[Cluster-devel] conga/luci/init.d luci

rmccabe at sourceware.org rmccabe at sourceware.org
Tue Feb 20 17:56:55 UTC 2007


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
 




More information about the Cluster-devel mailing list