summaryrefslogtreecommitdiffstats
path: root/ifplugd/netcfg.action
blob: cb8ad7fc808b8f65f406964b89e7e527964f48ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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