]>
git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - src/initscripts/networking/any
2 ########################################################################
5 # Description : ANY Device Script
7 # Authors : Nathan Coulson - nathan@linuxfromscratch.org
8 # Kevin P. Fleming - kpfleming@linuxfromscratch.org
9 # Michael Tremer - mitch@ipfire.org
10 # Maniacikarus - maniacikarus@ipfire.org
16 ########################################################################
20 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
22 if [ "$(basename $0)" == "green" ]; then
24 ADDRESS
="${GREEN_ADDRESS}"
25 NETADDRESS
="${GREEN_NETADDRESS}"
26 NETMASK
="${GREEN_NETMASK}"
29 elif [ "$(basename $0)" == "blue" ]; then
31 ADDRESS
="${BLUE_ADDRESS}"
32 NETADDRESS
="${BLUE_NETADDRESS}"
33 NETMASK
="${BLUE_NETMASK}"
36 elif [ "$(basename $0)" == "orange" ]; then
37 DEVICE
="${ORANGE_DEV}"
38 ADDRESS
="${ORANGE_ADDRESS}"
39 NETADDRESS
="${ORANGE_NETADDRESS}"
40 NETMASK
="${ORANGE_NETMASK}"
41 DEVICE
="${ORANGE_DEV}"
45 if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then
46 PREFIX
=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-`
47 args
="${args} ${ADDRESS}/${PREFIX}"
49 boot_mesg
"ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE}
57 boot_mesg
"Bringing up the ${DEVICE} interface..."
60 # Check if an interface is there...
61 if ip link show
${DEVICE} > /dev
/null
2>&1; then
62 link_status
=`ip link show ${DEVICE} 2> /dev/null`
63 if [ -n "${link_status}" ]; then
64 if ! echo "${link_status}" |
grep -q UP
; then
65 ip link
set ${DEVICE} up
69 boot_mesg
"Interface ${DEVICE} doesn't exist." ${FAILURE}
75 if [ -n "${MTU}" ]; then
76 if ! ip link
set dev
"${DEVICE}" mtu
"${MTU}" &>/dev
/null
; then
77 boot_mesg
"Could not set MTU of ${MTU} to ${DEVICE}..."
82 # Create & Enable vnstat data collection
83 /usr
/bin
/vnstat
-u -i ${DEVICE} -r --enable --force > /dev
/null
2>&1
85 if [ ! "${ADDRESS}" == "1.1.1.1" ]; then
86 boot_mesg
"Adding IPv4 address ${ADDRESS} to the ${DEVICE} interface..."
87 ip addr add
${args} dev
${DEVICE}
93 if [ ! "${ADDRESS}" == "1.1.1.1" ]; then
94 boot_mesg
"Removing IPv4 addresses from the ${DEVICE} interface..."
95 ip addr flush dev
${DEVICE}
99 # Disable vnstat collection
100 /usr
/bin
/vnstat
-u -i ${DEVICE} -r --disable > /dev
/null
2>&1