]> git.pld-linux.org Git - packages/ifplugd.git/commitdiff
- use functions to avoid reexec for restart
authorElan Ruusamäe <glen@pld-linux.org>
Sun, 17 Sep 2006 17:47:34 +0000 (17:47 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    ifplugd.init -> 1.7

ifplugd.init

index 6b609a981e9246112c24432fcbe7a143ca9b57b0..d7af7f7e2c5b09be310e958fc8c7be1f1c65c699 100644 (file)
@@ -26,14 +26,7 @@ else
        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 @@ case "$1" in
                        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 @@ case "$1" in
                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 @@ case "$1" in
                        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 @@ case "$1" in
                        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}"
This page took 0.167794 seconds and 4 git commands to generate.