wok annotate openssh/stuff/openssh @ rev 16681

Create some /var/run/<dir> in /etc/init.d/<daemon> scritps
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 18 20:24:07 2014 +0000 (2014-05-18)
parents 469b918af40a
children e2e3be9972fa
rev   line source
pascal@860 1 #!/bin/sh
pascal@860 2 # /etc/init.d/openssh : Start, stop and restart OpenSSH server on SliTaz, at
pascal@860 3 # boot time or with the command line.
pascal@860 4 #
pascal@860 5 # To start OpenSSH server at boot time, just put openssh in the $RUN_DAEMONS
pascal@860 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
pascal@860 7 #
pascal@860 8 . /etc/init.d/rc.functions
pascal@860 9 . /etc/daemons.conf
pascal@860 10
pascal@860 11 NAME=OpenSSH
pascal@860 12 DESC="OpenSSH server"
pascal@860 13 DAEMON=/usr/sbin/sshd
pascal@860 14 OPTIONS=$OPENSSH_OPTIONS
pascal@860 15 PIDFILE=/var/run/sshd.pid
pascal@860 16
pascal@16681 17 [ -d /var/run/sshd ] || mkdir -p /var/run/sshd
pascal@860 18 case "$1" in
pascal@860 19 start)
pascal@860 20 # We need rsa and dsa host key file to start dropbear.
pascal@860 21 if [ ! -f /etc/ssh/ssh_host_rsa_key ] ; then
pascal@860 22 echo "Generating $NAME rsa key... "
pascal@860 23 ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N ''
pascal@860 24 fi
pascal@860 25 if [ ! -f /etc/ssh/ssh_host_dsa_key ] ; then
pascal@860 26 echo "Generating $NAME dsa key... "
pascal@860 27 ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N ''
pascal@860 28 fi
erjo@11999 29 if [ ! -f /etc/ssh/ssh_host_ecdsa_key ] ; then
erjo@11999 30 echo "Generating $NAME ecdsa key... "
erjo@11999 31 ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C '' -N ''
erjo@11999 32 fi
pascal@6170 33 if active_pidfile $PIDFILE sshd ; then
pascal@860 34 echo "$NAME already running."
pascal@860 35 exit 1
pascal@860 36 fi
pascal@860 37 echo -n "Starting $DESC: $NAME... "
pascal@860 38 $DAEMON $OPTIONS
pascal@860 39 status
pascal@860 40 ;;
pascal@860 41 stop)
pascal@6170 42 if ! active_pidfile $PIDFILE sshd ; then
pascal@860 43 echo "$NAME is not running."
pascal@860 44 exit 1
pascal@860 45 fi
pascal@860 46 echo -n "Stopping $DESC: $NAME... "
pascal@860 47 kill `cat $PIDFILE`
pascal@860 48 status
pascal@860 49 ;;
pascal@860 50 restart)
pascal@6170 51 if ! active_pidfile $PIDFILE sshd ; then
pascal@860 52 echo "$NAME is not running."
pascal@860 53 exit 1
pascal@860 54 fi
pascal@860 55 echo -n "Restarting $DESC: $NAME... "
pascal@860 56 kill `cat $PIDFILE`
pascal@860 57 sleep 2
pascal@860 58 $DAEMON $OPTIONS
pascal@860 59 status
pascal@860 60 ;;
pascal@860 61 *)
pascal@860 62 echo ""
pascal@860 63 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
pascal@860 64 echo ""
pascal@860 65 exit 1
pascal@860 66 ;;
pascal@860 67 esac
pascal@860 68
pascal@860 69 exit 0