libunwind: update to 1.8.1
[openadk.git] / package / openssh / files / openssh.init
blobd9adb5f254e0d53a845f148021841466d64edb52
1 #!/bin/sh
2 #PKG openssh-server
3 #INIT 50
4 . /etc/rc.conf
6 case $1 in
7 autostop) ;;
8 autostart)
9 test x"${openssh:-NO}" = x"NO" && exit 0
10 grep "^dropbear" /etc/rc.conf >/dev/null 2>&1 || dropbear=NO
11 if [[ $openssh = AUTO && $dropbear != NO ]]; then
12 echo openssh not starting: set to AUTO and dropbear is enabled
13 exit 0
15 test x"$openssh" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start
16 exec sh $0 start
18 start)
19 if [[ ! -s /etc/ssh/ssh_host_rsa_key ]]; then
20 mkdir -p /etc/ssh
21 if [[ ! -x /usr/bin/ssh-keygen ]]; then
22 echo "openssh not starting: SSH private key missing"
23 exit 0
25 echo "openssh: generating SSH private key (RSA)"
26 /usr/bin/ssh-keygen -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key
27 rv=$?
28 echo openssh: key generation exited with code $rv
29 [[ $rv = 0 && -s /etc/ssh/ssh_host_rsa_key ]] || exit 1
31 mkdir -p /var/run/sshd
32 mkdir -p /var/empty
33 touch /var/log/btmp && chmod 600 /var/log/btmp
34 /usr/sbin/sshd
36 stop)
37 if [ -e /var/run/sshd.pid ]; then
38 kill $(cat /var/run/sshd.pid)
41 restart)
42 sh $0 stop
43 sh $0 start
46 echo "Usage: $0 {start | stop | restart}"
47 exit 1
49 esac
50 exit $?