cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/luci/init.d luci
@ 2006-07-17 20:56 kupcevic
  0 siblings, 0 replies; 11+ messages in thread
From: kupcevic @ 2006-07-17 20:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-07-17 20:56:46

Modified files:
	luci/init.d    : luci 

Log message:
	luci: leave some time for stunnel to start

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

--- conga/luci/init.d/luci	2006/07/05 19:20:15	1.5
+++ conga/luci/init.d/luci	2006/07/17 20:56:46	1.6
@@ -81,9 +81,8 @@
     if [ "1$?" != "10" ] ; then
 	generate_https_certs
     fi
-    sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF \
-	| $STUNNEL_D -fd 0
-    
+    sleep 4
+    sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF | $STUNNEL_D -fd 0
     sleep 4
 }
 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2006-09-26  0:22 kupcevic
  0 siblings, 0 replies; 11+ messages in thread
From: kupcevic @ 2006-09-26  0:22 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-09-26 00:22:27

Modified files:
	luci/init.d    : luci 

Log message:
	luci: if `service luci start` succeeds, print url to connect to luci, so user doesn't have to look thru manuals just to connect to it

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

--- conga/luci/init.d/luci	2006/08/23 19:58:42	1.8
+++ conga/luci/init.d/luci	2006/09/26 00:22:27	1.9
@@ -171,11 +171,13 @@
 		    cat $PIDFILE > $GLOB_PIDFILE
 		    touch $GLOB_LOCKFILE
 		    /usr/bin/logger -t $ID "startup succeeded"
+		    echo
+		    echo "Please, point your web browser to https://$HOSTNAME:$LUCI_HTTPS_PORT to access luci"
 		else
 		    echo_failure
 		    /usr/bin/logger -t $ID "startup failed"
+		    echo
 		fi
-		echo 
 		;;
 
         restart)



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2006-10-03 18:23 kupcevic
  0 siblings, 0 replies; 11+ messages in thread
From: kupcevic @ 2006-10-03 18:23 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-03 18:23:30

Modified files:
	luci/init.d    : luci 

Log message:
	luci: init script: besides printing out url to access luci, log it into log files as well

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

--- conga/luci/init.d/luci	2006/09/26 00:22:27	1.9
+++ conga/luci/init.d/luci	2006/10/03 18:23:30	1.10
@@ -17,6 +17,9 @@
 # Grab the network config file
 . /etc/sysconfig/network
 
+# grab luci defaults
+. /etc/sysconfig/luci
+
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export PATH
 
@@ -29,15 +32,14 @@
 LUCI_USER="luci"
 LUCI_GROUP="luci"
 
+LUCI_URL="https://$HOSTNAME:$LUCI_HTTPS_PORT"
+
 HTTPS_PUBKEY="/var/lib/luci/var/certs/https.pem"
 HTTPS_PRIVKEY="/var/lib/luci/var/certs/https.key.pem"
 STUNNEL_D="/usr/sbin/stunnel"
 STUNNEL_PID="/var/lib/luci/var/stunnel/pid"
 STUNNEL_CONF="/var/lib/luci/etc/stunnel.conf"
 
-# grab luci defaults
-. /etc/sysconfig/luci
-
 #
 # Only root wants to run this...
 #
@@ -171,8 +173,10 @@
 		    cat $PIDFILE > $GLOB_PIDFILE
 		    touch $GLOB_LOCKFILE
 		    /usr/bin/logger -t $ID "startup succeeded"
+		    /usr/bin/logger -t $ID "Listening on port $LUCI_HTTPS_PORT; accessible using url $LUCI_URL"
+		    echo; echo
+		    echo "Please, point your web browser to $LUCI_URL to access luci"
 		    echo
-		    echo "Please, point your web browser to https://$HOSTNAME:$LUCI_HTTPS_PORT to access luci"
 		else
 		    echo_failure
 		    /usr/bin/logger -t $ID "startup failed"



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2006-11-02  0:23 kupcevic
  0 siblings, 0 replies; 11+ messages in thread
From: kupcevic @ 2006-11-02  0:23 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-11-02 00:23:28

Modified files:
	luci/init.d    : luci 

Log message:
	luci init: display URL to access luci at status report

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

--- conga/luci/init.d/luci	2006/10/05 15:01:39	1.11
+++ conga/luci/init.d/luci	2006/11/02 00:23:28	1.12
@@ -203,7 +203,8 @@
 	        system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-		    echo "$ID is running..."
+		    echo "$ID is running..." 
+		    echo "$ID listens on port $LUCI_HTTPS_PORT; accessible using url $LUCI_URL" 
 		else
 		    echo "$ID is stopped"
 		fi



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2007-02-20 17:56 rmccabe
  0 siblings, 0 replies; 11+ messages in thread
From: rmccabe @ 2007-02-20 17:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-02-20 17:56:54

Modified files:
	luci/init.d    : luci 

Log message:
	bz 227852

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

--- conga/luci/init.d/luci	2007/01/18 03:02:38	1.14
+++ conga/luci/init.d/luci	2007/02/20 17:56:54	1.15
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2005 Red Hat, Inc.
+# Copyright (C) 2005-2007 Red Hat, Inc.
 #
 # This program is Free Software.  You may modify and/or redistribute it under
 # the terms of the GNU General Public License version 2, or (at your option)
