wok annotate backuppc/stuff/etc/init.d/backuppc @ 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
'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 | 118babc9679f |
children |
rev | line source |
---|---|
pascal@9282 | 1 #!/bin/sh |
pascal@9282 | 2 # /etc/init.d/backuppc: Start, stop and restart backuppc daemon on SliTaz, at boot |
pascal@9282 | 3 # time or with the command line. |
pascal@9282 | 4 # |
pascal@9282 | 5 # To start daemon at boot time, just put the right name in the $RUN_DAEMONS |
pascal@9282 | 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf. |
pascal@9282 | 7 # |
pascal@9282 | 8 . /etc/init.d/rc.functions |
pascal@9282 | 9 . /etc/daemons.conf |
pascal@9282 | 10 |
pascal@9282 | 11 NAME=BackupPC |
al@19159 | 12 DESC="$(_ '%s daemon' backuppc)" |
pascal@9282 | 13 DAEMON=/usr/bin/BackupPC |
pascal@9282 | 14 OPTIONS=$BACKUPPC_OPTIONS |
pascal@9282 | 15 [ -n "$OPTIONS" ] || OPTIONS="-d" |
pascal@9282 | 16 PIDFILE=/var/run/backuppc.pid |
pascal@9282 | 17 |
pascal@9282 | 18 case "$1" in |
pascal@9282 | 19 start) |
pascal@9282 | 20 if active_pidfile $PIDFILE $NAME ; then |
al@19159 | 21 _ '%s is already running.' $NAME |
pascal@9282 | 22 exit 1 |
pascal@9282 | 23 fi |
al@19159 | 24 action 'Starting %s: %s...' "$DESC" $NAME |
pascal@9282 | 25 su -s /bin/sh -c "$DAEMON $OPTIONS" www |
al@19159 | 26 pidof $NAME | awk '{print $1}' > $PIDFILE |
pascal@9282 | 27 status |
pascal@9282 | 28 ;; |
pascal@9282 | 29 stop) |
pascal@9282 | 30 if ! active_pidfile $PIDFILE $NAME ; then |
al@19159 | 31 _ '%s is not running.' $NAME |
pascal@9282 | 32 exit 1 |
pascal@9282 | 33 fi |
al@19159 | 34 action 'Stopping %s: %s...' "$DESC" $NAME |
al@19159 | 35 kill $(cat $PIDFILE) |
pascal@9282 | 36 rm $PIDFILE |
pascal@9282 | 37 status |
pascal@9282 | 38 ;; |
pascal@9282 | 39 restart) |
pascal@9282 | 40 if ! active_pidfile $PIDFILE $NAME ; then |
al@19159 | 41 _ '%s is not running.' $NAME |
pascal@9282 | 42 exit 1 |
pascal@9282 | 43 fi |
al@19159 | 44 action 'Restarting %s: %s...' "$DESC" $NAME |
al@19159 | 45 kill $(cat $PIDFILE) |
pascal@9282 | 46 rm $PIDFILE |
pascal@9282 | 47 sleep 2 |
pascal@9282 | 48 su -c "$DAEMON $OPTIONS" www |
al@19159 | 49 pidof $NAME | awk '{print $1}' > $PIDFILE |
pascal@9282 | 50 status |
pascal@9282 | 51 ;; |
pascal@9282 | 52 reload) |
al@19159 | 53 kill -1 $(cat $PIDFILE) |
pascal@9282 | 54 status |
pascal@9282 | 55 ;; |
pascal@9282 | 56 *) |
al@19159 | 57 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart|reload]" |
al@19159 | 58 newline |
pascal@9282 | 59 exit 1 |
pascal@9282 | 60 ;; |
pascal@9282 | 61 esac |
pascal@9282 | 62 |
pascal@9282 | 63 exit 0 |