summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/openssh/openssh/init
diff options
context:
space:
mode:
authorTudor Florea <tudor.florea@enea.com>2014-10-16 03:05:19 +0200
committerTudor Florea <tudor.florea@enea.com>2014-10-16 03:05:19 +0200
commitc527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch)
treebb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /meta/recipes-connectivity/openssh/openssh/init
downloadpoky-daisy-140929.tar.gz
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/recipes-connectivity/openssh/openssh/init')
-rw-r--r--meta/recipes-connectivity/openssh/openssh/init113
1 files changed, 113 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssh/openssh/init b/meta/recipes-connectivity/openssh/openssh/init
new file mode 100644
index 0000000000..37c8e7b907
--- /dev/null
+++ b/meta/recipes-connectivity/openssh/openssh/init
@@ -0,0 +1,113 @@
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
23HOST_KEY_ED25519=$SYSCONFDIR/ssh_host_ed25519_key
24
25check_for_no_start() {
26 # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
27 if [ -e $SYSCONFDIR/sshd_not_to_be_run ]; then
28 echo "OpenBSD Secure Shell server not in use ($SYSCONFDIR/sshd_not_to_be_run)"
29 exit 0
30 fi
31}
32
33check_privsep_dir() {
34 # Create the PrivSep empty dir if necessary
35 if [ ! -d /var/run/sshd ]; then
36 mkdir /var/run/sshd
37 chmod 0755 /var/run/sshd
38 fi
39}
40
41check_config() {
42 /usr/sbin/sshd -t || exit 1
43}
44
45check_keys() {
46 # create keys if necessary
47 if [ ! -f $HOST_KEY_RSA ]; then
48 echo " generating ssh RSA key..."
49 ssh-keygen -q -f $HOST_KEY_RSA -N '' -t rsa
50 fi
51 if [ ! -f $HOST_KEY_ECDSA ]; then
52 echo " generating ssh ECDSA key..."
53 ssh-keygen -q -f $HOST_KEY_ECDSA -N '' -t ecdsa
54 fi
55 if [ ! -f $HOST_KEY_DSA ]; then
56 echo " generating ssh DSA key..."
57 ssh-keygen -q -f $HOST_KEY_DSA -N '' -t dsa
58 fi
59 if [ ! -f $HOST_KEY_ED25519 ]; then
60 echo " generating ssh ED25519 key..."
61 ssh-keygen -q -f $HOST_KEY_ED25519 -N '' -t ed25519
62 fi
63}
64
65export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
66
67case "$1" in
68 start)
69 check_for_no_start
70 echo "Starting OpenBSD Secure Shell server: sshd"
71 check_keys
72 check_privsep_dir
73 start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
74 echo "done."
75 ;;
76 stop)
77 echo -n "Stopping OpenBSD Secure Shell server: sshd"
78 start-stop-daemon -K -x /usr/sbin/sshd
79 echo "."
80 ;;
81
82 reload|force-reload)
83 check_for_no_start
84 check_keys
85 check_config
86 echo -n "Reloading OpenBSD Secure Shell server's configuration"
87 start-stop-daemon -K -s 1 -x /usr/sbin/sshd
88 echo "."
89 ;;
90
91 restart)
92 check_keys
93 check_config
94 echo -n "Restarting OpenBSD Secure Shell server: sshd"
95 start-stop-daemon -K --oknodo -x /usr/sbin/sshd
96 check_for_no_start
97 check_privsep_dir
98 sleep 2
99 start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
100 echo "."
101 ;;
102
103 status)
104 status /usr/sbin/sshd
105 exit $?
106 ;;
107
108 *)
109 echo "Usage: /etc/init.d/ssh {start|stop|status|reload|force-reload|restart}"
110 exit 1
111esac
112
113exit 0