summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/openssh/openssh-6.4p1/init
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/openssh/openssh-6.4p1/init')
-rw-r--r--meta/recipes-connectivity/openssh/openssh-6.4p1/init108
1 files changed, 108 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssh/openssh-6.4p1/init b/meta/recipes-connectivity/openssh/openssh-6.4p1/init
new file mode 100644
index 0000000000..e7f3971324
--- /dev/null
+++ b/meta/recipes-connectivity/openssh/openssh-6.4p1/init
@@ -0,0 +1,108 @@
1#! /bin/sh
2set -e
3
4# source function library
5. /etc/init.d/functions
6
7# /etc/init.d/ssh: start and stop the OpenBSD "secure shell" daemon
8
9test -x /usr/sbin/sshd || exit 0
10( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0
11
12# /etc/default/ssh may set SYSCONFDIR and SSHD_OPTS
13if test -f /etc/default/ssh; then
14 . /etc/default/ssh
15fi
16
17[ -z "$SYSCONFDIR" ] && SYSCONFDIR=/etc/ssh
18mkdir -p $SYSCONFDIR
19
20HOST_KEY_RSA=$SYSCONFDIR/ssh_host_rsa_key
21HOST_KEY_DSA=$SYSCONFDIR/ssh_host_dsa_key
22HOST_KEY_ECDSA=$SYSCONFDIR/ssh_host_ecdsa_key
23
24check_for_no_start() {
25 # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
26 if [ -e $SYSCONFDIR/sshd_not_to_be_run ]; then
27 echo "OpenBSD Secure Shell server not in use ($SYSCONFDIR/sshd_not_to_be_run)"
28 exit 0
29 fi
30}
31
32check_privsep_dir() {
33 # Create the PrivSep empty dir if necessary
34 if [ ! -d /var/run/sshd ]; then
35 mkdir /var/run/sshd
36 chmod 0755 /var/run/sshd
37 fi
38}
39
40check_config() {
41 /usr/sbin/sshd -t || exit 1
42}
43
44check_keys() {
45 # create keys if necessary
46 if [ ! -f $HOST_KEY_RSA ]; then
47 echo " generating ssh RSA key..."
48 ssh-keygen -q -f $HOST_KEY_RSA -N '' -t rsa
49 fi
50 if [ ! -f $HOST_KEY_ECDSA ]; then
51 echo " generating ssh ECDSA key..."
52 ssh-keygen -q -f $HOST_KEY_ECDSA -N '' -t ecdsa
53 fi
54 if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
55 echo " generating ssh DSA key..."
56 ssh-keygen -q -f $HOST_KEY_DSA -N '' -t dsa
57 fi
58}
59
60export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
61
62case "$1" in
63 start)
64 check_for_no_start
65 echo "Starting OpenBSD Secure Shell server: sshd"
66 check_keys
67 check_privsep_dir
68 start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
69 echo "done."
70 ;;
71 stop)
72 echo -n "Stopping OpenBSD Secure Shell server: sshd"
73 start-stop-daemon -K -x /usr/sbin/sshd
74 echo "."
75 ;;
76
77 reload|force-reload)
78 check_for_no_start
79 check_keys
80 check_config
81 echo -n "Reloading OpenBSD Secure Shell server's configuration"
82 start-stop-daemon -K -s 1 -x /usr/sbin/sshd
83 echo "."
84 ;;
85
86 restart)
87 check_keys
88 check_config
89 echo -n "Restarting OpenBSD Secure Shell server: sshd"
90 start-stop-daemon -K --oknodo -x /usr/sbin/sshd
91 check_for_no_start
92 check_privsep_dir
93 sleep 2
94 start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
95 echo "."
96 ;;
97
98 status)
99 status /usr/sbin/sshd
100 exit $?
101 ;;
102
103 *)
104 echo "Usage: /etc/init.d/ssh {start|stop|status|reload|force-reload|restart}"
105 exit 1
106esac
107
108exit 0