CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
openssh: updated sshd script
[crossrootfs.git] / openssh / sshd
CommitLineData
fe2701c6
VM
1#!/bin/sh
2#
3# /etc/rc.d/sshd: start/stop ssh daemon
4#
5
2084faa4
VM
6SSD=/sbin/start-stop-daemon
7PROG=/usr/sbin/sshd
8PID=/var/run/sshd.pid
9KEYGEN=/usr/bin/ssh-keygen
10SSHDIR=/etc/ssh
11
12create_keys() {
13 if [ ! -f $SSHDIR/ssh_host_rsa_key ]; then
14 $KEYGEN -q -t rsa -b 2048 -N "" -f $SSHDIR/ssh_host_rsa_key
fe2701c6 15 fi
2084faa4
VM
16 if [ ! -f $SSHDIR/ssh_host_dsa_key ]; then
17 $KEYGEN -q -t dsa -N "" -f $SSHDIR/ssh_host_dsa_key
fe2701c6 18 fi
2084faa4
VM
19 if [ ! -f $SSHDIR/ssh_host_ecdsa_key ]; then
20 $KEYGEN -q -t ecdsa -b 521 -N "" -f $SSHDIR/ssh_host_ecdsa_key
fe2701c6 21 fi
2084faa4
VM
22 if [ ! -f $SSHDIR/ssh_host_ed25519_key ]; then
23 $KEYGEN -q -t ed25519 -N "" -f $SSHDIR/ssh_host_ed25519_key
fe2701c6 24 fi
2084faa4
VM
25}
26
27case $1 in
28start)
29 create_keys
30 $SSD --start --pidfile $PID --exec $PROG
fe2701c6
VM
31 ;;
32stop)
2084faa4 33 $SSD --stop --retry 10 --pidfile $PID
fe2701c6
VM
34 ;;
35restart)
36 $0 stop
fe2701c6
VM
37 $0 start
38 ;;
2084faa4
VM
39status)
40 $SSD --status --pidfile $PID
41 case $? in
42 0) echo "$PROG is running with pid $(cat $PID)" ;;
43 1) echo "$PROG is not running but the pid file $PID exists" ;;
44 3) echo "$PROG is not running" ;;
45 4) echo "Unable to determine the program status" ;;
46 esac
47 ;;
fe2701c6 48*)
2084faa4 49 echo "usage: $0 [start|stop|restart|status]"
fe2701c6
VM
50 ;;
51esac
52
53# End of file