summaryrefslogtreecommitdiff
path: root/debian/openssh-server.init
diff options
context:
space:
mode:
Diffstat (limited to 'debian/openssh-server.init')
-rw-r--r--debian/openssh-server.init74
1 files changed, 74 insertions, 0 deletions
diff --git a/debian/openssh-server.init b/debian/openssh-server.init
new file mode 100644
index 000000000..552330422
--- /dev/null
+++ b/debian/openssh-server.init
@@ -0,0 +1,74 @@
1#! /bin/sh
2set -e
3
4# /etc/init.d/ssh: start and stop the OpenBSD "secure shell(tm)" daemon
5
6test -x /usr/sbin/sshd || exit 0
7( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0
8
9if test -f /etc/default/ssh; then
10 . /etc/default/ssh
11fi
12
13check_for_no_start() {
14 # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
15 if [ -e /etc/ssh/sshd_not_to_be_run ]; then
16 echo "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)"
17 exit 0
18 fi
19}
20
21check_privsep_dir() {
22 # Create the PrivSep empty dir if necessary
23 if [ ! -d /var/run/sshd ]; then
24 mkdir /var/run/sshd
25 chmod 0755 /var/run/sshd
26 fi
27}
28
29check_config() {
30 if [ ! -e /etc/ssh/sshd_not_to_be_run ]; then
31 /usr/sbin/sshd -t || exit 1
32 fi
33}
34
35export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
36
37case "$1" in
38 start)
39 check_for_no_start
40 check_privsep_dir
41 echo -n "Starting OpenBSD Secure Shell server: sshd"
42 start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS
43 echo "."
44 ;;
45 stop)
46 echo -n "Stopping OpenBSD Secure Shell server: sshd"
47 start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid
48 echo "."
49 ;;
50
51 reload|force-reload)
52 check_for_no_start
53 check_config
54 echo -n "Reloading OpenBSD Secure Shell server's configuration"
55 start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
56 echo "."
57 ;;
58
59 restart)
60 check_config
61 echo -n "Restarting OpenBSD Secure Shell server: sshd"
62 start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/sshd.pid
63 check_for_no_start
64 check_privsep_dir
65 start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS
66 echo "."
67 ;;
68
69 *)
70 echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
71 exit 1
72esac
73
74exit 0