@@ -53,185 +53,186 @@
 
 https_certs_ok()
 {
-    if [ ! -e $HTTPS_PRIVKEY ] ; then
-	return 1
-    fi
-    if [ ! -e $HTTPS_PUBKEY ] ; then
-	return 2
-    fi
-    return 0
+	if [ ! -e $HTTPS_PRIVKEY ] ; then
+		return 1
+	fi
+	if [ ! -e $HTTPS_PUBKEY ] ; then
+		return 2
+	fi
+	return 0
 }
 
 generate_https_certs()
 {
-    rm -f $HTTPS_PRIVKEY $HTTPS_PUBKEY
-    echo -n "generating https SSL certificates...  "
-    /usr/bin/openssl genrsa -out $HTTPS_PRIVKEY 2048 > /dev/null 2>&1
-    /usr/bin/openssl req -new -x509 -key $HTTPS_PRIVKEY -out $HTTPS_PUBKEY -days 1825 -config /var/lib/luci/var/certs/cacert.config
-    /bin/chown $LUCI_USER:$LUCI_GROUP $HTTPS_PRIVKEY $HTTPS_PUBKEY
-    /bin/chmod 600 $HTTPS_PRIVKEY
-    /bin/chmod 644 $HTTPS_PUBKEY
-    echo "done"
-    return $?
+	rm -f $HTTPS_PRIVKEY $HTTPS_PUBKEY
+	echo -n "generating https SSL certificates...  "
+	/usr/bin/openssl genrsa -out $HTTPS_PRIVKEY 2048 > /dev/null 2>&1
+	/usr/bin/openssl req -new -x509 -key $HTTPS_PRIVKEY -out $HTTPS_PUBKEY -days 1825 -config /var/lib/luci/var/certs/cacert.config
+	/bin/chown $LUCI_USER:$LUCI_GROUP $HTTPS_PRIVKEY $HTTPS_PUBKEY
+	/bin/chmod 600 $HTTPS_PRIVKEY
+	/bin/chmod 644 $HTTPS_PUBKEY
+	ret=$?
+	echo "done"
+	return $ret
 }
 
 start()
 {
-    $LUCID >/dev/null 2>/dev/null &
-    
-    https_certs_ok
-    if [ "1$?" != "10" ] ; then
-	generate_https_certs
-    fi
-    sleep 4
-    sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF | $STUNNEL_D -fd 0
-    sleep 4
+	$LUCID >/dev/null 2>/dev/null &
+	
+	https_certs_ok
+	if [ "1$?" != "10" ] ; then
+		generate_https_certs
+	fi
+	sleep 4
+	sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF | $STUNNEL_D -fd 0
+	sleep 4
 }
 
 stop_luci()
 {
-    pid_num=`cat $PIDFILE`
-    kill $pid_num
-    sleep 2
+	pid_num=`cat $PIDFILE`
+	kill $pid_num
+	sleep 2
 }
 
 stop_stunnel()
 {
-    pid_num=`cat $STUNNEL_PID`
-    kill $pid_num
-    sleep 2
+	pid_num=`cat $STUNNEL_PID`
+	kill $pid_num
+	sleep 2
 }
 
 stop()
 {
-    stop_luci
-    stop_stunnel
+	stop_luci
+	stop_stunnel
 }
 
 system_running()
 {
-    # luci
-    LUCI_UP=1
-    if [ -e $PIDFILE ] ; then
-	pid_num=`cat $PIDFILE`
-	res=`ps -Af | grep python | grep $LUCI_USER | grep $pid_num`
-	if [ "1$res" != "1" ] ; then
-	    LUCI_UP=0
-	fi
-    fi
-    
-    # stunnel
-    ST_UP=2
-    if [ -e $STUNNEL_PID ] ; then
-	pid_num=`cat $STUNNEL_PID`
-	res=`ps -Af | grep stunnel | grep $LUCI_USER | grep $pid_num`
-	if [ "1$res" != "1" ] ; then
-	    ST_UP=0
-	fi
-    fi
-    
-    # resolve
-    let res=$LUCI_UP+$ST_UP
-    if [ "1$res" = "10" ] ; then
+	# luci
+	LUCI_UP=1
+	if [ -e $PIDFILE ] ; then
+		pid_num=`cat $PIDFILE`
+		kill -0 $pid_num 2>/dev/null
+		if [ "1$?" != "10" ] ; then
+			LUCI_UP=0
+		fi
+	else
+		LUCI_UP=0
+	fi
+	
+	# stunnel
+	ST_UP=2
+	if [ -e $STUNNEL_PID ] ; then
+		pid_num=`cat $STUNNEL_PID`
+		kill -0 $pid_num 2>/dev/null
+		if [ "1$?" != "10" ] ; then
+			ST_UP=0
+		fi
+	else
+		ST_UP=0
+	fi
+	
+	# resolve
+	let res=$LUCI_UP+$ST_UP
+	if [ "1$res" = "10" ] ; then
+		# neither luci nor stunnel is running
+		return 1
+	fi
+	if [ "1$res" = "11" ] ; then
+		# only stunnel running -> stop it
+		stop_stunnel
+	fi
+	if [ "1$res" = "12" ] ; then
+		# only luci running -> stop it
+		stop_luci
+	fi
 	return 0
-    fi
-    if [ "1$res" = "11" ] ; then
-	# only stunnel running -> stop it
-	stop_stunnel
-    fi
-    if [ "1$res" = "12" ] ; then
-	# only luci running -> stop it
-	stop_luci
-    fi
-    return 1
 }
 
 
