2011-04-26 12:26:24 +02:00
|
|
|
#!/bin/bash
|
2011-04-27 19:48:38 +02:00
|
|
|
# Copyright (c) 2003-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
2011-04-26 12:26:24 +02:00
|
|
|
# Copyright (c) 2003-2009 by Davide Madrisan <davide.madrisan@gmail.com>
|
|
|
|
|
|
|
|
. /etc/sysconfig/rc
|
|
|
|
. $rc_functions
|
|
|
|
. $rc_networkfunctions
|
|
|
|
|
|
|
|
DEVICE=${1}
|
|
|
|
|
|
|
|
[ "${DEVICE}" ] || exit 1
|
|
|
|
|
|
|
|
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
|
2011-04-27 19:48:38 +02:00
|
|
|
[ -r $network_devices/ifcfg-${DEVICE} ] && . $network_devices/ifcfg-${DEVICE}
|
2011-04-26 12:26:24 +02:00
|
|
|
|
|
|
|
[ "$2" = "--udev" -a "$ONBOOT" != "yes" -a "$ONBOOT" != "1" -a "$ONBOOT" != "true" ] \
|
|
|
|
&& exit 0
|
|
|
|
|
|
|
|
# udev boot: exit if root filesystem is read only
|
|
|
|
[ "$2" = "--udev" -a ! -w /var/run ] && exit 0
|
|
|
|
|
|
|
|
if [ -x $network_devices/ifup-${DEVICE} ]; then
|
|
|
|
$network_devices/ifup-${DEVICE}
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -r $network_devices/ifup-wireless ] && . $network_devices/ifup-wireless
|
|
|
|
|
|
|
|
if [ "$BOOTPROTO" = "dhcp" ]; then
|
|
|
|
if [ ! -r /var/run/dhclient.${DEVICE}.pid ]; then
|
|
|
|
echo -n "Bringing up the ${DEVICE} interface: "
|
|
|
|
/sbin/ifconfig ${DEVICE} up
|
|
|
|
dhclient -q ${DEVICE} -nw -pf /var/run/dhclient.${DEVICE}.pid >/dev/null
|
|
|
|
evaluate_retval
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo -n "Error: dhclient is already running for the interface"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
[ "$IPADDR" ] || IPADDR=$IP
|
|
|
|
|
|
|
|
if [ "$IPADDR" ]; then
|
|
|
|
if [ -z "$NETMASK" ]; then
|
|
|
|
echo "\
|
2011-04-27 19:48:38 +02:00
|
|
|
NETMASK variable missing in ifcfg-${DEVICE}, echo using 255.255.255.0"
|
2011-04-26 12:26:24 +02:00
|
|
|
NETMASK=255.255.255.0
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ "$BROADCAST" ] || eval `/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}`
|
|
|
|
|
|
|
|
echo -n "Bringing up the ${DEVICE} interface: "
|
|
|
|
/sbin/ifconfig ${DEVICE} $IPADDR netmask $NETMASK broadcast $BROADCAST
|
|
|
|
evaluate_retval
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
# if IPADDR is missing interface is brought up anyway without address
|
|
|
|
echo -n "Bringing up the ${DEVICE} interface with no address: "
|
|
|
|
/sbin/ifconfig ${DEVICE} up
|
|
|
|
evaluate_retval
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$ETHTOOL_OPTS" ] ; then
|
|
|
|
/usr/sbin/ethtool -s ${DEVICE} $ETHTOOL_OPTS
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$GATEWAY_IF" = "${DEVICE}" && -n "$GATEWAY" ]]; then
|
|
|
|
echo -n "Setting up default gateway: "
|
|
|
|
route add default gateway $GATEWAY metric 1 dev $GATEWAY_IF
|
|
|
|
evaluate_retval
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -r $network_devices/ifup-routes ] && . $network_devices/ifup-routes ${DEVICE}
|
|
|
|
|
|
|
|
exit 0
|