summaryrefslogtreecommitdiff
path: root/package/openssh/files/sshd.init
diff options
context:
space:
mode:
authorwbx <wbx@hydrogenium.(none)>2009-05-17 14:41:34 +0200
committerwbx <wbx@hydrogenium.(none)>2009-05-17 14:41:34 +0200
commit219a6dab8995aad9ac4860cc1a84d6f3509a03a4 (patch)
treeb9c0f3c43aebba2fcfef777592d0add39f2072f4 /package/openssh/files/sshd.init
Initial import
Diffstat (limited to 'package/openssh/files/sshd.init')
-rw-r--r--package/openssh/files/sshd.init47
1 files changed, 47 insertions, 0 deletions
diff --git a/package/openssh/files/sshd.init b/package/openssh/files/sshd.init
new file mode 100644
index 000000000..19774b891
--- /dev/null
+++ b/package/openssh/files/sshd.init
@@ -0,0 +1,47 @@
+#!/bin/sh
+#FWINIT 50
+. /etc/rc.conf
+
+case $1 in
+autostop) ;;
+autostart)
+ [[ $openssh = NO ]] && exit 0
+ grep dropbear_flags /etc/rc.conf >/dev/null 2>&1 || dropbear_flags=NO
+ if [[ $openssh = AUTO && $dropbear_flags != NO ]]; then
+ echo openssh not starting: set to AUTO and dropbear is enabled
+ exit 0
+ fi
+ exec sh $0 start
+ ;;
+start)
+ if [[ ! -s /etc/ssh/ssh_host_rsa_key ]]; then
+ mkdir -p /etc/ssh
+ if [[ ! -x /usr/bin/ssh-keygen ]]; then
+ bothlog openssh not starting: SSH private key missing
+ exit 0
+ fi
+ echo "openssh: generating SSH private key (RSA)"
+ /usr/bin/ssh-keygen -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key
+ rv=$?
+ echo openssh: key generation exited with code $rv
+ [[ $rv = 0 && -s /etc/ssh/ssh_host_rsa_key ]] || exit 1
+ fi
+ mkdir -p /var/run/sshd
+ mkdir -p /var/empty
+ /usr/sbin/sshd
+ ;;
+stop)
+ if [ -e /var/run/sshd.pid ]; then
+ kill $(cat /var/run/sshd.pid)
+ fi
+ ;;
+restart)
+ sh $0 stop
+ sh $0 start
+ ;;
+*)
+ echo "Usage: $0 {start | stop | restart}"
+ exit 1
+ ;;
+esac
+exit $?