-
 case $1 in
 	start)
-	        if ! /bin/grep True /var/lib/luci/.default_password_has_been_reset 2>&1 >/dev/null; then
-		    echo ""
-		    echo "luci's 'admin' password has to be changed before server is allowed to start"
-		    echo "To do so, execute (as root): " 
-		    echo -e "\tluci_admin password"
-		    echo ""
-		    /usr/bin/logger -t $ID "startup failed (password not reset): execute 'luci_admin password'"
-		    exit 1
+		if ! /bin/grep True /var/lib/luci/.default_password_has_been_reset 2>&1 >/dev/null; then
+			echo -e "\nluci's 'admin' password has to be set before the luci server is allowed to start"
+			echo "To do so, execute (as root): " 
+			echo -e "\tluci_admin password\n"
+			/usr/bin/logger -t $ID "startup failed (password not set): execute 'luci_admin password'"
+			exit 1
 		fi
 		
 		echo -n "Starting $ID: "
 		system_running
 		rtrn=$?
 		if [ "1$rtrn" != "10" ] ; then
-		    start
+			start
 		fi
 		system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-		    echo_success
-		    cat $PIDFILE > $GLOB_PIDFILE
-		    touch $GLOB_LOCKFILE
-		    /usr/bin/logger -t $ID "startup succeeded"
-		    /usr/bin/logger -t $ID "Listening on port $LUCI_HTTPS_PORT; accessible using url $LUCI_URL"
-		    echo; echo
-		    echo "Please, point your web browser to $LUCI_URL to access luci"
-		    echo
+			echo_success
+			cat $PIDFILE > $GLOB_PIDFILE
+			touch $GLOB_LOCKFILE
+			/usr/bin/logger -t $ID "startup succeeded"
+			/usr/bin/logger -t $ID "Listening on port $LUCI_HTTPS_PORT; accessible using url $LUCI_URL"
+			echo -e "\n\nPlease, point your web browser to $LUCI_URL to access luci\n"
 		else
-		    echo_failure
-		    /usr/bin/logger -t $ID "startup failed"
-		    echo
+			echo_failure
+			/usr/bin/logger -t $ID "startup failed"
+			echo
 		fi
-		;;
+	;;
 
-        restart)
+	restart)
 		$0 stop
 		$0 start 
 		rtrn=$?
-		;;
-        
-        condrestart)
-	        system_running
+	;;
+		
+	condrestart)
+		system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-		    $0 restart
-		    rtrn=$?
+			$0 restart
+			rtrn=$?
 		fi
-		;;
+	;;
 
 	status)
-	        system_running
+			system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-		    echo "$ID is running..."
+			echo "$ID is running..."
 		else
-		    echo "$ID is stopped"
+			echo "$ID is stopped"
 		fi
-		;;
+	;;
 
 	stop)
 		echo -n "Shutting down $ID: "
 		system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-		    stop
-		    /usr/bin/logger -t $ID "shutdown succeeded"
+			stop
+			/usr/bin/logger -t $ID "shutdown succeeded"
 		fi
 		echo_success
 		rm -f $GLOB_PIDFILE
 		rm -f $GLOB_LOCKFILE
 		rtrn=0
 		echo 
-		;;
+	;;
 
-        reload)
-               rtrn=0
-	       ;;
+	reload)
+		rtrn=0
+	;;
 
 	*)
 		echo "Usage: $0 {start|stop|status|restart|condrestart|reload}"
 		rtrn=1
-		;;
+	;;
 
 esac
 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2007-03-15 16:52 rmccabe
  0 siblings, 0 replies; 11+ messages in thread
From: rmccabe @ 2007-03-15 16:52 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-03-15 16:52:37

Modified files:
	luci/init.d    : luci 

Log message:
	Revert back to the old init script. This one needs more testing.

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

--- conga/luci/init.d/luci	2007/02/20 17:56:54	1.15
+++ conga/luci/init.d/luci	2007/03/15 16:52:36	1.16
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2005-2007 Red Hat, Inc.
+# Copyright (C) 2005 Red Hat, Inc.
 #
 # This program is Free Software.  You may modify and/or redistribute it under
 # the terms of the GNU General Public License version 2, or (at your option)
