X-Git-Url: http://andersk.mit.edu/gitweb/gssapi-openssh.git/blobdiff_plain/d16626dfef0b082972e4e24084aa5553504bdb63..fd888c28f80f176fd69e3d6e75f23ee2337320fd:/setup/SXXsshd.in diff --git a/setup/SXXsshd.in b/setup/SXXsshd.in index 74e5a6f..03d6c07 100644 --- a/setup/SXXsshd.in +++ b/setup/SXXsshd.in @@ -6,6 +6,15 @@ # 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 @@ -13,6 +22,7 @@ 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 @@ -26,21 +36,34 @@ do_start() if [ ! -d $localstatedir ]; then mkdir -p $localstatedir fi - echo "Starting up GSI-OpenSSH sshd server..." - ${sbindir}/sshd $SSHD_ARGS > /dev/null 2>&1 & - if [ $? -ne 0 ] ; then - echo "Failed to start up GSI-OpenSSH sshd server!" + 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() { - echo "Stopping the GSI-OpenSSH sshd server..." + 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 @@ -51,11 +74,11 @@ case "$1" in 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." + echo "Found stale sshd pid file... removing it." rm -f $PID_FILE do_start else - echo "GSI-OpenSSH sshd is already running!" + echo "GSI-OpenSSH sshd server is already running!" fi fi ;; @@ -63,6 +86,8 @@ case "$1" in 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 ;;