1 | #!/bin/sh
|
---|
2 | ########################################################################
|
---|
3 | # Begin /lib/services/bridge
|
---|
4 | #
|
---|
5 | # Description : Bridge Boot Script
|
---|
6 | #
|
---|
7 | # Authors : Nathan Coulson - nathan@linuxfromscratch.org
|
---|
8 | # Bruce Dubbs - bdubbs@linuxfromscratch.org
|
---|
9 | #
|
---|
10 | # Version : LFS-7.0
|
---|
11 | #
|
---|
12 | ########################################################################
|
---|
13 |
|
---|
14 | . /lib/lsb/init-functions
|
---|
15 |
|
---|
16 | if [ -z ${1} ] ; then
|
---|
17 | log_failure_msg "No ifconfig file specified"
|
---|
18 | exit 1
|
---|
19 | fi
|
---|
20 | IFCONFIG=$1
|
---|
21 | . ${IFCONFIG}
|
---|
22 |
|
---|
23 | # Call the bridge ${BRIDGE_IF} for clarity.
|
---|
24 | if [ -z ${BRIDGE_IF} ]; then
|
---|
25 | log_failure_msg "BRIDGE_IF variable missing from ${IFCONFIG}"
|
---|
26 | exit 1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | case "${2}" in
|
---|
30 | up)
|
---|
31 | log_info_msg2 "\n"
|
---|
32 | log_info_msg "Creating the ${BRIDGE_IF} interface..."
|
---|
33 | brctl addbr ${BRIDGE_IF}
|
---|
34 | ip link set ${BRIDGE_IF} up
|
---|
35 | evaluate_retval
|
---|
36 | for PHY in ${PHYS}; do
|
---|
37 | log_info_msg "Adding ${PHY} to ${BRIDGE_IF}..."
|
---|
38 | brctl addif ${BRIDGE_IF} ${PHY}
|
---|
39 | evaluate_retval
|
---|
40 | done
|
---|
41 |
|
---|
42 | if [ "${IP_FORWARD}" = "y" -o \
|
---|
43 | "${IP_FORWARD}" = "yes" -o \
|
---|
44 | "${IP_FORWARD}" = "t" -o \
|
---|
45 | "${IP_FORWARD}" = "true" -o \
|
---|
46 | "${IP_FORWARD}" = "1" ]; then
|
---|
47 | sysctl -w net.ipv4.ip_forward=1 > /dev/null
|
---|
48 | log_success_msg "Setting net.ipv4.ip_forward = 1"
|
---|
49 | fi
|
---|
50 | ;;
|
---|
51 |
|
---|
52 | down)
|
---|
53 | for PHY in ${PHYS}; do
|
---|
54 | log_info_msg "Removing ${PHY} from ${BRIDGE_IF}..."
|
---|
55 | brctl delif ${BRIDGE_IF} ${PHY}
|
---|
56 | evaluate_retval
|
---|
57 | done
|
---|
58 |
|
---|
59 | log_info_msg "Bringing down the ${BRIDGE_IF} interface..."
|
---|
60 | ip link set ${BRIDGE_IF} down
|
---|
61 | brctl delbr ${BRIDGE_IF}
|
---|
62 | evaluate_retval
|
---|
63 | ;;
|
---|
64 |
|
---|
65 | *)
|
---|
66 | echo "Usage: ${0} <ifconfig-file> {up|down}"
|
---|
67 | exit 1
|
---|
68 | ;;
|
---|
69 | esac
|
---|
70 |
|
---|
71 | # End /lib/services/bridge
|
---|