@@ -53,186 +53,185 @@
 
 https_certs_ok()
 {
-	if [ ! -e $HTTPS_PRIVKEY ] ; then
-		return 1
-	fi
-	if [ ! -e $HTTPS_PUBKEY ] ; then
-		return 2
-	fi
-	return 0
+    if [ ! -e $HTTPS_PRIVKEY ] ; then
+	return 1
+    fi
+    if [ ! -e $HTTPS_PUBKEY ] ; then
+	return 2
+    fi
+    return 0
 }
 
 generate_https_certs()
 {
-	rm -f $HTTPS_PRIVKEY $HTTPS_PUBKEY
-	echo -n "generating https SSL certificates...  "
-	/usr/bin/openssl genrsa -out $HTTPS_PRIVKEY 2048 > /dev/null 2>&1
-	/usr/bin/openssl req -new -x509 -key $HTTPS_PRIVKEY -out $HTTPS_PUBKEY -days 1825 -config /var/lib/luci/var/certs/cacert.config
-	/bin/chown $LUCI_USER:$LUCI_GROUP $HTTPS_PRIVKEY $HTTPS_PUBKEY
-	/bin/chmod 600 $HTTPS_PRIVKEY
-	/bin/chmod 644 $HTTPS_PUBKEY
-	ret=$?
-	echo "done"
-	return $ret
+    rm -f $HTTPS_PRIVKEY $HTTPS_PUBKEY
+    echo -n "generating https SSL certificates...  "
+    /usr/bin/openssl genrsa -out $HTTPS_PRIVKEY 2048 > /dev/null 2>&1
+    /usr/bin/openssl req -new -x509 -key $HTTPS_PRIVKEY -out $HTTPS_PUBKEY -days 1825 -config /var/lib/luci/var/certs/cacert.config
+    /bin/chown $LUCI_USER:$LUCI_GROUP $HTTPS_PRIVKEY $HTTPS_PUBKEY
+    /bin/chmod 600 $HTTPS_PRIVKEY
+    /bin/chmod 644 $HTTPS_PUBKEY
+    echo "done"
+    return $?
 }
 
 start()
 {
-	$LUCID >/dev/null 2>/dev/null &
-	
-	https_certs_ok
-	if [ "1$?" != "10" ] ; then
-		generate_https_certs
-	fi
-	sleep 4
-	sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF | $STUNNEL_D -fd 0
-	sleep 4
+    $LUCID >/dev/null 2>/dev/null &
+    
+    https_certs_ok
+    if [ "1$?" != "10" ] ; then
+	generate_https_certs
+    fi
+    sleep 4
+    sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF | $STUNNEL_D -fd 0
+    sleep 4
 }
 
 stop_luci()
 {
-	pid_num=`cat $PIDFILE`
-	kill $pid_num
-	sleep 2
+    pid_num=`cat $PIDFILE`
+    kill $pid_num
+    sleep 2
 }
 
 stop_stunnel()
 {
-	pid_num=`cat $STUNNEL_PID`
-	kill $pid_num
-	sleep 2
+    pid_num=`cat $STUNNEL_PID`
+    kill $pid_num
+    sleep 2
 }
 
 stop()
 {
-	stop_luci
-	stop_stunnel
+    stop_luci
+    stop_stunnel
 }
 
 system_running()
 {
-	# luci
-	LUCI_UP=1
-	if [ -e $PIDFILE ] ; then
-		pid_num=`cat $PIDFILE`
-		kill -0 $pid_num 2>/dev/null
-		if [ "1$?" != "10" ] ; then
-			LUCI_UP=0
-		fi
-	else
-		LUCI_UP=0
-	fi
-	
-	# stunnel
-	ST_UP=2
-	if [ -e $STUNNEL_PID ] ; then
-		pid_num=`cat $STUNNEL_PID`
-		kill -0 $pid_num 2>/dev/null
-		if [ "1$?" != "10" ] ; then
-			ST_UP=0
-		fi
-	else
-		ST_UP=0
-	fi
-	
-	# resolve
-	let res=$LUCI_UP+$ST_UP
-	if [ "1$res" = "10" ] ; then
-		# neither luci nor stunnel is running
-		return 1
-	fi
-	if [ "1$res" = "11" ] ; then
-		# only stunnel running -> stop it
-		stop_stunnel
-	fi
-	if [ "1$res" = "12" ] ; then
-		# only luci running -> stop it
-		stop_luci
-	fi
+    # luci
+    LUCI_UP=1
+    if [ -e $PIDFILE ] ; then
+	pid_num=`cat $PIDFILE`
+	res=`ps -Af | grep python | grep $LUCI_USER | grep $pid_num`
+	if [ "1$res" != "1" ] ; then
+	    LUCI_UP=0
+	fi
+    fi
+    
+    # stunnel
+    ST_UP=2
+    if [ -e $STUNNEL_PID ] ; then
+	pid_num=`cat $STUNNEL_PID`
+	res=`ps -Af | grep stunnel | grep $LUCI_USER | grep $pid_num`
+	if [ "1$res" != "1" ] ; then
+	    ST_UP=0
+	fi
+    fi
+    
+    # resolve
+    let res=$LUCI_UP+$ST_UP
+    if [ "1$res" = "10" ] ; then
 	return 0
+    fi
+    if [ "1$res" = "11" ] ; then
+	# only stunnel running -> stop it
+	stop_stunnel
+    fi
+    if [ "1$res" = "12" ] ; then
+	# only luci running -> stop it
+	stop_luci
+    fi
+    return 1
 }
 
 
+
 case $1 in
 	start)
