/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
#
# This is an example of a Mandos client network hook.  This hook
# brings up a bridge interface as specified in a separate
# configuration file.  To be used, this file and any needed
# configuration file(s) should be copied into the
# /etc/mandos/network-hooks.d directory.
# 
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.

set -e

CONFIG="$MANDOSNETHOOKDIR/bridge.conf"

# Read config file, which must set "BRIDGE", "PORTS", and optionally
# "IPADDRS" and "ROUTES".
if [ -e "$CONFIG" ]; then
    . "$CONFIG"
fi

if [ -z "$BRIDGE" -o -z "$PORTS" ]; then
    exit
fi

if [ -n "$DEVICE" -a "$DEVICE" != "$BRIDGE" ]; then
    exit
fi

case "$1" in
    start)
	/usr/sbin/brctl addbr "$BRIDGE"
	for port in $PORTS; do
	    /usr/sbin/brctl addif "$BRIDGE" "$port"
	done
	ip link set up "$BRIDGE"
	if [ -n "$IPADDRS" ]; then
            for ipaddr in $IPADDRS; do
		ip addr add "$ipaddr" dev "$BRIDGE"
	    done
	fi
	if [ -n "$ROUTES" ]; then
            for route in $ROUTES; do
		ip route add "$route" dev "$BRIDGE"
	    done
	fi
	;;
    stop)
	ip link set down "$BRIDGE"
	for port in $PORTS; do
	    /usr/sbin/brctl delif "$BRIDGE" "$port"
	done
	/usr/sbin/brctl delbr "$BRIDGE"
	;;
    files)
	echo /bin/ip
	echo /usr/sbin/brctl
	;;
    modules)
	echo bridge
	;;
esac