]> andersk Git - gssapi-openssh.git/blobdiff - setup/SXXsshd.in
o Add new messages to print to the user in some odd cases involving the
[gssapi-openssh.git] / setup / SXXsshd.in
index 507e12d50636c21311b21e5919a471d8826e51f6..2a01f221e39714e4ac315bbde695da9f1ef5f4b8 100644 (file)
@@ -1,37 +1,84 @@
 #!/bin/sh
+#
+# Init file for GSI-OpenSSH server daemon
+#
+# chkconfig: 2345 55 25
+# description: GSI-OpenSSH server daemon
+#
 
-GLOBUS_LOCATION=@GLOBUS_LOCATION@
-
+GLOBUS_LOCATION="@GLOBUS_LOCATION@"
 export GLOBUS_LOCATION
 
 . ${GLOBUS_LOCATION}/libexec/globus-script-initializer
 . ${libexecdir}/globus-sh-tools.sh
-. ${sysconfdir}/grid-info.conf
 
 PID_FILE=${localstatedir}/sshd.pid
 
-case "$1" in
-  start)
-    echo "Starting up GSI-OpenSSH sshd server"
-    ${sbindir}/sshd &
-    if [ $? -ne 0 ] ; then
-      echo "Failed to start up GSI-OpenSSH sshd server"
+#
+# 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
-    ;;
-
-  stop)
-    if [ -f $PID_FILE ] ; then
-      kill -TERM `cat $PID_FILE`
-      sleep 2
-      kill -TERM `cat $PID_FILE` 2> /dev/null
-      rm -f $PID_FILE
+    echo -n "Starting up GSI-OpenSSH sshd server... "
+    ${sbindir}/sshd $SSHD_ARGS > /dev/null 2>&1 &
+    if [ $? -eq 0 ]; then
+        echo "done."
+    else
+        echo "failed to start GSI-OpenSSH sshd server!"
     fi
-    ;;
+}
+
+do_stop()
+{
+    echo -n "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."
+}
 
-  *)
-    echo "Usage: $0 ( start | stop )"
-    exit 1
+case "$1" in
+    start)
+        if [ ! -f $PID_FILE ]; then
+            do_start
+        else
+            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
+            do_stop
+        else
+            echo "The server's pid file does not exist!  Are you sure the server is running?"
+        fi
+        ;;
+
+    restart)
+        $0 stop
+        $0 start
+        ;;
+
+    *)
+        echo "Usage: $0 (start|stop|restart)"
+        exit 1
 esac
 
 exit 0
-
This page took 0.038111 seconds and 4 git commands to generate.