updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / openssh-lpk / sshd
blob2ee1091f062022f314262bfabfb966094249d561
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5 . /etc/conf.d/sshd
7 PIDFILE=/var/run/sshd.pid
8 PID=$(cat $PIDFILE 2>/dev/null)
9 if ! readlink -q /proc/$PID/exe | grep -q '^/usr/sbin/sshd'; then
10 PID=
11 rm $PIDFILE 2>/dev/null
14 case "$1" in
15 start)
16 stat_busy "Starting Secure Shell Daemon"
17 [ -f /etc/ssh/ssh_host_key ] || { /usr/bin/ssh-keygen -t rsa1 -N "" -f /etc/ssh/ssh_host_key >/dev/null; }
18 [ -f /etc/ssh/ssh_host_rsa_key ] || { /usr/bin/ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key >/dev/null; }
19 [ -f /etc/ssh/ssh_host_dsa_key ] || { /usr/bin/ssh-keygen -t dsa -N "" -f /etc/ssh/ssh_host_dsa_key >/dev/null; }
20 [ -f /etc/ssh/ssh_host_ecdsa_key ] || { /usr/bin/ssh-keygen -t ecdsa -N "" -f /etc/ssh/ssh_host_ecdsa_key >/dev/null; }
21 [ -d /var/empty ] || mkdir -p /var/empty
22 [ -z "$PID" ] && /usr/sbin/sshd $SSHD_ARGS
23 if [ $? -gt 0 ]; then
24 stat_fail
25 else
26 add_daemon sshd
27 stat_done
30 stop)
31 stat_busy "Stopping Secure Shell Daemon"
32 [ ! -z "$PID" ] && kill $PID &> /dev/null
33 if [ $? -gt 0 ]; then
34 stat_fail
35 else
36 rm_daemon sshd
37 stat_done
40 restart)
41 $0 stop
42 sleep 1
43 $0 start
46 echo "usage: $0 {start|stop|restart}"
47 esac
48 exit 0