]> andersk Git - gssapi-openssh.git/blob - setup/SXXsshd.in
The man2html from jbasney on pkilab2 works whereas the standard one doesn't.
[gssapi-openssh.git] / setup / SXXsshd.in
1 #!/bin/sh
2 #
3 # Init file for GSI-OpenSSH server daemon
4 #
5 # chkconfig: 2345 55 25
6 # description: GSI-OpenSSH server daemon
7 #
8
9 ### BEGIN INIT INFO
10 # Provides: sshd
11 # Required-Start: $network
12 # Required-Stop: $network
13 # Default-Start: 2 3 4 5
14 # Default-Stop: 0 1 6
15 # Description: Start the sshd daemon
16 ### END INIT INFO
17
18 GLOBUS_LOCATION="@GLOBUS_LOCATION@"
19 export GLOBUS_LOCATION
20
21 . ${GLOBUS_LOCATION}/libexec/globus-script-initializer
22 . ${libexecdir}/globus-sh-tools.sh
23
24 PID_FILE=${localstatedir}/sshd.pid
25 SSHD=${sbindir}/sshd
26
27 #
28 # SSHD arguments can be added here within the following
29 # set of double quotes.
30 #
31
32 SSHD_ARGS=""
33
34 do_start()
35 {
36     if [ ! -d $localstatedir ]; then
37         mkdir -p $localstatedir
38     fi
39     printf "%s" "Starting up GSI-OpenSSH sshd server... "
40     if [ ! -e $SSHD ]; then
41         echo "failed"
42         echo "$SSHD does not exist."
43         exit 1;
44     fi
45     if [ ! -x $SSHD ]; then
46         echo "failed"
47         echo "$SSHD is not executable."
48         exit 1;
49     fi
50     $SSHD $SSHD_ARGS > /dev/null 2>&1
51     if [ $? -eq 0 ]; then
52         echo "done."
53     else
54         echo "failed to start $SSHD!"
55     fi
56 }
57
58 do_stop()
59 {
60     printf "%s" "Stopping the GSI-OpenSSH sshd server... "
61     pid=`cat $PID_FILE`
62     kill -TERM $pid
63     sleep 2
64     kill -TERM $pid 2> /dev/null
65     rm -f $PID_FILE
66     echo "done."
67 }
68
69 case "$1" in
70     start)
71         if [ ! -f $PID_FILE ]; then
72             do_start
73         else
74             pid=`cat $PID_FILE`
75             psout=`ps -A | grep $pid | grep -v grep | awk "{if (\\\$1 == $pid) print}"`
76             if [ "x$psout" = "x" ]; then
77                 echo "Found stale sshd pid file... removing it."
78                 rm -f $PID_FILE
79                 do_start
80             else
81                 echo "GSI-OpenSSH sshd server is already running!"
82             fi
83         fi
84         ;;
85
86     stop)
87         if [ -f $PID_FILE ] ; then
88             do_stop
89         else
90             echo "The server's pid file does not exist!  Are you sure the server is running?"
91         fi
92         ;;
93
94     restart)
95         $0 stop
96         $0 start
97         ;;
98
99     *)
100         echo "Usage: $0 (start|stop|restart)"
101         exit 1
102 esac
103
104 exit 0
This page took 0.122152 seconds and 5 git commands to generate.