summaryrefslogtreecommitdiffstats
path: root/src/ifplugd.action
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-12-28 02:38:58 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2012-12-28 02:38:58 +0100
commit4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d (patch)
tree09580c92ca78e8b9b54d7ed8d6b79d7fcd6fd9ff /src/ifplugd.action
parent6737a37e5666837a8f51a2f74bdebdd756151394 (diff)
downloadnetctl-4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d.tar.gz
netctl-4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d.tar.xz
Forking netcfg to netctl (1/2)
This commit contains the moving of files.
Diffstat (limited to 'src/ifplugd.action')
-rwxr-xr-xsrc/ifplugd.action49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/ifplugd.action b/src/ifplugd.action
new file mode 100755
index 0000000..ea3a16c
--- /dev/null
+++ b/src/ifplugd.action
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# ifplugd.action script for netcfg
+
+. /usr/lib/network/network
+
+case "$2" in
+ up)
+ # Look for a dhcp based profile to try first
+ # dhcp can actually outright fail, whereas
+ # it's difficult to tell if static succeeded
+ # Also check profile is same iface and is right connection
+ echo "up"
+ declare -a preferred_profiles
+ declare -a dhcp_profiles
+ declare -a static_profiles
+ for profile in $(list_profiles); do
+ (
+ echo "loading $profile"
+ load_profile "$profile"
+ [[ "$INTERFACE" == "$1" && "$CONNECTION" == "ethernet" ]] || continue
+ checkyesno "${AUTO_WIRED:-no}" && exit 1 # user preferred AUTO profile
+ [[ "$IP" == "dhcp" ]] && exit 2 # dhcp profile
+ exit 3 # static profile
+ )
+ case $? in
+ 1) preferred_profiles+=("$profile");;
+ 2) dhcp_profiles+=("$profile");;
+ 3) static_profiles+=("$profile");;
+ esac
+ done
+ if [[ ${#preferred_profiles[@]} > 1 ]]; then
+ echo "AUTO_WIRED flag for $1 set in more than one profile (${preferred_profiles[*]})"
+ fi
+ for profile in "${preferred_profiles[@]}" "${dhcp_profiles[@]}" "${static_profiles[@]}"; do
+ profile_up "$profile" && exit 0
+ done
+ ;;
+ down)
+ if check_iface "$1"; then
+ interface_down "$1" && exit 0
+ fi
+ ;;
+ *)
+ echo "Wrong arguments" > /dev/stderr
+ ;;
+esac
+
+exit 1