/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to network-hooks.d/bridge

* network-hooks.d/bridge: Bug fix - really find brctl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
CONFIG="$MANDOSNETHOOKDIR/bridge.conf"
17
17
 
18
 
addrtoif(){
19
 
    grep -liFe "$1" /sys/class/net/*/address \
20
 
        | sed -e 's,.*/\([^/]*\)/[^/]*,\1,'
21
 
}
22
 
 
23
 
# Read config file, which must set "BRIDGE", "PORT_ADDRESSES", and
24
 
# optionally "IPADDRS" and "ROUTES".
 
18
# Read config file, which must set "BRIDGE", "PORTS", and optionally
 
19
# "IPADDRS" and "ROUTES".
25
20
if [ -e "$CONFIG" ]; then
26
21
    . "$CONFIG"
27
22
fi
28
23
 
29
 
if [ -z "$BRIDGE" -o -z "$PORT_ADDRESSES" ]; then
 
24
if [ -z "$BRIDGE" -o -z "$PORTS" ]; then
30
25
    exit
31
26
fi
32
27
 
43
38
 
44
39
case "$1" in
45
40
    start)
46
 
        "$brctl" addbr "$BRIDGE"
47
 
        for address in $PORT_ADDRESSES; do
48
 
            interface=`addrtoif "$address"`
49
 
            "$brctl" addif "$BRIDGE" "$interface"
50
 
            ip link set dev "$interface" up
 
41
        /usr/sbin/brctl addbr "$BRIDGE"
 
42
        for port in $PORTS; do
 
43
            /usr/sbin/brctl addif "$BRIDGE" "$port"
51
44
        done
52
 
        ip link set dev "$BRIDGE" up
53
 
        sleep "$DELAY"
 
45
        ip link set up "$BRIDGE"
54
46
        if [ -n "$IPADDRS" ]; then
55
47
            for ipaddr in $IPADDRS; do
56
48
                ip addr add "$ipaddr" dev "$BRIDGE"
63
55
        fi
64
56
        ;;
65
57
    stop)
66
 
        ip link set dev "$BRIDGE" down
67
 
        for address in $PORT_ADDRESSES; do
68
 
            interface=`addrtoif "$address"`
69
 
            ip link set dev "$interface" down
70
 
            "$brctl" delif "$BRIDGE" "$interface"
 
58
        ip link set down "$BRIDGE"
 
59
        for port in $PORTS; do
 
60
            /usr/sbin/brctl delif "$BRIDGE" "$port"
71
61
        done
72
 
        "$brctl" delbr "$BRIDGE"
 
62
        /usr/sbin/brctl delbr "$BRIDGE"
73
63
        ;;
74
64
    files)
75
65
        echo /bin/ip