diff options
author | James Rayner <james@archlinux.org> | 2009-10-21 15:18:15 +0200 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2009-10-21 15:18:15 +0200 |
commit | d176d9fa5013a0c4a8b25754cec053c24a0d83d1 (patch) | |
tree | c43da11e9be9238ed87bfbe139f04e5a89e35858 /ifplugd | |
parent | ea1a71895e6b8776cc5f69372836feecbb767df0 (diff) | |
download | netctl-d176d9fa5013a0c4a8b25754cec053c24a0d83d1.tar.gz netctl-d176d9fa5013a0c4a8b25754cec053c24a0d83d1.tar.xz |
Add initial net-auto-wired concept
Diffstat (limited to 'ifplugd')
-rwxr-xr-x | ifplugd/net-auto-wired | 44 | ||||
-rwxr-xr-x | ifplugd/netcfg.action | 41 |
2 files changed, 85 insertions, 0 deletions
diff --git a/ifplugd/net-auto-wired b/ifplugd/net-auto-wired new file mode 100755 index 0000000..79e5beb --- /dev/null +++ b/ifplugd/net-auto-wired @@ -0,0 +1,44 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +CFG=/etc/ifplugd/ifplugd.conf +ACTION=/etc/ifplugd/netcfg.action +PID=$(cat /var/run/ifplugd.$WIRED_INTERFACE) + +# Source ifplugd configuration +[ -f $CFG ] && . $CFG + +case "$1" in + start) + stat_busy "Starting netcfg auto-wired mode for interface ${WIRED_INTERFACE}" + A="`eval echo \$\{ARGS_${WIRED_INTERFACE}\}`" + [ -z "$A" ] && A="$ARGS" + [ -z "$PID" ] && /usr/sbin/ifplugd -i $WIRED_INTERFACE -r $ACTION $A + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon net-auto-wired + stat_done + fi + ;; + stop) + stat_busy "Stopping netcfg auto-wired mode for interface ${WIRED_INTERFACE}" + [ ! -z "$PID" ] && /usr/sbin/ifplugd -k -i $WIRED_INTERFACE -r $ACTION + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon net-auto-wired + stat_done + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 diff --git a/ifplugd/netcfg.action b/ifplugd/netcfg.action new file mode 100755 index 0000000..cb8ad7f --- /dev/null +++ b/ifplugd/netcfg.action @@ -0,0 +1,41 @@ +#!/bin/sh +# +# ifplugd.action script for netcfg + +. /etc/rc.conf +. /etc/rc.d/functions +. /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 + for profile in $(list_profiles); do ( + load_profile $profile + [[ $INTERFACE != $1 ]] && continue + [[ $CONNECTION != @(ethernet|ethernet-iproute) ]] && continue + if [[ $IP == "dhcp" ]]; then + netcfg $profile && exit 0 + fi + ) done + for profile in $(list profiles}; do ( + load_profile $profile + [[ $INTERFACE != $1 ]] && continue + [[ $CONNECTION != "(ethernet|ethernet-iproute)" ]] && continue + netcfg $profile && exit 0 + ) done + exit 1 + ;; + down) + if check_iface $1; then + netcfg -i $1 + fi + ;; + *) + echo "Wrong arguments" > /dev/stderr + ;; +esac + +exit 1 |