SOURCES: apache1.init - use functions

glen glen at pld-linux.org
Thu Jan 25 18:14:40 CET 2007


Author: glen                         Date: Thu Jan 25 17:14:40 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- use functions

---- Files affected:
SOURCES:
   apache1.init (1.23 -> 1.24) 

---- Diffs:

================================================================
Index: SOURCES/apache1.init
diff -u SOURCES/apache1.init:1.23 SOURCES/apache1.init:1.24
--- SOURCES/apache1.init:1.23	Tue May 30 13:40:40 2006
+++ SOURCES/apache1.init	Thu Jan 25 18:14:34 2007
@@ -33,10 +33,11 @@
 	HTTPD_OPTS="$HTTPD_OPTS -4"
 fi
 
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
+configtest() {
+	apache -t > /dev/null 2>&1
+}
+
+start() {
 	# Check if the service is already running?
 	if [ -x /usr/lib/apache1/lingerd ]; then
 		if [ ! -f /var/lock/subsys/lingerd ]; then
@@ -56,8 +57,9 @@
 	else
 		msg_already_running apache
 	fi
-	;;
-  stop)
+}
+
+stop() {
 	# Stop daemons.
 	if [ -f /var/lock/subsys/apache ]; then
 		msg_stopping apache
@@ -75,6 +77,16 @@
 			msg_not_running lingerd
 		fi
 	fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+  	start
+	;;
+  stop)
+  	stop
 	;;
   status)
 	status apache
@@ -85,10 +97,8 @@
 	apache -t > /dev/null 2>&1
 	RETVAL=$?
 	if [ $RETVAL -eq 0 ]; then
-		$0 stop
-		RETVAL=$((RETVAL + $?))
-		$0 start
-		RETVAL=$((RETVAL + $?))
+		stop
+		start
 	else
 		fail
 		echo "Configuration file syntax test failed."
@@ -99,7 +109,7 @@
   	if [ -f /var/lock/subsys/apache ]; then
 		msg_reloading apache
 
-		apache -t > /dev/null 2>&1
+		configtest
 		RETVAL=$?
 		if [ $RETVAL -eq 0 ]; then
 			killproc apache -HUP
@@ -116,7 +126,7 @@
 	if [ -f /var/lock/subsys/apache ]; then
 		msg_reloading apache
 
-		apache -t > /dev/null 2>&1
+		configtest
 		RETVAL=$?
 		if [ $RETVAL -eq 0 ]; then
 			killproc apache -USR1
@@ -133,7 +143,7 @@
 	if [ -f /var/lock/subsys/apache ]; then
 		msg_reloading apache
 
-		apache -t > /dev/null 2>&1
+		configtest
 		RETVAL=$?
 		if [ $RETVAL -eq 0 ]; then
 			killproc apache -USR1
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/apache1.init?r1=1.23&r2=1.24&f=u



More information about the pld-cvs-commit mailing list