summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorY Giridhar Appaji Nag <giridhar@appaji.net>2008-09-22 18:08:10 +0530
committerAndrew Shadura <andrew.shadura@collabora.co.uk>2016-06-21 11:57:31 +0200
commit7b9f005dae9268d9a79904fb4de3221d23ee5156 (patch)
treed7fda0793863ee27e2326a5e10ec88193ceb25db
parentcc784237d4e0083b603883fcb459dfb2fc96ab4d (diff)
Imported Debian patch 0.28-13
-rw-r--r--debian/changelog10
-rw-r--r--debian/ifplugd.action7
-rw-r--r--debian/ifplugd.init2
-rw-r--r--debian/ifplugd.udev.agent117
4 files changed, 91 insertions, 45 deletions
diff --git a/debian/changelog b/debian/changelog
index 3fbf95b..11148ac 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+ifplugd (0.28-13) unstable; urgency=low
+
+ * The "Thanks Kel Modderman <kel@otaku42.de> for patches" release
+ + Run action scripts in reverse when action=down and remove
+ --exit-on-error. (Closes: #488536)
+ + Silence the initscript if INTERFACES is empty (Closes: #487197)
+ + Wait for "lo" != down before starting ifplugd (Closes: #325614)
+
+ -- Y Giridhar Appaji Nag <giridhar@appaji.net> Mon, 22 Sep 2008 18:08:10 +0530
+
ifplugd (0.28-12) unstable; urgency=low
* Thanks for updated debconf translations:
diff --git a/debian/ifplugd.action b/debian/ifplugd.action
index 44e7f5f..eca2d4b 100644
--- a/debian/ifplugd.action
+++ b/debian/ifplugd.action
@@ -20,8 +20,11 @@
set -e
case "$2" in
-up|down)
- run-parts --exit-on-error --arg="$1" --arg="$2" /etc/ifplugd/action.d/
+up)
+ run-parts --arg="$1" --arg="$2" /etc/ifplugd/action.d/
+ ;;
+down)
+ run-parts --reverse --arg="$1" --arg="$2" /etc/ifplugd/action.d/
;;
*)
echo "ifplugd.action: Incorrect action argument" >&2
diff --git a/debian/ifplugd.init b/debian/ifplugd.init
index ee87993..19dd442 100644
--- a/debian/ifplugd.init
+++ b/debian/ifplugd.init
@@ -47,6 +47,8 @@ shift
[ "x$INTERFACES" = "xauto" -o "x$INTERFACES" = "xall" ] && INTERFACES="`cat /proc/net/dev | awk '{ print $1 }' | egrep '^(eth|wlan)' | cut -d: -f1`"
+[ "$INTERFACES" ] || exit 0
+
case "$VERB" in
start)
echo -n "Starting Network Interface Plugging Daemon:"
diff --git a/debian/ifplugd.udev.agent b/debian/ifplugd.udev.agent
index 60a232c..0d3b9a1 100644
--- a/debian/ifplugd.udev.agent
+++ b/debian/ifplugd.udev.agent
@@ -1,59 +1,90 @@
#!/bin/sh
# udev agent script
-DAEMON_NAME=ifplugd
-
-DAEMON=/usr/sbin/$DAEMON_NAME
-CFG=/etc/default/$DAEMON_NAME
-
-[ -x $DAEMON ] || exit 0
-
HOTPLUGFUNCS=/lib/udev/hotplug.functions
-
[ -f $HOTPLUGFUNCS ] || exit 1
. $HOTPLUGFUNCS
-DEBUG=yes export DEBUG
-[ "$INTERFACE" ] || { mesg Bad invocation: \$INTERFACE is not set ; exit 1 ; }
+if [ -z "$INTERFACE" ]; then
+ mesg Bad invocation: \$INTERFACE is not set
+ exit 1
+fi
-[ -f $CFG ] || { mesg No $DAEMON_NAME configuration file ; exit 1 ; }
-. $CFG
+DAEMON_NAME=ifplugd
+DAEMON=/usr/sbin/$DAEMON_NAME
+if [ ! -x $DAEMON ]; then
+ mesg No $DAEMON_NAME executable: $DAEMON
+ exit 1
+fi
-# return true (0) if interface from list $1 is in list $2
+CFG=/etc/default/$DAEMON_NAME
+if [ -f $CFG ]; then
+ . $CFG
+else
+ mesg No $DAEMON_NAME configuration file
+ exit 1
+fi
+
+# return true (0) if searchifc ($1) is in argument list ($@)
# return false (1) otherwise
search_interfaces () {
- for IF in $2 ; do
- for SEARCH_IF in $1 ; do
- if [ "$SEARCH_IF" = "$IF" ] ; then
- return 0
- fi
- done
+ searchifc=$1
+ shift
+
+ for i in $@; do
+ if [ "$i" = "$searchifc" ] || [ "$i" = "all" ]; then
+ return 0
+ fi
done
+
return 1
}
-IFPLUGD=/usr/sbin/ifplugd
-test -x $IFPLUGD || exit 0
-
-search_interfaces "$INTERFACE" "$INTERFACES"
-if [ $? -gt 0 ] ; then
- # Interface isn't statically managed by ifplugd
- search_interfaces "all $INTERFACE" "$HOTPLUG_INTERFACES"
- if [ $? -eq 0 ] ; then
- # Interface is in hotplug allowed list
- case $ACTION in
- add|register)
- debug_mesg Invoking $DAEMON_NAME for $INTERFACE
- IF1=$(echo $INTERFACE | sed "s/-/_/")
- A=$(eval echo \$\{ARGS_${IF1}\})
- [ -z "$A" ] && A="$ARGS"
- exec $IFPLUGD -i $INTERFACE $A &
- ;;
- remove|unregister)
- debug_mesg Stopping $DAEMON_NAME for $INTERFACE
- exec $IFPLUGD -k --wait-on-kill -i $INTERFACE &
- ;;
- esac
- break
+# wait for networking to be available, taken from net.agent (ifupdown)
+wait_for_interface () {
+ waitifc=$1
+
+ while :; do
+ ifcstate="$(cat /sys/class/net/${waitifc}/operstate 2>/dev/null || true)"
+ if [ "$ifcstate" != down ]; then
+ return 0
+ fi
+ sleep 1
+ done
+}
+
+ifplugd_daemon () {
+ search_interfaces "$INTERFACE" $INTERFACES
+ if [ $? -gt 0 ]; then
+ # Interface isn't statically managed by ifplugd
+ search_interfaces "$INTERFACE" $HOTPLUG_INTERFACES
+ if [ $? -eq 0 ]; then
+ # Interface is in hotplug allowed list
+ case "$ACTION" in
+ add|register)
+ debug_mesg Invoking $DAEMON_NAME for $INTERFACE
+
+ # check for interface specific arguments
+ IF1=$(echo $INTERFACE | sed "s/-/_/")
+ A=$(eval echo \$\{ARGS_${IF1}\})
+ [ -z "$A" ] && A="$ARGS"
+
+ # wait for loopback interface to exist, we may have
+ # been invoked very early in boot sequence
+ wait_for_interface lo
+
+ # spawn ifplugd daemon
+ exec $DAEMON -i $INTERFACE $A
+ ;;
+ remove|unregister)
+ debug_mesg Stopping $DAEMON_NAME for $INTERFACE
+
+ # kill a running ifplugd daemon
+ exec $DAEMON -k -i $INTERFACE
+ ;;
+ esac
+ fi
fi
-fi
+}
+
+ifplugd_daemon &