-		if ! /bin/grep True /var/lib/luci/.default_password_has_been_reset 2>&1 >/dev/null; then
-			echo -e "\nluci's 'admin' password has to be set before the luci server is allowed to start"
-			echo "To do so, execute (as root): " 
-			echo -e "\tluci_admin password\n"
-			/usr/bin/logger -t $ID "startup failed (password not set): execute 'luci_admin password'"
-			exit 1
+	        if ! /bin/grep True /var/lib/luci/.default_password_has_been_reset 2>&1 >/dev/null; then
+		    echo ""
+		    echo "luci's 'admin' password has to be changed before server is allowed to start"
+		    echo "To do so, execute (as root): " 
+		    echo -e "\tluci_admin password"
+		    echo ""
+		    /usr/bin/logger -t $ID "startup failed (password not reset): execute 'luci_admin password'"
+		    exit 1
 		fi
 		
 		echo -n "Starting $ID: "
 		system_running
 		rtrn=$?
 		if [ "1$rtrn" != "10" ] ; then
-			start
+		    start
 		fi
 		system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-			echo_success
-			cat $PIDFILE > $GLOB_PIDFILE
-			touch $GLOB_LOCKFILE
-			/usr/bin/logger -t $ID "startup succeeded"
-			/usr/bin/logger -t $ID "Listening on port $LUCI_HTTPS_PORT; accessible using url $LUCI_URL"
-			echo -e "\n\nPlease, point your web browser to $LUCI_URL to access luci\n"
+		    echo_success
+		    cat $PIDFILE > $GLOB_PIDFILE
+		    touch $GLOB_LOCKFILE
+		    /usr/bin/logger -t $ID "startup succeeded"
+		    /usr/bin/logger -t $ID "Listening on port $LUCI_HTTPS_PORT; accessible using url $LUCI_URL"
+		    echo; echo
+		    echo "Please, point your web browser to $LUCI_URL to access luci"
+		    echo
 		else
-			echo_failure
-			/usr/bin/logger -t $ID "startup failed"
-			echo
+		    echo_failure
+		    /usr/bin/logger -t $ID "startup failed"
+		    echo
 		fi
-	;;
+		;;
 
-	restart)
+        restart)
 		$0 stop
 		$0 start 
 		rtrn=$?
-	;;
-		
-	condrestart)
-		system_running
+		;;
+        
+        condrestart)
+	        system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-			$0 restart
-			rtrn=$?
+		    $0 restart
+		    rtrn=$?
 		fi
-	;;
+		;;
 
 	status)
-			system_running
+	        system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-			echo "$ID is running..."
+		    echo "$ID is running..."
 		else
-			echo "$ID is stopped"
+		    echo "$ID is stopped"
 		fi
-	;;
+		;;
 
 	stop)
 		echo -n "Shutting down $ID: "
 		system_running
 		rtrn=$?
 		if [ "1$rtrn" = "10" ] ; then
-			stop
-			/usr/bin/logger -t $ID "shutdown succeeded"
+		    stop
+		    /usr/bin/logger -t $ID "shutdown succeeded"
 		fi
 		echo_success
 		rm -f $GLOB_PIDFILE
 		rm -f $GLOB_LOCKFILE
 		rtrn=0
 		echo 
-	;;
+		;;
 
-	reload)
-		rtrn=0
-	;;
+        reload)
+               rtrn=0
+	       ;;
 
 	*)
 		echo "Usage: $0 {start|stop|status|restart|condrestart|reload}"
 		rtrn=1
-	;;
+		;;
 
 esac
 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2007-05-22  1:39 rmccabe
  0 siblings, 0 replies; 11+ messages in thread
From: rmccabe @ 2007-05-22  1:39 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	EXPERIMENTAL
Changes by:	rmccabe at sourceware.org	2007-05-22 01:39:51

Modified files:
	luci/init.d    : luci 

Log message:
	Make the init script more robust, and make it log errors for any failures.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/init.d/luci.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.16&r2=1.16.2.1

--- conga/luci/init.d/luci	2007/03/15 16:52:36	1.16
+++ conga/luci/init.d/luci	2007/05/22 01:39:51	1.16.2.1
@@ -1,10 +1,9 @@
 #!/bin/sh
 #
-# Copyright (C) 2005 Red Hat, Inc.
+# Copyright (C) 2005-2007 Red Hat, Inc.
 #
-# This program is Free Software.  You may modify and/or redistribute it under
-# the terms of the GNU General Public License version 2, or (at your option)
-# any later version.
+# This program is Free Software. You may modify and/or redistribute it under
+# the terms of the GNU General Public License version 2.
 #
 # description:  Starts and stops Red Hat Cluster and Storage Remote \
 #               Configuration Web Interface (luci)
@@ -23,22 +22,26 @@
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export PATH
 
-ID="luci"
-LUCID="/var/lib/luci/bin/runzope"
-PIDFILE="/var/lib/luci/var/Z2.pid"
-GLOB_PIDFILE="/var/run/luci.pid"
-GLOB_LOCKFILE="/var/lock/subsys/luci"
+ID='luci'
+LUCID='/var/lib/luci/bin/runzope'
+PIDFILE='/var/lib/luci/var/Z2.pid'
+GLOB_PIDFILE='/var/run/luci.pid'
+GLOB_LOCKFILE='/var/lock/subsys/luci'
 
-LUCI_USER="luci"
-LUCI_GROUP="luci"
+LUCI_USER='luci'
+LUCI_GROUP='luci'
 
 LUCI_URL="https://`/bin/hostname`:$LUCI_HTTPS_PORT"
 
