diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-10-12 20:30:52 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-10-12 20:30:52 +0000 |
commit | 8b5ba1c39acd9bdf64c55a1407021111969a4289 (patch) | |
tree | 70d01b6f6b8000a3310692331957840684a8ac29 /contrib/solaris/opensshd.in | |
parent | 4a820ea750ce79be709ca8c4b11edf39e07b2676 (diff) |
- (bal) First wave of contrib/solaris/ package upgrades. Still more
work needs to be done, but it is a 190% better then the stuff we
had before!
Diffstat (limited to 'contrib/solaris/opensshd.in')
-rwxr-xr-x | contrib/solaris/opensshd.in | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/contrib/solaris/opensshd.in b/contrib/solaris/opensshd.in new file mode 100755 index 000000000..057459b17 --- /dev/null +++ b/contrib/solaris/opensshd.in | |||
@@ -0,0 +1,88 @@ | |||
1 | #!/sbin/sh | ||
2 | # Donated code that was put under PD license. | ||
3 | # | ||
4 | # Stripped PRNGd out of it for the time being. | ||
5 | |||
6 | AWK=/usr/bin/awk | ||
7 | CAT=/usr/bin/cat | ||
8 | EGREP=/usr/bin/egrep | ||
9 | KILL=/usr/bin/kill | ||
10 | PS=/usr/bin/ps | ||
11 | |||
12 | PREFIX=%%openSSHDir%% | ||
13 | ETCDIR=%%configDir%% | ||
14 | |||
15 | SSHD=$PREFIX/sbin/sshd | ||
16 | SSH_KEYGEN=$PREFIX/bin/ssh-keygen | ||
17 | HOST_KEY_RSA1=$ETCDIR/ssh_host_key | ||
18 | HOST_KEY_DSA=$ETCDIR/ssh_host_dsa_key | ||
19 | HOST_KEY_RSA=$ETCDIR/ssh_host_rsa_key | ||
20 | |||
21 | killproc() { | ||
22 | _procname=$1 | ||
23 | _signal=$2 | ||
24 | ${PGREP} ${_procname} | ${HEAD} -1 | ${XARGS} -t -I {} ${KILL} -${_signal} {} | ||
25 | } | ||
26 | |||
27 | |||
28 | checkkeys() { | ||
29 | if [ ! -f $HOST_KEY_RSA1 ]; then | ||
30 | $SSH_KEYGEN -t rsa1 -f $HOST_KEY_RSA1 -N "" | ||
31 | fi | ||
32 | if [ ! -f $HOST_KEY_DSA ]; then | ||
33 | $SSH_KEYGEN -t dsa -f $HOST_KEY_DSA -N "" | ||
34 | fi | ||
35 | if [ ! -f $HOST_KEY_RSA ]; then | ||
36 | $SSH_KEYGEN -t rsa -f $HOST_KEY_RSA -N "" | ||
37 | fi | ||
38 | } | ||
39 | |||
40 | stop_service() { | ||
41 | if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then | ||
42 | PID=`cat ${PIDFILE}` | ||
43 | fi | ||
44 | if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then | ||
45 | $KILL $PID | ||
46 | else | ||
47 | echo "Unable to read PID file, killing using alternate method" | ||
48 | killproc sshd TERM | ||
49 | fi | ||
50 | } | ||
51 | |||
52 | start_service() { | ||
53 | # XXX We really should check if the service is already going, but | ||
54 | # XXX we will opt out at this time. - Bal | ||
55 | |||
56 | # Check to see if we have keys that need to be made | ||
57 | checkkeys | ||
58 | |||
59 | # Start SSHD | ||
60 | echo "starting $SSHD... \c" ; $SSHD | ||
61 | |||
62 | sshd_rc=$? | ||
63 | if [ $sshd_rc -ne 0 ]; then | ||
64 | echo "$0: Error ${sshd_rc} starting ${SSHD}... bailing." | ||
65 | exit $sshd_rc | ||
66 | fi | ||
67 | echo done. | ||
68 | } | ||
69 | |||
70 | case $1 in | ||
71 | |||
72 | 'start') | ||
73 | start_service | ||
74 | ;; | ||
75 | |||
76 | 'stop') | ||
77 | stop_service | ||
78 | ;; | ||
79 | |||
80 | 'restart') | ||
81 | stop_service | ||
82 | start_service | ||
83 | ;; | ||
84 | |||
85 | *) | ||
86 | echo "$0: usage: $0 {start|stop|restart}" | ||
87 | ;; | ||
88 | esac | ||