wok annotate phpvirtualbox/stuff/etc/init.d/vboxwebsrv @ rev 19159

/etc/init.d/*: use 'action' in pair with 'status'.
'action' returns translated message, so why not to add full translatable /etc/init.d/* content
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu May 26 20:16:45 2016 +0300 (2016-05-26)
parents 5b1450e90bf6
children ff5fd8788cd9
rev   line source
pascal@7738 1 #!/bin/sh
al@19159 2 # Start, stop and restart vboxwebsrv deamon on SliTaz, at boot time or
pascal@7738 3 # with the command line.
pascal@7738 4 #
pascal@7738 5 # To start daemon at boot time, just put vboxwebsrv in the $RUN_DAEMONS
pascal@7738 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
pascal@7738 7 #
pascal@7738 8 . /etc/init.d/rc.functions
pascal@7738 9
pascal@7738 10 NAME=$(basename $0)
al@19159 11 DESC="$(_ '%s daemon' $NAME)"
pascal@7738 12 DAEMON=$(which $NAME)
pascal@7738 13 OPTIONS="-b --logfile /dev/null"
pascal@7738 14 eval $(grep -i ^${NAME}_OPTIONS /etc/daemons.conf | sed 's/.*_OPT/OPT/')
pascal@7738 15 PIDFILE=/var/run/$NAME.pid
pascal@7738 16
pascal@7738 17 case "$1" in
pascal@7738 18 start)
pascal@7738 19 if active_pidfile $PIDFILE $NAME ; then
al@19159 20 _ '%s is already running.' $NAME
pascal@7738 21 exit 1
pascal@7738 22 fi
al@19159 23 action 'Starting %s: %s...' "$DESC" $NAME
al@19159 24 $DAEMON $OPTIONS >/dev/null 2>&1
al@19159 25 [ -f $PIDFILE ] || pidof $NAME | awk '{print $1}' > $PIDFILE
pascal@7738 26 active_pidfile $PIDFILE $NAME
pascal@7738 27 status
pascal@7738 28 ;;
pascal@7738 29 stop)
pascal@7738 30 if ! active_pidfile $PIDFILE $NAME ; then
al@19159 31 _ '%s is not running.' $NAME
pascal@7738 32 exit 1
pascal@7738 33 fi
al@19159 34 action 'Stopping %s: %s...' "$DESC" $NAME
al@19159 35 kill $(cat $PIDFILE)
pascal@7738 36 status
pascal@7738 37 ;;
pascal@7738 38 restart)
pascal@7738 39 if ! active_pidfile $PIDFILE $NAME ; then
al@19159 40 _ '%s is not running.' $NAME
pascal@7738 41 exit 1
pascal@7738 42 fi
al@19159 43 action 'Restarting %s: %s...' "$DESC" $NAME
al@19159 44 kill $(cat $PIDFILE)
pascal@7738 45 sleep 2
al@19159 46 $DAEMON $OPTIONS >/dev/null 2>&1
al@19159 47 [ -f $PIDFILE ] || pidof $NAME | awk '{print $1}' > $PIDFILE
pascal@7738 48 active_pidfile $PIDFILE $NAME
pascal@7738 49 status
pascal@7738 50 ;;
al@19159 51 *)
al@19159 52 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]"
al@19159 53 newline
pascal@7738 54 exit 1
pascal@7738 55 ;;
pascal@7738 56 esac
pascal@7738 57
pascal@7738 58 exit 0