/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

  • Committer: Teddy Hogeborn
  • Date: 2011-12-21 17:16:00 UTC
  • mto: This revision was merged to the branch mainline in revision 527.
  • Revision ID: teddy@recompile.se-20111221171600-riv7zgtnb3rojcfl
* mandos (main): Handle EOFError when reading state file.

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 | sed -e 's,.*/\([^/]*\)/[^/]*,\1,'
20
 
}
21
 
 
22
 
# Read config file, which must set "BRIDGE", "PORT_ADDRESSES", and
23
 
# optionally "IPADDRS" and "ROUTES".
 
18
# Read config file, which must set "BRIDGE", "PORTS", and optionally
 
19
# "IPADDRS" and "ROUTES".
24
20
if [ -e "$CONFIG" ]; then
25
21
    . "$CONFIG"
26
22
fi
27
23
 
28
 
if [ -z "$BRIDGE" -o -z "$PORT_ADDRESSES" ]; then
 
24
if [ -z "$BRIDGE" -o -z "$PORTS" ]; then
29
25
    exit
30
26
fi
31
27
 
43
39
case "$1" in
44
40
    start)
45
41
        "$brctl" addbr "$BRIDGE"
46
 
        for address in $PORT_ADDRESSES; do
47
 
            interface=`addrtoif "$address"`
48
 
            "$brctl" addif "$BRIDGE" "$interface"
49
 
            ip link set dev "$interface" up
 
42
        for port in $PORTS; do
 
43
            "$brctl" addif "$BRIDGE" "$port"
 
44
            ip link set up "$port"
50
45
        done
51
 
        ip link set dev "$BRIDGE" up
 
46
        ip link set up "$BRIDGE"
52
47
        sleep "$DELAY"
53
48
        if [ -n "$IPADDRS" ]; then
54
49
            for ipaddr in $IPADDRS; do
62
57
        fi
63
58
        ;;
64
59
    stop)
65
 
        ip link set dev "$BRIDGE" down
66
 
        for address in $PORT_ADDRESSES; do
67
 
            interface=`addrtoif "$address"`
68
 
            ip link set dev "$interface" down
69
 
            "$brctl" delif "$BRIDGE" "$interface"
 
60
        ip link set down "$BRIDGE"
 
61
        for port in $PORTS; do
 
62
            ip link set down "$port"
 
63
            "$brctl" delif "$BRIDGE" "$port"
70
64
        done
71
65
        "$brctl" delbr "$BRIDGE"
72
66
        ;;