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