From: Elan Ruusamäe Date: Sun, 17 Sep 2006 17:47:34 +0000 (+0000) Subject: - use functions to avoid reexec for restart X-Git-Tag: auto/ac/ifplugd-0_28-2~10 X-Git-Url: https://git.pld-linux.org/?a=commitdiff_plain;h=cd1b01008d60dfceb65f3411def485f7b44f7c8c;p=packages%2Fifplugd.git - use functions to avoid reexec for restart Changed files: ifplugd.init -> 1.7 --- diff --git a/ifplugd.init b/ifplugd.init index 6b609a9..d7af7f7 100644 --- a/ifplugd.init +++ b/ifplugd.init @@ -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}"