Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   conga/luci/init.d luci (http://www.linux-archive.org/cluster-development/47987-conga-luci-init-d-luci.html)

02-05-2008 05:31 PM

conga/luci/init.d luci
 
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe@sourceware.org 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
;;

02-05-2008 05:41 PM

conga/luci/init.d luci
 
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe@sourceware.org 2008-02-05 18:41:46

Modified files:
luci/init.d : luci

Log message:
pedantry

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

--- conga/luci/init.d/luci 2008/02/05 18:31:30 1.20
+++ conga/luci/init.d/luci 2008/02/05 18:41:46 1.21
@@ -73,12 +73,12 @@
old_umask=`umask`
umask 077

- rm -f "$HTTPS_PRIVKEY" "$HTTPS_PUBKEY"
+ rm -f -- "$HTTPS_PRIVKEY" "$HTTPS_PUBKEY"
/usr/bin/openssl genrsa -out "$HTTPS_PRIVKEY" "$KEY_BITS" >&/dev/null
/usr/bin/openssl req -new -x509 -key "$HTTPS_PRIVKEY" -out "$HTTPS_PUBKEY" -days "$KEY_LIFE_DAYS" -config /var/lib/luci/var/certs/cacert.config
- /bin/chmod 600 "$HTTPS_PRIVKEY"
- /bin/chmod 644 "$HTTPS_PUBKEY"
- /bin/chown $LUCI_USER:$LUCI_GROUP "$HTTPS_PRIVKEY" "$HTTPS_PUBKEY"
+ /bin/chmod -- 600 "$HTTPS_PRIVKEY"
+ /bin/chmod -- 644 "$HTTPS_PUBKEY"
+ /bin/chown -- $LUCI_USER:$LUCI_GROUP "$HTTPS_PRIVKEY" "$HTTPS_PUBKEY"
ret=$?

umask $old_umask
@@ -88,7 +88,7 @@

stop_luci()
{
- pid_num=`cat $PIDFILE 2>/dev/null`
+ pid_num=`cat -- $PIDFILE 2>/dev/null`
ret=$?
if [ $ret -eq 0 ]; then
kill $pid_num >& /dev/null
@@ -96,7 +96,7 @@
fi

if [ $ret -ne 0 ]; then
- pkill -u "$LUCI_USER" python >&/dev/null
+ pkill -u "$LUCI_USER" -- python >&/dev/null
ret=$?
fi
return $ret
@@ -104,7 +104,7 @@

stop_stunnel()
{
- pid_num=`cat $STUNNEL_PID 2>/dev/null`
+ pid_num=`cat -- $STUNNEL_PID 2>/dev/null`
ret=$?
if [ $ret -eq 0 ]; then
kill $pid_num >& /dev/null
@@ -112,7 +112,7 @@
fi

if [ $ret -ne 0 ]; then
- pkill -u "$LUCI_USER" stunnel >&/dev/null
+ pkill -u "$LUCI_USER" -- stunnel >&/dev/null
ret=$?
fi
return $ret
@@ -221,11 +221,11 @@
test -f "$PIDFILE"
LUCI_PID_EXISTS=$?
if [ "$LUCI_PID_EXISTS" -eq 0 ]; then
- pgrep -u "$LUCI_USER" python >&/dev/null
+ pgrep -u "$LUCI_USER" -- python >&/dev/null
if [ $? -ne 0 ]; then
LUCI_UP=0
# remove stale pidfile
- rm -f "$PIDFILE" >& /dev/null
+ rm -f -- "$PIDFILE" >& /dev/null
fi
else
LUCI_UP=0
@@ -237,14 +237,14 @@
stunnel_running()
{
ST_UP=2
- pgrep -u "$LUCI_USER" stunnel >&/dev/null
+ pgrep -u "$LUCI_USER" -- stunnel >&/dev/null
if [ $? -ne 0 ]; then
ST_UP=0
fi

if [ -f "$STUNNEL_PID" ] && [ $ST_UP -eq 0 ]; then
# stale pidfile
- rm -f "$STUNNEL_PID"
+ rm -f -- "$STUNNEL_PID"
fi
return $ST_UP
}
@@ -290,7 +290,7 @@
echo "The admin user password must be set before the luci can start"
echo "To set it, execute (as root): "
echo -e " luci_admin password
"
- /usr/bin/logger -t "$ID" "Luci startup failed: admin password not set (execute 'luci_admin password')"
+ /usr/bin/logger -t "$ID" -- "Luci startup failed: admin password not set (execute 'luci_admin password')"
exit 6
fi

@@ -306,15 +306,15 @@
exit 0
elif [ $ret -gt 2 ]; then
# one of the two processes was running and couldn't be stopped.
- /usr/bin/logger -t "$ID" "Luci startup failed: $errmsg"
+ /usr/bin/logger -t "$ID" -- "Luci startup failed: $errmsg"
exit 1
fi

system_running
if [ $? -eq 1 ]; then
echo_success
- cat "$PIDFILE" > "$GLOB_PIDFILE"
- touch "$GLOB_LOCKFILE"
+ 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"
echo; echo
@@ -365,12 +365,12 @@
if [ $rtrn -eq 1 ]; then
stop
if [ $? -eq 0 ]; then
- rm -f "$GLOB_PIDFILE"
- rm -f "$GLOB_LOCKFILE"
- /usr/bin/logger -t "$ID" "Luci shutdown succeeded"
+ rm -f -- "$GLOB_PIDFILE"
+ rm -f -- "$GLOB_LOCKFILE"
+ /usr/bin/logger -t "$ID" -- "Luci shutdown succeeded"
rtrn=0
else
- /usr/bin/logger -t "$ID" "Luci shutdown failed"
+ /usr/bin/logger -t "$ID" -- "Luci shutdown failed"
rtrn=1
fi
elif [ $rtrn -eq 0 ]; then

02-04-2010 10:36 PM

conga/luci/init.d luci
 
CVSROOT: /cvs/cluster
Module name: conga
Branch: RHEL5
Changes by: rmccabe@sourceware.org 2010-02-04 23:36:35

Modified files:
luci/init.d : luci

Log message:
conga: fix bz469881

Give luci more time to start up. This should fix problems with the luci init script when luci is running on a heavily loaded (or just very slow) machine.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/init.d/luci.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1 .11.2.5&r2=1.11.2.6

--- conga/luci/init.d/luci 2008/04/11 06:50:32 1.11.2.5
+++ conga/luci/init.d/luci 2010/02/04 23:36:34 1.11.2.6
@@ -138,7 +138,7 @@
fi

stop_luci
- max_wait=10
+ max_wait=25
cur_wait=0
while [ $cur_wait -lt $max_wait ]; do
sleep 1
@@ -150,7 +150,11 @@
done

if [ $? -ne 0 ]; then
- errmsg='Failed to stop luci'
+ if [ $cur_wait -eq $max_wait ]; then
+ errmsg="Luci did not stop after $max_wait seconds."
+ else
+ errmsg='Failed to stop luci'
+ fi
return 1
fi
return 0
@@ -170,7 +174,7 @@
sh $LUCID >&/dev/null &

cur_wait=0
- max_wait=10
+ max_wait=25
luci_running
ret=$?
while [ $ret -ne 1 ] && [ $cur_wait -lt $max_wait ]; do
@@ -181,7 +185,11 @@
done

if [ $ret -ne 1 ]; then
- errmsg='An error occurred while starting luci'
+ if [ $cur_wait -eq $max_wait ]; then
+ errmsg="Luci did not start after $max_wait seconds."
+ else
+ errmsg='An error occurred while starting luci'
+ fi
stop_luci
return 1
fi


All times are GMT. The time now is 09:50 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.