wok annotate busybox/stuff/daemon @ rev 21655

updated p11-kit and p11-kit-dev (0.23.12 -> 0.23.16)
author Hans-G?nter Theisgen
date Fri May 31 15:09:23 2019 +0100 (2019-05-31)
parents 7f188676b59c
children 314dd7281637
rev   line source
pascal@5308 1 #!/bin/sh
al@19161 2 # Start, stop and restart a busybox daemon 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)
al@19159 11 DESC="$(_ '%s daemon' $NAME)"
pascal@5308 12 DAEMON=$(which $NAME)
pascal@18590 13 for p in ${PATH//:/ }; do
pascal@18590 14 [ -L $p/$NAME ] || continue
pascal@18590 15 case "$(readlink $p/$NAME)" in
al@19159 16 *busybox)
al@19159 17 DAEMON=$p/$NAME
pascal@18590 18 break
pascal@18590 19 esac
pascal@18590 20 done
pascal@5308 21 eval $(grep -i ^${NAME}_OPTIONS /etc/daemons.conf | sed 's/.*_OPT/OPT/')
pascal@5308 22 PIDFILE=/var/run/$NAME.pid
pascal@5308 23
pascal@5308 24 active_inetd()
pascal@5308 25 {
pascal@5308 26 if grep $DAEMON /etc/inetd.conf | grep -q ^\#; then
pascal@5308 27 sed -i "s,^#\(.*$DAEMON.*\)$,\1," /etc/inetd.conf
al@19159 28 /etc/init.d/inetd stop >/dev/null
pascal@5308 29 exec /etc/init.d/inetd start
pascal@5308 30 else
al@19159 31 _ '%s is already active.' $NAME
pascal@5308 32 exit 1
pascal@5308 33 fi
pascal@5308 34 }
pascal@5308 35
pascal@5308 36 inactive_inetd()
pascal@5308 37 {
pascal@5308 38 if grep $DAEMON /etc/inetd.conf | grep -q ^\#; then
al@19159 39 _ '%s is not active.' $NAME
pascal@5308 40 exit 1
pascal@5308 41 else
pascal@5308 42 sed -i "s,^.*$DAEMON.*$,#&," /etc/inetd.conf
al@19159 43 /etc/init.d/inetd stop >/dev/null
pascal@5308 44 exec /etc/init.d/inetd start
pascal@5308 45 fi
pascal@5308 46 }
pascal@5308 47
pascal@5308 48 case "$1" in
pascal@5308 49 start)
pascal@5308 50 grep -qs $DAEMON /etc/inetd.conf && active_inetd
pascal@5308 51 if active_pidfile $PIDFILE $NAME ; then
al@19159 52 _ '%s is already running.' $NAME
pascal@5308 53 exit 1
pascal@5308 54 fi
al@19159 55 action 'Starting %s: %s...' "$DESC" $NAME
al@19159 56 $DAEMON $OPTIONS
al@19159 57 [ -f $PIDFILE ] || pidof $NAME | awk '{print $1}' > $PIDFILE
pascal@5308 58 active_pidfile $PIDFILE $NAME
pascal@5308 59 status
pascal@5308 60 ;;
pascal@5308 61 stop)
pascal@5308 62 grep -qs $DAEMON /etc/inetd.conf && inactive_inetd
pascal@5308 63 if ! active_pidfile $PIDFILE $NAME ; then
al@19159 64 _ '%s is not running.' $NAME
pascal@5308 65 exit 1
pascal@5308 66 fi
al@19159 67 action 'Stopping %s: %s...' "$DESC" $NAME
al@19159 68 kill $(cat $PIDFILE)
pascal@5308 69 status
pascal@5308 70 ;;
pascal@5308 71 restart)
pascal@5308 72 grep -qs $DAEMON /etc/inetd.conf && exit 0
pascal@5308 73 if ! active_pidfile $PIDFILE $NAME ; then
al@19159 74 _ '%s is not running.' $NAME
pascal@5308 75 exit 1
pascal@5308 76 fi
al@19159 77 action 'Restarting %s: %s...' "$DESC" $NAME
al@19159 78 kill $(cat $PIDFILE)
pascal@5308 79 sleep 2
pascal@5308 80 $DAEMON $OPTIONS
al@19159 81 [ -f $PIDFILE ] || pidof $NAME | awk '{print $1}' > $PIDFILE
pascal@5308 82 active_pidfile $PIDFILE $NAME
pascal@5308 83 status
pascal@5308 84 ;;
al@19159 85 *)
al@19159 86 emsg "<n><b>$(_ 'Usage:')</b> /etc/init.d/$(basename $0) [start|stop|restart]"
al@19159 87 newline
pascal@5308 88 exit 1
pascal@5308 89 ;;
pascal@5308 90 esac
pascal@5308 91
pascal@5308 92 exit 0