wok-current annotate busybox/stuff/daemon @ rev 8268

Fix: pack swrast drivers into mesa-dri
author Antoine Bodin <gokhlayeh@slitaz.org>
date Sun Jan 30 05:22:41 2011 +0100 (2011-01-30)
parents
children d2c1950b6f95
rev   line source
pascal@5308 1 #!/bin/sh
pascal@5308 2 # Start, stop and restart a busybox deamon on SliTaz, at boot time or
pascal@5308 3 # with the command line.
pascal@5308 4 #
pascal@5308 5 # To start daemon at boot time, just put the right name in the $RUN_DAEMONS
pascal@5308 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
pascal@5308 7 #
pascal@5308 8 . /etc/init.d/rc.functions
pascal@5308 9
pascal@5308 10 NAME=$(basename $0)
pascal@5308 11 DESC="$NAME deamon"
pascal@5308 12 DAEMON=$(which $NAME)
pascal@5308 13 eval $(grep -i ^${NAME}_OPTIONS /etc/daemons.conf | sed 's/.*_OPT/OPT/')
pascal@5308 14 PIDFILE=/var/run/$NAME.pid
pascal@5308 15
pascal@5308 16 active_inetd()
pascal@5308 17 {
pascal@5308 18 if grep $DAEMON /etc/inetd.conf | grep -q ^\#; then
pascal@5308 19 sed -i "s,^#\(.*$DAEMON.*\)$,\1," /etc/inetd.conf
pascal@5308 20 /etc/init.d/inetd stop > /dev/null
pascal@5308 21 exec /etc/init.d/inetd start
pascal@5308 22 else
pascal@5308 23 echo "$NAME is already active."
pascal@5308 24 exit 1
pascal@5308 25 fi
pascal@5308 26 }
pascal@5308 27
pascal@5308 28 inactive_inetd()
pascal@5308 29 {
pascal@5308 30 if grep $DAEMON /etc/inetd.conf | grep -q ^\#; then
pascal@5308 31 echo "$NAME is not active."
pascal@5308 32 exit 1
pascal@5308 33 else
pascal@5308 34 sed -i "s,^.*$DAEMON.*$,#&," /etc/inetd.conf
pascal@5308 35 /etc/init.d/inetd stop > /dev/null
pascal@5308 36 exec /etc/init.d/inetd start
pascal@5308 37 fi
pascal@5308 38 }
pascal@5308 39
pascal@5308 40 case "$1" in
pascal@5308 41 start)
pascal@5308 42 grep -qs $DAEMON /etc/inetd.conf && active_inetd
pascal@5308 43 if active_pidfile $PIDFILE $NAME ; then
pascal@5308 44 echo "$NAME is already running."
pascal@5308 45 exit 1
pascal@5308 46 fi
pascal@5308 47 echo -n "Starting $DESC: $NAME... "
pascal@5308 48 $DAEMON $OPTIONS
pascal@5308 49 [ -f $PIDFILE ] || pidof $NAME | awk '{ print $1 }' > $PIDFILE
pascal@5308 50 active_pidfile $PIDFILE $NAME
pascal@5308 51 status
pascal@5308 52 ;;
pascal@5308 53 stop)
pascal@5308 54 grep -qs $DAEMON /etc/inetd.conf && inactive_inetd
pascal@5308 55 if ! active_pidfile $PIDFILE $NAME ; then
pascal@5308 56 echo "$NAME is not running."
pascal@5308 57 exit 1
pascal@5308 58 fi
pascal@5308 59 echo -n "Stopping $DESC: $NAME... "
pascal@5308 60 kill `cat $PIDFILE`
pascal@5308 61 status
pascal@5308 62 ;;
pascal@5308 63 restart)
pascal@5308 64 grep -qs $DAEMON /etc/inetd.conf && exit 0
pascal@5308 65 if ! active_pidfile $PIDFILE $NAME ; then
pascal@5308 66 echo "$NAME is not running."
pascal@5308 67 exit 1
pascal@5308 68 fi
pascal@5308 69 echo -n "Restarting $DESC: $NAME... "
pascal@5308 70 kill `cat $PIDFILE`
pascal@5308 71 sleep 2
pascal@5308 72 $DAEMON $OPTIONS
pascal@5308 73 [ -f $PIDFILE ] || pidof $NAME | awk '{ print $1 }' > $PIDFILE
pascal@5308 74 active_pidfile $PIDFILE $NAME
pascal@5308 75 status
pascal@5308 76 ;;
pascal@5308 77 *)
pascal@5308 78 echo ""
pascal@5308 79 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
pascal@5308 80 echo ""
pascal@5308 81 exit 1
pascal@5308 82 ;;
pascal@5308 83 esac
pascal@5308 84
pascal@5308 85 exit 0