[root@ㅣlocalhost] vi /etc/init.d/inadyn #!/bin/bash # # inadyn Startup script fo CODNS update service # config: /etc/inadyn.conf # pidfile: /tmp/inadyn.pid # case "$1" in start) if [ -f /tmp/inadyn.pid ]; then PID=$(cat /tmp/inadyn.pid) kill -0 ${PID} &>/dev/null if [ $? = 0 ]; then echo "inadyn is already running." else /usr/bin/inadyn pidof inadyn > /tmp/inadyn.pid PID=$(cat /tmp/inadyn.pid) kill -0 ${PID} &>/dev/null if [ $? = 0 ]; then echo "inadyn started succesfully." else echo "Error starting inadyn" fi fi else /usr/bin/inadyn pidof inadyn > /tmp/inadyn.pid PID=$(cat /tmp/inadyn.pid) kill -0 ${PID} &>/dev/null if [ $? = 0 ]; then echo "inadyn started succesfully." else echo "Error starting inadyn" fi fi ;;
stop) if [ -f /tmp/inadyn.pid ];then PID=$(cat /tmp/inadyn.pid) kill -0 ${PID} &>/dev/null if [ $? = 0 ]; then /bin/kill ${PID} kill -0 ${PID} &>/dev/null if [ $? = 1 ]; then echo "inadyn stopped succesfully." else echo "Error stopping inadyn" fi else echo "inadyn is already stopped." fi else echo "inadyn is already stopped." fi ;;
status) PID=$(cat /tmp/inadyn.pid) if ps -p $PID > /dev/null then echo "inadyn is running" else echo "inadyn is not running" fi ;;
reload|restart) $0 stop $0 start ;;
*) echo "Usage: $0 start|stop|restart|reload" exit 1 esac exit 0
[root@ㅣlocalhost] chmod +x /etc/init.d/inadyn
[root@ㅣlocalhost] chkconfig --add inadyn
[root@ㅣlocalhost] chkconfig inadyn on
[root@ㅣlocalhost] chkconfig --list inadyn
inadyn 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|