SOURCES: postfix.init - use functions; only starting and restarting require...

blues blues at pld-linux.org
Mon Jan 26 22:13:11 CET 2009


Author: blues                        Date: Mon Jan 26 21:13:11 2009 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- use functions; only starting and restarting requires networking check. 
  There is no need to check it while stopping or rebuilding databases (man
  can do this completelly offline).

---- Files affected:
SOURCES:
   postfix.init (1.21 -> 1.22) 

---- Diffs:

================================================================
Index: SOURCES/postfix.init
diff -u SOURCES/postfix.init:1.21 SOURCES/postfix.init:1.22
--- SOURCES/postfix.init:1.21	Wed Oct 18 13:09:32 2006
+++ SOURCES/postfix.init	Mon Jan 26 22:13:05 2009
@@ -19,20 +19,18 @@
 [ -f /etc/sysconfig/postfix ] && . /etc/sysconfig/postfix
 
 # Check that networking is up.
-if is_yes "${NETWORKING}"; then
-	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
-		msg_network_down Postfix
-		exit 1
+networking_check() {
+	if is_yes "${NETWORKING}"; then
+		if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+			msg_network_down Postfix
+			exit 1
+		fi
+	else
+		exit 0
 	fi
-else
-	exit 0
-fi
+}
 
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
-	# Check if the service is already running?
+start() {
 	if [ ! -f /var/lock/subsys/postfix ]; then
 		msg_starting Postfix
 		busy
@@ -48,9 +46,9 @@
 	else
 		msg_already_running Postfix
 	fi
-	;;
-  stop)
-	# Stop daemons.
+}
+
+stop() {
 	if [ -f /var/lock/subsys/postfix ]; then
 		msg_stopping Postfix
 		busy
@@ -65,13 +63,26 @@
 	else
 		msg_not_running Postfix
 	fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+  	networking_check
+	start
+	;;
+  stop)
+  	stop
 	;;
   restart)
-	$0 stop
-	$0 start
+  	networking_check
+	stop
+	start
 	exit $?
 	;;
   reload|force-reload)
+  	networking_check
 	if [ -f /var/lock/subsys/postfix ]; then
 		msg_reloading Postfix
 		daemon /usr/sbin/postfix reload
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/postfix.init?r1=1.21&r2=1.22&f=u



More information about the pld-cvs-commit mailing list