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