wok view openssh/stuff/openssh @ rev 18897

syslinux/isohybrid.exe add -r support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Feb 14 22:06:06 2016 +0100 (2016-02-14)
parents 0d8a1a3edc72
children 7f188676b59c
line source
1 #!/bin/sh
2 # /etc/init.d/openssh : Start, stop and restart OpenSSH server on SliTaz, at
3 # boot time or with the command line.
4 #
5 # To start OpenSSH server at boot time, just put openssh 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=OpenSSH
12 DESC="OpenSSH server"
13 DAEMON=/usr/sbin/sshd
14 OPTIONS=$OPENSSH_OPTIONS
15 PIDFILE=/var/run/sshd.pid
17 [ -d /var/run/sshd ] || mkdir -p /var/run/sshd
19 case "$1" in
20 start)
21 # We need rsa and dsa host key file to start dropbear.
22 if [ ! -f /etc/ssh/ssh_host_rsa_key ] ; then
23 echo "Generating $NAME rsa key... "
24 ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N ''
25 fi
26 if [ ! -f /etc/ssh/ssh_host_dsa_key ] ; then
27 echo "Generating $NAME dsa key... "
28 ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N ''
29 fi
30 if [ ! -f /etc/ssh/ssh_host_ecdsa_key ] ; then
31 echo "Generating $NAME ecdsa key... "
32 ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C '' -N ''
33 fi
34 if active_pidfile $PIDFILE sshd ; then
35 echo "$NAME already running."
36 exit 1
37 fi
38 action "Starting $DESC: $NAME... "
39 $DAEMON $OPTIONS
40 status
41 ;;
42 stop)
43 if ! active_pidfile $PIDFILE sshd ; then
44 echo "$NAME is not running."
45 exit 1
46 fi
47 action "Stopping $DESC: $NAME... "
48 kill $(cat $PIDFILE)
49 status
50 ;;
51 restart)
52 if ! active_pidfile $PIDFILE sshd ; then
53 echo "$NAME is not running."
54 exit 1
55 fi
56 action "Restarting $DESC: $NAME... "
57 kill $(cat $PIDFILE)
58 sleep 2
59 $DAEMON $OPTIONS
60 status
61 ;;
62 *)
63 emsg "<n><b>Usage:</b> /etc/init.d/$(basename $0) [start|stop|restart]"
64 newline
65 exit 1
66 ;;
67 esac
69 exit 0