-HTTPS_PUBKEY="/var/lib/luci/var/certs/https.pem"
-HTTPS_PRIVKEY="/var/lib/luci/var/certs/https.key.pem"
-STUNNEL_D="/usr/sbin/stunnel"
-STUNNEL_PID="/var/lib/luci/var/stunnel/pid"
-STUNNEL_CONF="/var/lib/luci/etc/stunnel.conf"
+HTTPS_PUBKEY='/var/lib/luci/var/certs/https.pem'
+HTTPS_PRIVKEY='/var/lib/luci/var/certs/https.key.pem'
+
+KEY_LIFE_DAYS='1825'
+KEY_BITS='2048'
+
+STUNNEL_D='/usr/sbin/stunnel'
+STUNNEL_PID='/var/lib/luci/var/stunnel/pid'
+STUNNEL_CONF='/var/lib/luci/etc/stunnel.conf'
 
 #
 # Only root wants to run this...
@@ -53,186 +56,273 @@
 
 https_certs_ok()
 {
-    if [ ! -e $HTTPS_PRIVKEY ] ; then
-	return 1
-    fi
-    if [ ! -e $HTTPS_PUBKEY ] ; then
-	return 2
-    fi
-    return 0
-}
+	if [ ! -f "$HTTPS_PRIVKEY" ]; then
+		return 1
+	fi
 
-generate_https_certs()
-{
-    rm -f $HTTPS_PRIVKEY $HTTPS_PUBKEY
-    echo -n "generating https SSL certificates...  "
-    /usr/bin/openssl genrsa -out $HTTPS_PRIVKEY 2048 > /dev/null 2>&1
-    /usr/bin/openssl req -new -x509 -key $HTTPS_PRIVKEY -out $HTTPS_PUBKEY -days 1825 -config /var/lib/luci/var/certs/cacert.config
-    /bin/chown $LUCI_USER:$LUCI_GROUP $HTTPS_PRIVKEY $HTTPS_PUBKEY
-    /bin/chmod 600 $HTTPS_PRIVKEY
-    /bin/chmod 644 $HTTPS_PUBKEY
-    echo "done"
-    return $?
+	if [ ! -f "$HTTPS_PUBKEY" ]; then
+		return 2
+	fi
+
+	return 0
 }
 
-start()
+generate_https_certs()
 {
-    $LUCID >/dev/null 2>/dev/null &
-    
-    https_certs_ok
-    if [ "1$?" != "10" ] ; then
-	generate_https_certs
-    fi
-    sleep 4
-    sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF | $STUNNEL_D -fd 0
-    sleep 4
+	echo -n "Generating https SSL certificates...  "
+	old_umask=`umask`
+	umask 077
+
+	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"
+	ret=$?
+
+	umask $old_umask
+	echo "done"
+	return $ret
 }
 
 stop_luci()
 {
-    pid_num=`cat $PIDFILE`
-    kill $pid_num
-    sleep 2
+	pid_num=`cat $PIDFILE 2>/dev/null`
+	ret=$?
+	if [ $ret -eq 0 ]; then
+		kill $pid_num >& /dev/null
+		ret=$?
+	fi
+
+	if [ $ret -ne 0 ]; then
+		pkill -u "$LUCI_USER" python >&/dev/null
+		ret=$?
+	fi
+	return $ret
 }
 
 stop_stunnel()
 {
-    pid_num=`cat $STUNNEL_PID`
-    kill $pid_num
-    sleep 2
+	pid_num=`cat $STUNNEL_PID 2>/dev/null`
+	ret=$?
+	if [ $ret -eq 0 ]; then
+		kill $pid_num >& /dev/null
+		ret=$?
+	fi
+
+	if [ $ret -ne 0 ]; then
+		pkill -u "$LUCI_USER" stunnel >&/dev/null
+		ret=$?
+	fi
+	return $ret
 }
 
 stop()
 {
-    stop_luci
-    stop_stunnel
+	stop_stunnel
+	if [ $? -ne 0 ]; then
+		errmsg='Failed to stop stunnel'
+		return 1
+	fi
+	stop_luci
+	if [ $? -ne 0 ]; then
+		errmsg='Failed to stop luci'
+		return 1
+	fi
+	return 0
 }
 
-system_running()
+start()
 {
-    # luci
-    LUCI_UP=1
-    if [ -e $PIDFILE ] ; then
-	pid_num=`cat $PIDFILE`
-	res=`ps -Af | grep python | grep $LUCI_USER | grep $pid_num`
-	if [ "1$res" != "1" ] ; then
-	    LUCI_UP=0
-	fi
-    fi
-    
-    # stunnel
-    ST_UP=2
-    if [ -e $STUNNEL_PID ] ; then
-	pid_num=`cat $STUNNEL_PID`
-	res=`ps -Af | grep stunnel | grep $LUCI_USER | grep $pid_num`
-	if [ "1$res" != "1" ] ; then
-	    ST_UP=0
-	fi
-    fi
-    
-    # resolve
-    let res=$LUCI_UP+$ST_UP
-    if [ "1$res" = "10" ] ; then
+	https_certs_ok
+	if [ $? -ne 0 ]; then
+		generate_https_certs
+		if [ $? -ne 0 ]; then
+			errmsg='An error occurred while generating certificates'
+			return 1
+		fi
+	fi
+
+	$LUCID >&/dev/null &
+	sleep 4
+
+	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
+		return 1
+	fi
 	return 0
-    fi
-    if [ "1$res" = "11" ] ; then
-	# only stunnel running -> stop it
-	stop_stunnel
-    fi
-    if [ "1$res" = "12" ] ; then
-	# only luci running -> stop it
-	stop_luci
-    fi
-    return 1
 }
 
