wok-stable annotate busybox/stuff/zcip @ rev 3875

Busybox: ensure pidfile are valid
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Aug 10 13:56:55 2009 +0200 (2009-08-10)
parents 72fa50265748
children
rev   line source
pascal@937 1 #!/bin/sh
pascal@937 2 # /etc/init.d/zcip: Start, stop and restart ZeroConf deamon on SliTaz, at boot
pascal@937 3 # time or with the command line.
pascal@937 4 #
pascal@937 5 # To start daemon at boot time, just put the right name in the $RUN_DAEMONS
pascal@937 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
pascal@937 7 #
pascal@937 8 . /etc/init.d/rc.functions
pascal@937 9 . /etc/daemons.conf
pascal@3875 10 . /etc/network.conf
pascal@937 11
pascal@937 12 NAME=Zcip
pascal@937 13 DESC="ZeroConf deamon"
pascal@937 14 DAEMON=/sbin/zcip
pascal@937 15 OPTIONS=$ZCIP_OPTIONS
pascal@937 16 PIDFILE=/var/run/zcip.pid
pascal@3875 17 [ -n "$OPTIONS" ] || OPTIONS="$INTERFACE /etc/zcip.script"
pascal@937 18
pascal@937 19 case "$1" in
pascal@937 20 start)
pascal@3875 21 if active_pidfile $PIDFILE zcip ; then
pascal@937 22 echo "$NAME already running."
pascal@937 23 exit 1
pascal@937 24 fi
pascal@937 25 echo -n "Starting $DESC: $NAME... "
pascal@937 26 $DAEMON $OPTIONS && echo `pidof $DAEMON` > $PIDFILE
pascal@937 27 status
pascal@937 28 ;;
pascal@937 29 stop)
pascal@3875 30 if ! active_pidfile $PIDFILE zcip ; then
pascal@937 31 echo "$NAME is not running."
pascal@937 32 exit 1
pascal@937 33 fi
pascal@937 34 echo -n "Stopping $DESC: $NAME... "
pascal@937 35 kill `cat $PIDFILE`
pascal@937 36 rm $PIDFILE
pascal@937 37 status
pascal@937 38 ;;
pascal@937 39 restart)
pascal@3875 40 if ! active_pidfile $PIDFILE zcip ; then
pascal@937 41 echo "$NAME is not running."
pascal@937 42 exit 1
pascal@937 43 fi
pascal@937 44 echo -n "Restarting $DESC: $NAME... "
pascal@937 45 kill `cat $PIDFILE`
pascal@937 46 rm $PIDFILE
pascal@937 47 sleep 2
pascal@937 48 $DAEMON $OPTIONS
pascal@937 49 status
pascal@937 50 ;;
pascal@937 51 *)
pascal@937 52 echo ""
pascal@937 53 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
pascal@937 54 echo ""
pascal@937 55 exit 1
pascal@937 56 ;;
pascal@937 57 esac
pascal@937 58
pascal@937 59 exit 0