diff options
author | Rémy Oudompheng <remy@archlinux.org> | 2011-08-20 13:13:35 +0200 |
---|---|---|
committer | Rémy Oudompheng <remy@archlinux.org> | 2011-08-20 13:13:35 +0200 |
commit | 1227a80b24c943438757e933bd568ceddd00479b (patch) | |
tree | e88638495f85726377dfa6cf4279ab31c3f54534 /scripts/ifplugd.action | |
parent | ec0e041a8eab919abef8e3af289c979ee1737382 (diff) | |
download | netctl-1227a80b24c943438757e933bd568ceddd00479b.tar.gz netctl-1227a80b24c943438757e933bd568ceddd00479b.tar.xz |
Reorganize files to match install location closer
Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
Diffstat (limited to 'scripts/ifplugd.action')
-rw-r--r-- | scripts/ifplugd.action | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/ifplugd.action b/scripts/ifplugd.action new file mode 100644 index 0000000..0c081df --- /dev/null +++ b/scripts/ifplugd.action @@ -0,0 +1,54 @@ +#!/bin/sh +# +# ifplugd.action script for netcfg + +. /etc/rc.conf +. /etc/rc.d/functions +. /usr/lib/network/network +shopt -s extglob + +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 ( + load_profile "$profile" + echo "loading $profile" + [[ "$INTERFACE" != "$1" ]] && continue + [[ "$CONNECTION" != @(ethernet|ethernet-iproute) ]] && 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[*]})" + else + for profile in "${preferred_profiles[@]}" "${dhcp_profiles[@]}" "${static_profiles[@]}"; do ( + netcfg "$profile" && exit 1 + exit 0 + ) || exit 0; done + fi + ;; + down) + if check_iface "$1"; then + netcfg -i "$1" && exit 0 + fi + ;; + *) + echo "Wrong arguments" > /dev/stderr + ;; +esac + +exit 1 |