wok view dropbear-pam/stuff/init.d/dropbear @ rev 2281
perdition: disable pam support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Feb 19 11:05:04 2009 +0000 (2009-02-19) |
parents | |
children |
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="SSH server"
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 echo -n "Generating $NAME rsa key... "
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 echo -n "Generating $NAME dss key... "
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 [ -f $PIDFILE ] ; then
35 echo "$NAME already running."
36 exit 1
37 fi
38 echo -n "Starting $DESC: $NAME... "
39 $DAEMON $OPTIONS
40 status
41 ;;
42 stop)
43 if [ ! -f $PIDFILE ] ; then
44 echo "$NAME is not running."
45 exit 1
46 fi
47 echo -n "Stopping $DESC: $NAME... "
48 kill `cat $PIDFILE`
49 status
50 ;;
51 restart)
52 if [ ! -f $PIDFILE ] ; then
53 echo "$NAME is not running."
54 exit 1
55 fi
56 echo -n "Restarting $DESC: $NAME... "
57 kill `cat $PIDFILE`
58 sleep 2
59 $DAEMON $OPTIONS
60 status
61 ;;
62 *)
63 echo ""
64 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
65 echo ""
66 exit 1
67 ;;
68 esac
70 exit 0