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