blob: 212254dc8bcb96fc8a25205080fc96847b14d110 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/sbin/sh
# Donated code that was put under PD license.
#
# Stripped PRNGd out of it for the time being.
AWK=/usr/bin/awk
CAT=/usr/bin/cat
KILL=/usr/bin/kill
PS=/usr/bin/ps
XARGS=/usr/bin/xargs
prefix=%%openSSHDir%%
etcdir=%%configDir%%
piddir=%%pidDir%%
SSHD=$prefix/sbin/sshd
PIDFILE=$piddir/sshd.pid
SSH_KEYGEN=$prefix/bin/ssh-keygen
HOST_KEY_RSA1=$etcdir/ssh_host_key
HOST_KEY_DSA=$etcdir/ssh_host_dsa_key
HOST_KEY_RSA=$etcdir/ssh_host_rsa_key
killproc() {
_procname=$1
_signal=$2
${PS} -u root | ${AWK} '/'"$_procname"'$/ {print $1}' | ${XARGS} ${KILL}
}
checkkeys() {
if [ ! -f $HOST_KEY_RSA1 ]; then
${SSH_KEYGEN} -t rsa1 -f ${HOST_KEY_RSA1} -N ""
fi
if [ ! -f $HOST_KEY_DSA ]; then
${SSH_KEYGEN} -t dsa -f ${HOST_KEY_DSA} -N ""
fi
if [ ! -f $HOST_KEY_RSA ]; then
${SSH_KEYGEN} -t rsa -f ${HOST_KEY_RSA} -N ""
fi
}
stop_service() {
if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
PID=`${CAT} ${PIDFILE}`
fi
if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
${KILL} ${PID}
else
echo "Unable to read PID file, killing using alternate method"
killproc sshd TERM
fi
}
start_service() {
# XXX We really should check if the service is already going, but
# XXX we will opt out at this time. - Bal
# Check to see if we have keys that need to be made
checkkeys
# Start SSHD
echo "starting $SSHD... \c" ; $SSHD
sshd_rc=$?
if [ $sshd_rc -ne 0 ]; then
echo "$0: Error ${sshd_rc} starting ${SSHD}... bailing."
exit $sshd_rc
fi
echo done.
}
case $1 in
'start')
start_service
;;
'stop')
stop_service
;;
'restart')
stop_service
start_service
;;
*)
echo "$0: usage: $0 {start|stop|restart}"
;;
esac
|