summaryrefslogtreecommitdiff
path: root/debian/openssh-server.ssh.init
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2010-04-07 13:56:13 +0100
committerColin Watson <cjwatson@debian.org>2010-04-07 13:56:13 +0100
commit71cab2ada0d25da322bc8c857aeeab43ecb6e3c6 (patch)
tree61aa7dbbfc8b10c03cdcec86eaa6ae0d3ef84538 /debian/openssh-server.ssh.init
parenta2e78317862f864feee24cf0e1dbfb203e9f041b (diff)
Convert to dh(1), and use dh_installdocs --link-doc.
Diffstat (limited to 'debian/openssh-server.ssh.init')
-rw-r--r--debian/openssh-server.ssh.init164
1 files changed, 164 insertions, 0 deletions
diff --git a/debian/openssh-server.ssh.init b/debian/openssh-server.ssh.init
new file mode 100644
index 000000000..62bcc21d4
--- /dev/null
+++ b/debian/openssh-server.ssh.init
@@ -0,0 +1,164 @@
1#! /bin/sh
2
3### BEGIN INIT INFO
4# Provides: sshd
5# Required-Start: $remote_fs $syslog
6# Required-Stop: $remote_fs $syslog
7# Default-Start: 2 3 4 5
8# Default-Stop:
9# Short-Description: OpenBSD Secure Shell server
10### END INIT INFO
11
12set -e
13
14# /etc/init.d/ssh: start and stop the OpenBSD "secure shell(tm)" daemon
15
16test -x /usr/sbin/sshd || exit 0
17( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0
18
19umask 022
20
21if test -f /etc/default/ssh; then
22 . /etc/default/ssh
23fi
24
25. /lib/lsb/init-functions
26
27if [ -n "$2" ]; then
28 SSHD_OPTS="$SSHD_OPTS $2"
29fi
30
31# Are we running from init?
32run_by_init() {
33 ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
34}
35
36check_for_no_start() {
37 # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
38 if [ -e /etc/ssh/sshd_not_to_be_run ]; then
39 if [ "$1" = log_end_msg ]; then
40 log_end_msg 0
41 fi
42 if ! run_by_init; then
43 log_action_msg "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)"
44 fi
45 exit 0
46 fi
47}
48
49check_dev_null() {
50 if [ ! -c /dev/null ]; then
51 if [ "$1" = log_end_msg ]; then
52 log_end_msg 1 || true
53 fi
54 if ! run_by_init; then
55 log_action_msg "/dev/null is not a character device!"
56 fi
57 exit 1
58 fi
59}
60
61check_privsep_dir() {
62 # Create the PrivSep empty dir if necessary
63 if [ ! -d /var/run/sshd ]; then
64 mkdir /var/run/sshd
65 chmod 0755 /var/run/sshd
66 fi
67}
68
69check_config() {
70 if [ ! -e /etc/ssh/sshd_not_to_be_run ]; then
71 /usr/sbin/sshd $SSHD_OPTS -t || exit 1
72 fi
73}
74
75export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
76
77case "$1" in
78 start)
79 check_privsep_dir
80 check_for_no_start
81 check_dev_null
82 log_daemon_msg "Starting OpenBSD Secure Shell server" "sshd"
83 if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then
84 log_end_msg 0
85 else
86 log_end_msg 1
87 fi
88 ;;
89 stop)
90 log_daemon_msg "Stopping OpenBSD Secure Shell server" "sshd"
91 if start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid; then
92 log_end_msg 0
93 else
94 log_end_msg 1
95 fi
96 ;;
97
98 reload|force-reload)
99 check_for_no_start
100 check_config
101 log_daemon_msg "Reloading OpenBSD Secure Shell server's configuration" "sshd"
102 if start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd; then
103 log_end_msg 0
104 else
105 log_end_msg 1
106 fi
107 ;;
108
109 restart)
110 check_privsep_dir
111 check_config
112 log_daemon_msg "Restarting OpenBSD Secure Shell server" "sshd"
113 start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/sshd.pid
114 check_for_no_start log_end_msg
115 check_dev_null log_end_msg
116 if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then
117 log_end_msg 0
118 else
119 log_end_msg 1
120 fi
121 ;;
122
123 try-restart)
124 check_privsep_dir
125 check_config
126 log_daemon_msg "Restarting OpenBSD Secure Shell server" "sshd"
127 set +e
128 start-stop-daemon --stop --quiet --retry 30 --pidfile /var/run/sshd.pid
129 RET="$?"
130 set -e
131 case $RET in
132 0)
133 # old daemon stopped
134 check_for_no_start log_end_msg
135 check_dev_null log_end_msg
136 if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then
137 log_end_msg 0
138 else
139 log_end_msg 1
140 fi
141 ;;
142 1)
143 # daemon not running
144 log_progress_msg "(not running)"
145 log_end_msg 0
146 ;;
147 *)
148 # failed to stop
149 log_progress_msg "(failed to stop)"
150 log_end_msg 1
151 ;;
152 esac
153 ;;
154
155 status)
156 status_of_proc -p /var/run/sshd.pid /usr/sbin/sshd sshd && exit 0 || exit $?
157 ;;
158
159 *)
160 log_action_msg "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart|try-restart|status}"
161 exit 1
162esac
163
164exit 0