]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/init.d/networking/any
7d2242954944e193fd6532c89b47864c686d4421
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 BROADCAST
="${GREEN_BROADCAST}"
26 NETADDRESS
="${GREEN_NETADDRESS}"
27 NETMASK
="${GREEN_NETMASK}"
29 elif [ "$(basename $0)" == "blue" ]; then
31 ADDRESS
="${BLUE_ADDRESS}"
32 BROADCAST
="${BLUE_BROADCAST}"
33 NETADDRESS
="${BLUE_NETADDRESS}"
34 NETMASK
="${BLUE_NETMASK}"
36 elif [ "$(basename $0)" == "orange" ]; then
37 DEVICE
="${ORANGE_DEV}"
38 ADDRESS
="${ORANGE_ADDRESS}"
39 BROADCAST
="${ORANGE_BROADCAST}"
40 NETADDRESS
="${ORANGE_NETADDRESS}"
41 NETMASK
="${ORANGE_NETMASK}"
42 DEVICE
="${ORANGE_DEV}"
45 if [ -z "${BROADCAST}" ]; then
46 boot_mesg
"BROADCAST variable missing from input, cannot continue." ${FAILURE}
51 if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then
52 PREFIX
=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-`
53 args
="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}"
55 boot_mesg
"ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE}
63 boot_mesg
"Bringing up the ${DEVICE} interface..."
66 # Check if an interface is there...
67 if ip link show
${DEVICE} > /dev
/null
2>&1; then
68 link_status
=`ip link show ${DEVICE} 2> /dev/null`
69 if [ -n "${link_status}" ]; then
70 if ! echo "${link_status}" |
grep -q UP
; then
71 ip link
set ${DEVICE} up
75 boot_mesg
"Interface ${DEVICE} doesn't exist." ${FAILURE}
80 boot_mesg
"Adding IPv4 address ${ADDRESS} to the ${DEVICE} interface..."
81 ip addr add
${args} dev
${DEVICE}
86 boot_mesg
"Removing IPv4 address ${ADDRESS} from the ${DEVICE} interface..."
87 ip addr del
${args} dev
${DEVICE}