summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/openssh/openssh-5.6p1/init
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/openssh/openssh-5.6p1/init')
-rw-r--r--meta/recipes-connectivity/openssh/openssh-5.6p1/init88
1 files changed, 88 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssh/openssh-5.6p1/init b/meta/recipes-connectivity/openssh/openssh-5.6p1/init
new file mode 100644
index 0000000000..b16cbd61a6
--- /dev/null
+++ b/meta/recipes-connectivity/openssh/openssh-5.6p1/init
@@ -0,0 +1,88 @@
1#! /bin/sh
2set -e
3
4# /etc/init.d/ssh: start and stop the OpenBSD "secure shell" 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 /usr/sbin/sshd -t || exit 1
31}
32
33check_keys() {
34 # create keys if necessary
35 if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
36 echo " generating ssh RSA key..."
37 ssh-keygen -q -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
38 fi
39 if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
40 echo " generating ssh DSA key..."
41 ssh-keygen -q -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
42 fi
43}
44
45export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
46
47case "$1" in
48 start)
49 check_for_no_start
50 echo "Starting OpenBSD Secure Shell server: sshd"
51 check_keys
52 check_privsep_dir
53 start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
54 echo "done."
55 ;;
56 stop)
57 echo -n "Stopping OpenBSD Secure Shell server: sshd"
58 start-stop-daemon -K -x /usr/sbin/sshd
59 echo "."
60 ;;
61
62 reload|force-reload)
63 check_for_no_start
64 check_keys
65 check_config
66 echo -n "Reloading OpenBSD Secure Shell server's configuration"
67 start-stop-daemon -K -s 1 -x /usr/sbin/sshd
68 echo "."
69 ;;
70
71 restart)
72 check_keys
73 check_config
74 echo -n "Restarting OpenBSD Secure Shell server: sshd"
75 start-stop-daemon -K -x /usr/sbin/sshd
76 check_for_no_start
77 check_privsep_dir
78 sleep 2
79 start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
80 echo "."
81 ;;
82
83 *)
84 echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
85 exit 1
86esac
87
88exit 0