]> andersk Git - gssapi-openssh.git/blob - setup/SXXsshd.in
2a01f221e39714e4ac315bbde695da9f1ef5f4b8
[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 GLOBUS_LOCATION="@GLOBUS_LOCATION@"
10 export GLOBUS_LOCATION
11
12 . ${GLOBUS_LOCATION}/libexec/globus-script-initializer
13 . ${libexecdir}/globus-sh-tools.sh
14
15 PID_FILE=${localstatedir}/sshd.pid
16
17 #
18 # SSHD arguments can be added here within the following
19 # set of double quotes.
20 #
21
22 SSHD_ARGS=""
23
24 do_start()
25 {
26     if [ ! -d $localstatedir ]; then
27         mkdir -p $localstatedir
28     fi
29     echo -n "Starting up GSI-OpenSSH sshd server... "
30     ${sbindir}/sshd $SSHD_ARGS > /dev/null 2>&1 &
31     if [ $? -eq 0 ]; then
32         echo "done."
33     else
34         echo "failed to start GSI-OpenSSH sshd server!"
35     fi
36 }
37
38 do_stop()
39 {
40     echo -n "Stopping the GSI-OpenSSH sshd server... "
41     pid=`cat $PID_FILE`
42     kill -TERM $pid
43     sleep 2
44     kill -TERM $pid 2> /dev/null
45     rm -f $PID_FILE
46     echo "done."
47 }
48
49 case "$1" in
50     start)
51         if [ ! -f $PID_FILE ]; then
52             do_start
53         else
54             pid=`cat $PID_FILE`
55             psout=`ps -A | grep $pid | grep -v grep | awk "{if (\\\$1 == $pid) print}"`
56             if [ "x$psout" = "x" ]; then
57                 echo "Found stale sshd pid file... removing it."
58                 rm -f $PID_FILE
59                 do_start
60             else
61                 echo "GSI-OpenSSH sshd server is already running!"
62             fi
63         fi
64         ;;
65
66     stop)
67         if [ -f $PID_FILE ] ; then
68             do_stop
69         else
70             echo "The server's pid file does not exist!  Are you sure the server is running?"
71         fi
72         ;;
73
74     restart)
75         $0 stop
76         $0 start
77         ;;
78
79     *)
80         echo "Usage: $0 (start|stop|restart)"
81         exit 1
82 esac
83
84 exit 0
This page took 0.381916 seconds and 3 git commands to generate.