+luci_running()
+{
+	LUCI_UP=1
+	pgrep -u "$LUCI_USER" python >&/dev/null
+	if [ $? -ne 0 ]; then
+		LUCI_UP=0
+	fi
+
+	if [ -f "$PIDFILE" ] && [ $LUCI_UP -eq 0 ]; then
+		# stale pidfile
+		rm -f "$PIDFILE" >& /dev/null
+	fi
+	return $LUCI_UP
+}
+
+stunnel_running()
+{
+	ST_UP=2
+	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"
+	fi
+	return $ST_UP
+}
+
+system_running()
+{
+	luci_running
+	LUCI_UP=$?
+
+	stunnel_running
+	STUNNEL_UP=$?
+
+	res=`echo $LUCI_UP $STUNNEL_UP + p | /usr/bin/dc`
+	if [ $res -eq 0 ]; then
+		# none up
+		return 0
+	elif [ $res -eq 3 ]; then
+		# both up
+		return 1
+	elif [ $res -eq 1 ]; then
+		# only luci up
+		stop_luci
+		if [ $? -ne 0 ]; then
+			errmsg='Only luci was running and it could not be stopped'
+			return 3
+		fi
+	elif [ $res -eq 2 ]; then
+		# only stunnel up
+		stop_stunnel
+		if [ $? -ne 0 ]; then
+			errmsg='Only stunnel was running and it could not be stopped'
+			return 4
+		fi
+	fi
+	return 0
+}
 
 case $1 in
 	start)
-	        if ! /bin/grep True /var/lib/luci/.default_password_has_been_reset 2>&1 >/dev/null; then
-		    echo ""
-		    echo "luci's 'admin' password has to be changed before server is allowed to start"
-		    echo "To do so, execute (as root): " 
-		    echo -e "\tluci_admin password"
-		    echo ""
-		    /usr/bin/logger -t $ID "startup failed (password not reset): execute 'luci_admin password'"
-		    exit 1
+		if ! /bin/grep True /var/lib/luci/.default_password_has_been_reset 2>&1 >/dev/null; then
+			echo ""
+			echo "The admin user password must be set before the luci can start"
+			echo "To do so, execute (as root): "
+			echo -e "\tluci_admin password\n"
+			/usr/bin/logger -t "$ID" "Luci startup failed: admin password not set (execute 'luci_admin password')"
+			exit 1
 		fi
-		
+
 		echo -n "Starting $ID: "
 		system_running
-		rtrn=$?
-		if [ "1$rtrn" != "10" ] ; then
-		    start
+		ret=$?
+		if [ $ret -eq 0 ]; then
+			start
+		elif [ $ret -eq 1 ]; then
+			# already running
+			echo_success
+			echo
+			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"
+			exit 1
 		fi
+
 		system_running
-		rtrn=$?
-		if [ "1$rtrn" = "10" ] ; then
-		    echo_success
-		    cat $PIDFILE > $GLOB_PIDFILE
-		    touch $GLOB_LOCKFILE
-		    /usr/bin/logger -t $ID "startup succeeded"
-		    /usr/bin/logger -t $ID "Listening on port $LUCI_HTTPS_PORT; accessible using url $LUCI_URL"
-		    echo; echo
-		    echo "Please, point your web browser to $LUCI_URL to access luci"
-		    echo
+		if [ $? -eq 1 ]; then
+			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"
+			echo; echo
+			echo "Point your web browser to $LUCI_URL to access luci"
+			echo
 		else
-		    echo_failure
-		    /usr/bin/logger -t $ID "startup failed"
-		    echo
+			echo_failure
+			/usr/bin/logger -t "$ID" "Luci startup failed $errmsg"
+			echo
 		fi
-		;;
+	;;
 
-        restart)
+	restart)
 		$0 stop
-		$0 start 
 		rtrn=$?
-		;;
-        
-        condrestart)
-	        system_running
+		if [ $rtrn -eq 0 ]; then
+			$0 start
+			rtrn=$?
+		fi
+	;;
+
+	condrestart)
+		system_running
 		rtrn=$?
-		if [ "1$rtrn" = "10" ] ; then
-		    $0 restart
-		    rtrn=$?
+		if [ $? -eq 1 ] ; then
+			$0 restart
+			rtrn=$?
 		fi
-		;;
+	;;
 
 	status)
-	        system_running
-		rtrn=$?
-		if [ "1$rtrn" = "10" ] ; then
-		    echo "$ID is running..."
+		system_running
+		if [ $? -eq 1 ]; then
+			echo "$ID is running..."
+			rtrn=0
 		else
-		    echo "$ID is stopped"
+			echo "$ID is stopped"
+			rtrn=1
 		fi
-		;;
+	;;
 
 	stop)
 		echo -n "Shutting down $ID: "
 		system_running
 		rtrn=$?
