bzr branch
http://bzr.recompile.se/loggerhead/mandos/release
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
1 |
#!/bin/sh
|
2 |
#
|
|
3 |
# This is an example of a Mandos client network hook. This hook
|
|
4 |
# brings up a bridge interface as specified in a separate
|
|
5 |
# configuration file. To be used, this file and any needed
|
|
6 |
# configuration file(s) should be copied into the
|
|
7 |
# /etc/mandos/network-hooks.d directory.
|
|
8 |
#
|
|
9 |
# Copying and distribution of this file, with or without modification,
|
|
10 |
# are permitted in any medium without royalty provided the copyright
|
|
11 |
# notice and this notice are preserved. This file is offered as-is,
|
|
12 |
# without any warranty.
|
|
13 |
||
14 |
set -e |
|
15 |
||
16 |
CONFIG="$MANDOSNETHOOKDIR/bridge.conf" |
|
17 |
||
18 |
# Read config file, which must set "BRIDGE", "PORTS", and optionally
|
|
19 |
# "IPADDRS" and "ROUTES".
|
|
20 |
if [ -e "$CONFIG" ]; then |
|
21 |
. "$CONFIG" |
|
22 |
fi
|
|
23 |
||
24 |
if [ -z "$BRIDGE" -o -z "$PORTS" ]; then |
|
25 |
exit |
|
26 |
fi
|
|
27 |
||
28 |
if [ -n "$DEVICE" -a "$DEVICE" != "$BRIDGE" ]; then |
|
29 |
exit |
|
30 |
fi
|
|
31 |
||
237.16.21
by Teddy Hogeborn
* network-hooks.d/bridge: Bug fix - really find brctl. |
32 |
for b in /sbin/brctl /usr/sbin/brctl; do |
33 |
if [ -e "$b" ]; then |
|
34 |
brctl="$b" |
|
237.16.20
by Teddy Hogeborn
* network-hooks.d/bridge: Look for both /sbin/brctl and /usr/sbin/brctl. |
35 |
break |
36 |
fi |
|
37 |
done
|
|
38 |
||
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
39 |
case "$1" in |
40 |
start) |
|
237.16.22
by Teddy Hogeborn
* network-hooks.d/bridge: Bug fix - use the found brctl. |
41 |
"$brctl" addbr "$BRIDGE" |
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
42 |
for port in $PORTS; do |
237.16.22
by Teddy Hogeborn
* network-hooks.d/bridge: Bug fix - use the found brctl. |
43 |
"$brctl" addif "$BRIDGE" "$port" |
237.17.1
by teddy at recompile
Add wireless network hook |
44 |
ip link set dev "$port" up |
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
45 |
done |
237.17.1
by teddy at recompile
Add wireless network hook |
46 |
ip link set dev "$BRIDGE" up |
237.16.23
by Teddy Hogeborn
* network-hooks.d/bridge: Bug fix - take up (and down) the bound |
47 |
sleep "$DELAY" |
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
48 |
if [ -n "$IPADDRS" ]; then |
49 |
for ipaddr in $IPADDRS; do |
|
50 |
ip addr add "$ipaddr" dev "$BRIDGE" |
|
51 |
done |
|
52 |
fi |
|
53 |
if [ -n "$ROUTES" ]; then |
|
54 |
for route in $ROUTES; do |
|
55 |
ip route add "$route" dev "$BRIDGE" |
|
56 |
done |
|
57 |
fi |
|
58 |
;; |
|
59 |
stop) |
|
237.17.1
by teddy at recompile
Add wireless network hook |
60 |
ip link set dev "$BRIDGE" down |
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
61 |
for port in $PORTS; do |
237.17.1
by teddy at recompile
Add wireless network hook |
62 |
ip link set dev "$port" down |
237.16.22
by Teddy Hogeborn
* network-hooks.d/bridge: Bug fix - use the found brctl. |
63 |
"$brctl" delif "$BRIDGE" "$port" |
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
64 |
done |
237.16.22
by Teddy Hogeborn
* network-hooks.d/bridge: Bug fix - use the found brctl. |
65 |
"$brctl" delbr "$BRIDGE" |
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
66 |
;; |
67 |
files) |
|
68 |
echo /bin/ip |
|
237.16.20
by Teddy Hogeborn
* network-hooks.d/bridge: Look for both /sbin/brctl and /usr/sbin/brctl. |
69 |
echo "$brctl" |
237.16.14
by teddy at bsnet
Hooks take new "modules" argument, and hook names can contain periods. |
70 |
;; |
71 |
modules) |
|
72 |
echo bridge |
|
237.16.10
by Teddy Hogeborn
* network-hooks.d: New directory. |
73 |
;; |
74 |
esac
|