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