CVSROOT:        /cvs/cluster
Module name:    conga
Changes by:     [EMAIL PROTECTED]       2008-02-05 18:31:31

Modified files:
        luci/init.d    : luci 

Log message:
        - stop-after-stop should return success
        - cleanup

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/init.d/luci.diff?cvsroot=cluster&r1=1.19&r2=1.20

--- conga/luci/init.d/luci      2008/01/02 20:52:23     1.19
+++ conga/luci/init.d/luci      2008/02/05 18:31:30     1.20
@@ -121,11 +121,34 @@
 stop()
 {
        stop_stunnel
+       max_wait=5
+       cur_wait=0
+       while [ $cur_wait -lt $max_wait ]; do
+               sleep 1
+               cur_wait=`expr $cur_wait + 1`
+               stunnel_running
+               if [ $? -eq 0 ]; then
+                       break
+               fi
+       done
+
        if [ $? -ne 0 ]; then
                errmsg='Failed to stop stunnel'
                return 1
        fi
+
        stop_luci
+       max_wait=10
+       cur_wait=0
+       while [ $cur_wait -lt $max_wait ]; do
+               sleep 1
+               cur_wait=`expr $cur_wait + 1`
+               luci_running
+               if [ $? -eq 0 ]; then
+                       break
+               fi
+       done
+
        if [ $? -ne 0 ]; then
                errmsg='Failed to stop luci'
                return 1
@@ -145,29 +168,69 @@
        fi
 
        sh $LUCID >&/dev/null &
-       sleep 4
+
+       cur_wait=0
+       max_wait=10
+       luci_running
+       ret=$?
+       while [ $ret -ne 1 ] && [ $cur_wait -lt $max_wait ]; do
+               sleep 1
+               cur_wait=`expr $cur_wait + 1`
+               luci_running
+               ret=$?
+       done
+
+       if [ $ret -ne 1 ]; then
+               errmsg='An error occurred while starting luci'
+               stop_luci
+               return 1
+       fi
 
        sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, 
$STUNNEL_CONF | $STUNNEL_D -fd 0
        if [ $? -ne 0 ]; then
                errmsg='An error occurred while starting stunnel'
-               stop_luci
+               stop_luci >& /dev/null
+               return 1
+       fi
+
+       max_wait=5
+       cur_wait=0
+       stunnel_running
+       ret=$?
+       while [ $ret -ne 2 ] && [ $cur_wait -lt $max_wait ]; do
+               sleep 1
+               cur_wait=`expr $cur_wait + 1`
+               stunnel_running
+               ret=$?
+       done
+
+       if [ $ret -ne 2 ]; then
+               errmsg='An error occurred while starting stunnel'
+               stop_luci >& /dev/null
+               stop_stunnel >& /dev/null 
                return 1
        fi
+
        return 0
 }
 
 luci_running()
 {
        LUCI_UP=1
-       pgrep -u "$LUCI_USER" python >&/dev/null
-       if [ $? -ne 0 ]; then
+
+       test -f "$PIDFILE"
+       LUCI_PID_EXISTS=$?
+       if [ "$LUCI_PID_EXISTS" -eq 0 ]; then
+               pgrep -u "$LUCI_USER" python >&/dev/null
+               if [ $? -ne 0 ]; then
+                       LUCI_UP=0
+                       # remove stale pidfile
+                       rm -f "$PIDFILE" >& /dev/null
+               fi
+       else
                LUCI_UP=0
        fi
 
-       if [ -f "$PIDFILE" ] && [ $LUCI_UP -eq 0 ]; then
-               # stale pidfile
-               rm -f "$PIDFILE" >& /dev/null
-       fi
        return $LUCI_UP
 }
 
@@ -252,15 +315,15 @@
                        echo_success
                        cat "$PIDFILE" > "$GLOB_PIDFILE"
                        touch "$GLOB_LOCKFILE"
-                       /usr/bin/logger -t "$ID" "Luci startup succeeded"
-                       /usr/bin/logger -t "$ID" "Listening on port 
$LUCI_HTTPS_PORT; accessible via URL $LUCI_URL"
+                       /usr/bin/logger -t "$ID" -- "Luci startup succeeded"
+                       /usr/bin/logger -t "$ID" -- "Listening on port 
$LUCI_HTTPS_PORT; accessible via URL $LUCI_URL"
                        echo; echo
                        echo "Point your web browser to $LUCI_URL to access 
luci"
                        echo
                        exit 0
                else
                        echo_failure
-                       /usr/bin/logger -t "$ID" "Luci startup failed $errmsg"
+                       /usr/bin/logger -t "$ID" -- "Luci startup failed 
$errmsg"
                        echo
                        exit 1
                fi
@@ -269,7 +332,7 @@
        restart)
                $0 stop
                rtrn=$?
-               if [ $rtrn -eq 0 ] || [ $rtrn -eq 7 ]; then
+               if [ $rtrn -eq 0 ];  then
                        $0 start
                        rtrn=$?
                fi
@@ -311,7 +374,7 @@
                                rtrn=1
                        fi
                elif [ $rtrn -eq 0 ]; then
-                       rtrn=7
+                       rtrn=0
                else
                        rtrn=1
                fi
@@ -324,6 +387,10 @@
                echo
        ;;
 
+       try-restart)
+               rtrn=3
+       ;;
+
        reload)
                rtrn=3
        ;;

Reply via email to