2 # Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
4 # Author: Jiri Smid <feedback@suse.de>
8 # and symbolic its link
14 # Required-Start: $network $remote_fs
15 # Required-Stop: $network $remote_fs
17 # Default-Stop: 0 1 2 6
18 # Description: Start the sshd daemon
21 SSHD_BIN=/usr/sbin/sshd
22 test -x $SSHD_BIN || exit 5
24 SSHD_SYSCONFIG=/etc/sysconfig/ssh
25 test -r $SSHD_SYSCONFIG || exit 6
28 SSHD_PIDFILE=/var/run/sshd.init.pid
32 # Shell functions sourced from /etc/rc.status:
33 # rc_check check and set local and overall rc status
34 # rc_status check and set local and overall rc status
35 # rc_status -v ditto but be verbose in local rc status
36 # rc_status -v -r ditto and clear the local rc status
37 # rc_failed set local and overall rc status to failed
38 # rc_reset clear local rc status (overall remains)
39 # rc_exit exit appropriate to overall rc status
41 # First reset status of this service
46 # Generate any missing host keys
48 echo -n "Starting SSH daemon"
49 ## Start daemon with startproc(8). If this fails
50 ## the echo return value is set appropriate.
52 startproc -f -p $SSHD_PIDFILE $SSHD_BIN $SSHD_OPTS -o "PidFile=$SSHD_PIDFILE"
54 # Remember status and be verbose
58 echo -n "Shutting down SSH daemon"
59 ## Stop daemon with killproc(8) and if this fails
60 ## set echo the echo return value.
62 killproc -p $SSHD_PIDFILE -TERM $SSHD_BIN
64 # Remember status and be verbose
68 ## Stop the service and if this succeeds (i.e. the
69 ## service was running before), start it again.
70 $0 status >/dev/null && $0 restart
72 # Remember status and be quiet
76 ## Stop the service and regardless of whether it was
77 ## running or not, start it again.
81 # Remember status and be quiet
85 ## Signal the daemon to reload its config. Most daemons
86 ## do this on signal 1 (SIGHUP).
88 echo -n "Reload service sshd"
90 killproc -p $SSHD_PIDFILE -HUP $SSHD_BIN
96 echo -n "Checking for service sshd "
97 ## Check status with checkproc(8), if process is running
98 ## checkproc will return with exit status 0.
100 # Status has a slightly different for the status command:
101 # 0 - service running
102 # 1 - service dead, but /var/run/ pid file exists
103 # 2 - service dead, but /var/lock/ lock file exists
104 # 3 - service not running
106 checkproc -p $SSHD_PIDFILE $SSHD_BIN
111 ## Optional: Probe for the necessity of a reload,
112 ## give out the argument which is required for a reload.
114 test /etc/ssh/sshd_config -nt $SSHD_PIDFILE && echo reload
117 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"