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