SOURCES: ifplugd.init - use functions to avoid reexec for restart

glen glen at pld-linux.org
Sun Sep 17 19:47:39 CEST 2006


Author: glen                         Date: Sun Sep 17 17:47:39 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- use functions to avoid reexec for restart

---- Files affected:
SOURCES:
   ifplugd.init (1.6 -> 1.7) 

---- Diffs:

================================================================
Index: SOURCES/ifplugd.init
diff -u SOURCES/ifplugd.init:1.6 SOURCES/ifplugd.init:1.7
--- SOURCES/ifplugd.init:1.6	Sun Sep 17 19:43:24 2006
+++ SOURCES/ifplugd.init	Sun Sep 17 19:47:34 2006
@@ -26,14 +26,7 @@
 	exit 0
 fi
 
-[ -n "$2" ] && INTERFACES="$2"
-
-[ -z "$INTERFACES" -o "$INTERFACES" = "auto" ] && INTERFACES=$(awk -F: '/(eth|wlan)/ { print $1 }' /proc/net/dev | xargs)
-
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
+start() {
 	# Check if the service is already running?
 	for iface in $INTERFACES; do
 		if [ ! -f /var/lock/subsys/ifplugd.${iface} ]; then
@@ -47,8 +40,9 @@
 			msg_already_running "ifplugd ($iface)"
 		fi
 	done
-	;;
-  stop)
+}
+
+stop() {
   	for iface in $INTERFACES; do
 		if [ -f /var/lock/subsys/ifplugd.${iface} ]; then
 			msg_stopping "Network Interface Plugging Daemon ($iface)"
@@ -59,8 +53,9 @@
 		fi
 	done
 	rm -f /var/run/ifplugd.pid /var/lock/subsys/ifplugd.* >/dev/null 2>&1
-	;;
-  suspend)
+}
+
+suspend() {
   	for iface in $INTERFACES; do
 		if [ -f /var/lock/subsys/ifplugd.${iface} ]; then
 			msg_stopping "Network Interface Plugging Daemon (suspending $iface)"
@@ -70,8 +65,9 @@
 			msg_not_running "ifplugd ($iface)"
 		fi
 	done
-	;;
-   resume)
+}
+
+resume() {
 	for iface in $INTERFACES; do
 		if [ -f /var/lock/subsys/ifplugd.${iface} ]; then
 			msg_starting "Network Interface Plugging Daemon (resuming $iface)"
@@ -81,29 +77,55 @@
 			msg_not_running "ifplugd ($iface)"
 		fi
 	done
+}
+
+reload() {
+	if [ -f /var/lock/subsys/ifplugd ]; then
+		$0 stop
+		sleep 2
+		$0 start
+		RETVAL=$?
+	else
+		msg_not_running ifplugd
+		exit 7
+	fi
+}
+
+[ -n "$2" ] && INTERFACES="$2"
+
+[ -z "$INTERFACES" -o "$INTERFACES" = "auto" ] && INTERFACES=$(awk -F: '/(eth|wlan)/ { print $1 }' /proc/net/dev | xargs)
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+  	start
+	;;
+  stop)
+  	stop
+	;;
+  suspend)
+  	suspend
+	;;
+  resume)
+  	resume
 	;;
   restart)
-	$0 stop
-	$0 start
+	stop
+	start
 	exit $?
 	;;
   status)
 	status /sbin/ifplugd
+	RETVAL=$?
   	for iface in $INTERFACES; do
-		/sbin/ifplugd -c -i ${iface}
+		/sbin/ifplugd -c -i $iface
+		ret=$?
+		[ $ret -gt 0 ] && RETVAL=$ret
 	done
-	exit $?
 	;;
   reload|force-reload)
-	if [ -f /var/lock/subsys/ifplugd ]; then
-		$0 stop
-		sleep 2
-		$0 start
-		RETVAL=$?
-	else
-		msg_not_running ifplugd
-		exit 7
-	fi
+	reload
 	;;
   *)
 	msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/ifplugd.init?r1=1.6&r2=1.7&f=u



More information about the pld-cvs-commit mailing list