]> andersk Git - gssapi-openssh.git/blame - openssh/contrib/suse/rc.sshd
Import of OpenSSH 5.2p1
[gssapi-openssh.git] / openssh / contrib / suse / rc.sshd
CommitLineData
3c0ef626 1#! /bin/sh
2c06c99b 2# Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
3c0ef626 3#
2c06c99b 4# Author: Jiri Smid <feedback@suse.de>
3c0ef626 5#
2c06c99b 6# /etc/init.d/sshd
3c0ef626 7#
8# and symbolic its link
9#
2c06c99b 10# /usr/sbin/rcsshd
3c0ef626 11#
2c06c99b 12### BEGIN INIT INFO
13# Provides: sshd
14# Required-Start: $network $remote_fs
15# Required-Stop: $network $remote_fs
16# Default-Start: 3 5
17# Default-Stop: 0 1 2 6
18# Description: Start the sshd daemon
19### END INIT INFO
3c0ef626 20
2c06c99b 21SSHD_BIN=/usr/sbin/sshd
22test -x $SSHD_BIN || exit 5
3c0ef626 23
2c06c99b 24SSHD_SYSCONFIG=/etc/sysconfig/ssh
25test -r $SSHD_SYSCONFIG || exit 6
26. $SSHD_SYSCONFIG
3c0ef626 27
2c06c99b 28SSHD_PIDFILE=/var/run/sshd.init.pid
29
30. /etc/rc.status
31
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
40
41# First reset status of this service
42rc_reset
3c0ef626 43
3c0ef626 44case "$1" in
45 start)
2c06c99b 46 if ! test -f /etc/ssh/ssh_host_key ; then
47 echo Generating /etc/ssh/ssh_host_key.
91d9cdd3 48 ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ''
2c06c99b 49 fi
50 if ! test -f /etc/ssh/ssh_host_dsa_key ; then
51 echo Generating /etc/ssh/ssh_host_dsa_key.
52
91d9cdd3 53 ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
2c06c99b 54 fi
55 if ! test -f /etc/ssh/ssh_host_rsa_key ; then
56 echo Generating /etc/ssh/ssh_host_rsa_key.
57
91d9cdd3 58 ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
2c06c99b 59 fi
60 echo -n "Starting SSH daemon"
3c0ef626 61 ## Start daemon with startproc(8). If this fails
62 ## the echo return value is set appropriate.
63
2c06c99b 64 startproc -f -p $SSHD_PIDFILE /usr/sbin/sshd $SSHD_OPTS -o "PidFile=$SSHD_PIDFILE"
3c0ef626 65
2c06c99b 66 # Remember status and be verbose
67 rc_status -v
3c0ef626 68 ;;
69 stop)
2c06c99b 70 echo -n "Shutting down SSH daemon"
3c0ef626 71 ## Stop daemon with killproc(8) and if this fails
72 ## set echo the echo return value.
73
2c06c99b 74 killproc -p $SSHD_PIDFILE -TERM /usr/sbin/sshd
3c0ef626 75
2c06c99b 76 # Remember status and be verbose
77 rc_status -v
3c0ef626 78 ;;
2c06c99b 79 try-restart)
80 ## Stop the service and if this succeeds (i.e. the
81 ## service was running before), start it again.
82 $0 status >/dev/null && $0 restart
83
84 # Remember status and be quiet
85 rc_status
86 ;;
3c0ef626 87 restart)
2c06c99b 88 ## Stop the service and regardless of whether it was
89 ## running or not, start it again.
90 $0 stop
91 $0 start
3c0ef626 92
2c06c99b 93 # Remember status and be quiet
94 rc_status
95 ;;
96 force-reload|reload)
97 ## Signal the daemon to reload its config. Most daemons
98 ## do this on signal 1 (SIGHUP).
3c0ef626 99
100 echo -n "Reload service sshd"
2c06c99b 101
102 killproc -p $SSHD_PIDFILE -HUP /usr/sbin/sshd
103
104 rc_status -v
105
106 ;;
3c0ef626 107 status)
2c06c99b 108 echo -n "Checking for service sshd "
109 ## Check status with checkproc(8), if process is running
110 ## checkproc will return with exit status 0.
3c0ef626 111
2c06c99b 112 # Status has a slightly different for the status command:
113 # 0 - service running
114 # 1 - service dead, but /var/run/ pid file exists
115 # 2 - service dead, but /var/lock/ lock file exists
116 # 3 - service not running
117
118 checkproc -p $SSHD_PIDFILE /usr/sbin/sshd
119
120 rc_status -v
3c0ef626 121 ;;
122 probe)
123 ## Optional: Probe for the necessity of a reload,
124 ## give out the argument which is required for a reload.
125
2c06c99b 126 test /etc/ssh/sshd_config -nt $SSHD_PIDFILE && echo reload
3c0ef626 127 ;;
128 *)
2c06c99b 129 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
3c0ef626 130 exit 1
131 ;;
132esac
2c06c99b 133rc_exit
This page took 1.299344 seconds and 5 git commands to generate.