- (dtucker) [contrib/cygwin/ssh-{host,user}-config] Add ECDSA key
[openssh-git.git] / contrib / caldera / sshd.init
blob983146f4fe0015ef6e84b02f02afe3ddcba6a4d5
1 #! /bin/bash
3 # $Id: sshd.init,v 1.4 2003/11/21 12:48:57 djm Exp $
5 ### BEGIN INIT INFO
6 # Provides:
7 # Required-Start: $network
8 # Required-Stop:
9 # Default-Start: 3 4 5
10 # Default-Stop: 0 1 2 6
11 # Description: sshd
12 # Bring up/down the OpenSSH secure shell daemon.
13 ### END INIT INFO
15 # Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
16 # Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
17 # Modified for OpenLinux by Raymund Will <ray@caldera.de>
19 NAME=sshd
20 DAEMON=/usr/sbin/$NAME
21 # Hack-Alert(TM)! This is necessary to get around the 'reload'-problem
22 # created by recent OpenSSH daemon/ssd combinations. See Caldera internal
23 # PR [linux/8278] for details...
24 PIDF=/var/run/$NAME.pid
25 NAME=$DAEMON
27 _status() {
28 [ -z "$1" ] || local pidf="$1"
29 local ret=-1
30 local pid
31 if [ -n "$pidf" ] && [ -r "$pidf" ]; then
32 pid=$(head -1 $pidf)
33 else
34 pid=$(pidof $NAME)
37 if [ ! -e $SVIlock ]; then
38 # no lock-file => not started == stopped?
39 ret=3
40 elif [ -n "$pidf" -a ! -f "$pidf" ] || [ -z "$pid" ]; then
41 # pid-file given but not present or no pid => died, but was not stopped
42 ret=2
43 elif [ -r /proc/$pid/cmdline ] &&
44 echo -ne $NAME'\000' | cmp -s - /proc/$pid/cmdline; then
45 # pid-file given and present or pid found => check process...
46 # but don't compare exe, as this will fail after an update!
47 # compares OK => all's well, that ends well...
48 ret=0
49 else
50 # no such process or exe does not match => stale pid-file or process died
51 # just recently...
52 ret=1
54 return $ret
57 # Source function library (and set vital variables).
58 . @SVIdir@/functions
60 case "$1" in
61 start)
62 [ ! -e $SVIlock ] || exit 0
63 [ -x $DAEMON ] || exit 5
64 SVIemptyConfig @sysconfdir@/sshd_config && exit 6
66 if [ ! \( -f @sysconfdir@/ssh_host_key -a \
67 -f @sysconfdir@/ssh_host_key.pub \) -a \
68 ! \( -f @sysconfdir@/ssh_host_rsa_key -a \
69 -f @sysconfdir@/ssh_host_rsa_key.pub \) -a \
70 ! \( -f @sysconfdir@/ssh_host_dsa_key -a \
71 -f @sysconfdir@/ssh_host_dsa_key.pub \) ]; then
73 echo "$SVIsubsys: host key not initialized: skipped!"
74 echo "$SVIsubsys: use ssh-host-keygen to generate one!"
75 exit 6
78 echo -n "Starting $SVIsubsys services: "
79 ssd -S -x $DAEMON -n $NAME -- $OPTIONS
80 ret=$?
82 echo "."
83 touch $SVIlock
86 stop)
87 [ -e $SVIlock ] || exit 0
89 echo -n "Stopping $SVIsubsys services: "
90 ssd -K -p $PIDF -n $NAME
91 ret=$?
93 echo "."
94 rm -f $SVIlock
97 force-reload|reload)
98 [ -e $SVIlock ] || exit 0
100 echo "Reloading $SVIsubsys configuration files: "
101 ssd -K --signal 1 -q -p $PIDF -n $NAME
102 ret=$?
103 echo "done."
106 restart)
107 $0 stop
108 $0 start
109 ret=$?
112 status)
113 _status $PIDF
114 ret=$?
118 echo "Usage: $SVIscript {[re]start|stop|[force-]reload|status}"
119 ret=2
122 esac
124 exit $ret