]> andersk Git - gssapi-openssh.git/blobdiff - setup/SXXsshd.in
OPENSSH_GSI_GPT_4_7 release
[gssapi-openssh.git] / setup / SXXsshd.in
index b5a0a3d9bd4a5c58800666dbe47aaf447272e9df..03d6c07bb1c9de0df5f3a5e9c27ac8d230ee775e 100644 (file)
@@ -1,4 +1,19 @@
 #!/bin/sh
+#
+# Init file for GSI-OpenSSH server daemon
+#
+# chkconfig: 2345 55 25
+# description: GSI-OpenSSH server daemon
+#
+
+### BEGIN INIT INFO
+# Provides: sshd
+# Required-Start: $network
+# Required-Stop: $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Start the sshd daemon
+### END INIT INFO
 
 GLOBUS_LOCATION="@GLOBUS_LOCATION@"
 export GLOBUS_LOCATION
@@ -7,35 +22,82 @@ export GLOBUS_LOCATION
 . ${libexecdir}/globus-sh-tools.sh
 
 PID_FILE=${localstatedir}/sshd.pid
+SSHD=${sbindir}/sshd
+
+#
+# SSHD arguments can be added here within the following
+# set of double quotes.
+#
+
+SSHD_ARGS=""
+
+do_start()
+{
+    if [ ! -d $localstatedir ]; then
+        mkdir -p $localstatedir
+    fi
+    printf "%s" "Starting up GSI-OpenSSH sshd server... "
+    if [ ! -e $SSHD ]; then
+        echo "failed"
+        echo "$SSHD does not exist."
+        exit 1;
+    fi
+    if [ ! -x $SSHD ]; then
+        echo "failed"
+        echo "$SSHD is not executable."
+        exit 1;
+    fi
+    $SSHD $SSHD_ARGS > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+        echo "done."
+    else
+        echo "failed to start $SSHD!"
+    fi
+}
+
+do_stop()
+{
+    printf "%s" "Stopping the GSI-OpenSSH sshd server... "
+    pid=`cat $PID_FILE`
+    kill -TERM $pid
+    sleep 2
+    kill -TERM $pid 2> /dev/null
+    rm -f $PID_FILE
+    echo "done."
+}
 
 case "$1" in
     start)
         if [ ! -f $PID_FILE ]; then
-            if [ ! -d $localstatedir ]; then
-                mkdir -p $localstatedir
-            fi
-            echo "Starting up GSI-OpenSSH sshd server"
-            ${sbindir}/sshd > /dev/null 2>&1 &
-            if [ $? -ne 0 ] ; then
-                echo "Failed to start up GSI-OpenSSH sshd server"
-            fi
+            do_start
         else
-            echo "GSI-OpenSSH sshd is already running..."
+            pid=`cat $PID_FILE`
+            psout=`ps -A | grep $pid | grep -v grep | awk "{if (\\\$1 == $pid) print}"`
+            if [ "x$psout" = "x" ]; then
+                echo "Found stale sshd pid file... removing it."
+                rm -f $PID_FILE
+                do_start
+            else
+                echo "GSI-OpenSSH sshd server is already running!"
+            fi
         fi
         ;;
 
     stop)
         if [ -f $PID_FILE ] ; then
-            pid=`cat $PID_FILE`
-            kill -TERM $pid
-            sleep 2
-            kill -TERM $pid 2> /dev/null
-            rm -f $PID_FILE
+            do_stop
+        else
+            echo "The server's pid file does not exist!  Are you sure the server is running?"
         fi
         ;;
 
-  *)
-        echo "Usage: $0 ( start | stop )"
+    restart)
+        $0 stop
+        $0 start
+        ;;
+
+    *)
+        echo "Usage: $0 (start|stop|restart)"
         exit 1
 esac
 
This page took 0.034717 seconds and 4 git commands to generate.