-		if [ "1$rtrn" = "10" ] ; then
-		    stop
-		    /usr/bin/logger -t $ID "shutdown succeeded"
-		fi
-		echo_success
-		rm -f $GLOB_PIDFILE
-		rm -f $GLOB_LOCKFILE
-		rtrn=0
-		echo 
-		;;
+		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"
+				rtrn=0
+			else
+				/usr/bin/logger -t "$ID" "Luci shutdown failed"
+			fi
+		fi
+		if [ $rtrn -eq 0 ]; then
+			echo_success
+		else
+			echo_failure
+		fi
+		echo
+	;;
 
-        reload)
-               rtrn=0
-	       ;;
+	reload)
+		rtrn=0
+	;;
 
 	*)
 		echo "Usage: $0 {start|stop|status|restart|condrestart|reload}"
 		rtrn=1
-		;;
-
+	;;
 esac
 
 exit $rtrn



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2007-06-05 16:03 rmccabe
  0 siblings, 0 replies; 11+ messages in thread
From: rmccabe @ 2007-06-05 16:03 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	EXPERIMENTAL
Changes by:	rmccabe at sourceware.org	2007-06-05 16:03:33

Modified files:
	luci/init.d    : luci 

Log message:
	fix bz242668 (luci init script can return non-LSB-compliant return codes)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/init.d/luci.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.16.2.1&r2=1.16.2.2

--- conga/luci/init.d/luci	2007/05/22 01:39:51	1.16.2.1
+++ conga/luci/init.d/luci	2007/06/05 16:03:33	1.16.2.2
@@ -46,12 +46,12 @@
 #
 # Only root wants to run this...
 #
-[ `id -u` = 0 ] || exit 0
+[ `id -u` = 0 ] || exit 4
 
 #
 # If we're not configured, then don't start anything.
 #
-[ "${NETWORKING}" = "yes" ] || exit 0
+[ "${NETWORKING}" = "yes" ] || exit 1
 
 
 https_certs_ok()
@@ -221,13 +221,14 @@
 
 case $1 in
 	start)
-		if ! /bin/grep True /var/lib/luci/.default_password_has_been_reset 2>&1 >/dev/null; then
+		grep True /var/lib/luci/.default_password_has_been_reset >&/dev/null
+		if [ $? -ne 0 ]; then
 			echo ""
 			echo "The admin user password must be set before the luci can start"
-			echo "To do so, execute (as root): "
+			echo "To set it, execute (as root): "
 			echo -e "\tluci_admin password\n"
 			/usr/bin/logger -t "$ID" "Luci startup failed: admin password not set (execute 'luci_admin password')"
-			exit 1
+			exit 6
 		fi
 
 		echo -n "Starting $ID: "
@@ -256,17 +257,19 @@
 			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"
 			echo
+			exit 1
 		fi
 	;;
 
 	restart)
 		$0 stop
 		rtrn=$?
-		if [ $rtrn -eq 0 ]; then
+		if [ $rtrn -eq 0 ] || [ $rtrn -eq 7 ]; then
 			$0 start
 			rtrn=$?
 		fi
@@ -275,7 +278,7 @@
 	condrestart)
 		system_running
 		rtrn=$?
-		if [ $? -eq 1 ] ; then
+		if [ $rtrn -eq 1 ]; then
 			$0 restart
 			rtrn=$?
 		fi
@@ -288,7 +291,7 @@
 			rtrn=0
 		else
 			echo "$ID is stopped"
-			rtrn=1
+			rtrn=7
 		fi
 	;;
 
@@ -305,8 +308,14 @@
 				rtrn=0
 			else
 				/usr/bin/logger -t "$ID" "Luci shutdown failed"
+				rtrn=1
 			fi
+		elif [ $rtrn -eq 0 ]; then
+			rtrn=7
+		else
+			rtrn=1
 		fi
+
 		if [ $rtrn -eq 0 ]; then
 			echo_success
 		else
@@ -316,12 +325,12 @@
 	;;
 
 	reload)
-		rtrn=0
+		rtrn=3
 	;;
 
 	*)
 		echo "Usage: $0 {start|stop|status|restart|condrestart|reload}"
-		rtrn=1
+		rtrn=3
 	;;
 esac
 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2008-02-05 18:31 rmccabe
  0 siblings, 0 replies; 11+ messages in thread
From: rmccabe @ 2008-02-05 18:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at 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
 	;;



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2008-02-05 18:41 rmccabe
  0 siblings, 0 replies; 11+ messages in thread
From: rmccabe @ 2008-02-05 18:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at 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 "\tluci_admin password\n"
-			/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



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Cluster-devel] conga/luci/init.d luci
@ 2010-02-04 23:36 rmccabe
  0 siblings, 0 replies; 11+ messages in thread
From: rmccabe @ 2010-02-04 23:36 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at 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



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-02-04 23:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-17 20:56 [Cluster-devel] conga/luci/init.d luci kupcevic
  -- strict thread matches above, loose matches on Subject: below --
2006-09-26  0:22 kupcevic
2006-10-03 18:23 kupcevic
2006-11-02  0:23 kupcevic
2007-02-20 17:56 rmccabe
2007-03-15 16:52 rmccabe
2007-05-22  1:39 rmccabe
2007-06-05 16:03 rmccabe
2008-02-05 18:31 rmccabe
2008-02-05 18:41 rmccabe
2010-02-04 23:36 rmccabe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).