wok annotate dropbear/stuff/init.d/dropbear @ 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 | 0c5bcb5a0cad |
children | ce7157786dac |
rev | line source |
---|---|
pankso@126 | 1 #!/bin/sh |
al@19159 | 2 # /etc/init.d/dropbear : Start, stop and restart SSH server on SliTaz, at |
pankso@126 | 3 # boot time or with the command line. |
pankso@126 | 4 # |
pankso@126 | 5 # To start SSH server at boot time, just put dropbear in the $RUN_DAEMONS |
pankso@126 | 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf |
pankso@126 | 7 # |
pankso@126 | 8 . /etc/init.d/rc.functions |
pankso@126 | 9 . /etc/daemons.conf |
pankso@126 | 10 |
pankso@126 | 11 NAME=Dropbear |
al@19159 | 12 DESC="$(_ '%s server' SSH)" |
pankso@126 | 13 DAEMON=/usr/sbin/dropbear |
pankso@126 | 14 OPTIONS=$DROPBEAR_OPTIONS |
pankso@126 | 15 PIDFILE=/var/run/dropbear.pid |
pankso@126 | 16 |
pankso@126 | 17 case "$1" in |
pankso@126 | 18 start) |
pankso@126 | 19 # We need rsa and dss host key file to start dropbear. |
pascal@1273 | 20 if [ ! -s /etc/dropbear/dropbear_rsa_host_key ] ; then |
al@19159 | 21 action 'Generating Dropbear %s key...' RSA |
erjo@1410 | 22 # Need to delete key before creating it. |
erjo@1410 | 23 rm -f /etc/dropbear/dropbear_rsa_host_key |
al@19159 | 24 dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key >/dev/null 2>&1 |
erjo@1410 | 25 status |
pankso@126 | 26 fi |
pascal@1273 | 27 if [ ! -s /etc/dropbear/dropbear_dss_host_key ] ; then |
al@19159 | 28 action 'Generating Dropbear %s key...' DSS |
erjo@1410 | 29 # Need to delete key before creating it. |
erjo@1410 | 30 rm -f /etc/dropbear/dropbear_dss_host_key |
al@19159 | 31 dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key >/dev/null 2>&1 |
erjo@1410 | 32 status |
pankso@126 | 33 fi |
pascal@2395 | 34 if active_pidfile $PIDFILE dropbear ; then |
al@19159 | 35 _ '%s is already running.' $NAME |
pankso@126 | 36 exit 1 |
pankso@126 | 37 fi |
al@19159 | 38 action 'Starting %s: %s...' "$DESC" $NAME |
pankso@126 | 39 $DAEMON $OPTIONS |
pankso@126 | 40 status |
pankso@126 | 41 ;; |
pankso@126 | 42 stop) |
pascal@2395 | 43 if ! active_pidfile $PIDFILE dropbear ; then |
al@19159 | 44 _ '%s is not running.' $NAME |
pankso@126 | 45 exit 1 |
pankso@126 | 46 fi |
al@19159 | 47 action 'Stopping %s: %s...' "$DESC" $NAME |
al@19159 | 48 kill $(cat $PIDFILE) |
pankso@126 | 49 status |
pankso@126 | 50 ;; |
pankso@126 | 51 restart) |
pascal@2395 | 52 if ! active_pidfile $PIDFILE dropbear ; then |
al@19159 | 53 _ '%s is not running.' $NAME |
pankso@126 | 54 exit 1 |
pankso@126 | 55 fi |
al@19159 | 56 action 'Restarting %s: %s...' "$DESC" $NAME |
al@19159 | 57 kill $(cat $PIDFILE) |
pankso@126 | 58 sleep 2 |
pankso@126 | 59 $DAEMON $OPTIONS |
pankso@126 | 60 status |
pankso@126 | 61 ;; |
pankso@126 | 62 *) |
al@19159 | 63 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]" |
al@19159 | 64 newline |
pankso@126 | 65 exit 1 |
pankso@126 | 66 ;; |
pankso@126 | 67 esac |
pankso@126 | 68 |
pankso@126 | 69 exit 0 |