]> andersk Git - openssh.git/blame - opensshd.init.in
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / opensshd.init.in
CommitLineData
eeb27c78 1#!@STARTUP_SCRIPT_SHELL@
6e464960 2# Donated code that was put under PD license.
3#
4# Stripped PRNGd out of it for the time being.
5
17d429bb 6umask 022
7
ddd8c95b 8CAT=@CAT@
9KILL=@KILL@
6e464960 10
ddd8c95b 11prefix=@prefix@
12sysconfdir=@sysconfdir@
13piddir=@piddir@
6e464960 14
78c84f13 15SSHD=$prefix/sbin/sshd
09a3bd6d 16PIDFILE=$piddir/sshd.pid
e4402dc5 17PidFile=`grep "^PidFile" ${sysconfdir}/sshd_config | tr "=" " " | awk '{print $2}'`
18[ X$PidFile = X ] || PIDFILE=$PidFile
78c84f13 19SSH_KEYGEN=$prefix/bin/ssh-keygen
ddd8c95b 20HOST_KEY_RSA1=$sysconfdir/ssh_host_key
21HOST_KEY_DSA=$sysconfdir/ssh_host_dsa_key
22HOST_KEY_RSA=$sysconfdir/ssh_host_rsa_key
6e464960 23
6e464960 24
25checkkeys() {
26 if [ ! -f $HOST_KEY_RSA1 ]; then
aff51935 27 ${SSH_KEYGEN} -t rsa1 -f ${HOST_KEY_RSA1} -N ""
6e464960 28 fi
29 if [ ! -f $HOST_KEY_DSA ]; then
aff51935 30 ${SSH_KEYGEN} -t dsa -f ${HOST_KEY_DSA} -N ""
6e464960 31 fi
32 if [ ! -f $HOST_KEY_RSA ]; then
aff51935 33 ${SSH_KEYGEN} -t rsa -f ${HOST_KEY_RSA} -N ""
6e464960 34 fi
35}
36
37stop_service() {
38 if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
aff51935 39 PID=`${CAT} ${PIDFILE}`
6e464960 40 fi
41 if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
aff51935 42 ${KILL} ${PID}
6e464960 43 else
aff51935 44 echo "Unable to read PID file"
6e464960 45 fi
46}
47
48start_service() {
49 # XXX We really should check if the service is already going, but
50 # XXX we will opt out at this time. - Bal
51
52 # Check to see if we have keys that need to be made
53 checkkeys
54
55 # Start SSHD
56 echo "starting $SSHD... \c" ; $SSHD
57
58 sshd_rc=$?
59 if [ $sshd_rc -ne 0 ]; then
aff51935 60 echo "$0: Error ${sshd_rc} starting ${SSHD}... bailing."
61 exit $sshd_rc
6e464960 62 fi
63 echo done.
64}
65
66case $1 in
67
68'start')
69 start_service
70 ;;
71
72'stop')
73 stop_service
74 ;;
75
76'restart')
77 stop_service
78 start_service
79 ;;
80
81*)
82 echo "$0: usage: $0 {start|stop|restart}"
83 ;;
84esac
This page took 0.20267 seconds and 5 git commands to generate.