#!/sbin/runscript # Copyright 1999-2002 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License, v2 or later # $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.9 2002/02/15 04:35:43 azarah Exp $ #NB: Config is in /etc/conf.d/net #for pcmcia users. note that pcmcia must be added to the same #runlevel as the net.* script that needs it. depend() { use pcmcia } checkconfig() { if [ -z "`eval echo \$\{iface_${IFACE}\}`" ] then eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set" return 1 fi } start() { checkconfig || return 1 local iface_args="`eval echo \$\{iface_${IFACE}\}`" local dhcp_args="`eval echo \$\{dhcpcd_${IFACE}\}`" local retval=0 ebegin "Bringing ${IFACE} up" if [ "`eval echo \$\{iface_${IFACE}\}`" != "dhcp" ] then /sbin/ifconfig "$IFACE" "$iface_args" >/dev/null 2>&1 || { retval=$? eend $retval return $retval } else /sbin/dhcpcd "$dhcp_args" "$IFACE" >/dev/null 2>&1 || { retval=$? eend $retval return $? } fi if [ -n "`eval echo \$\{alias_${IFACE}\}`" ] then local x="" local num=0 for x in `eval echo \$\{alias_${IFACE}\}` do /sbin/ifconfig "${IFACE}:${num}" "$x" >/dev/null 2>&1 num=$((num + 1)) done save_options alias "`eval echo \$\{alias_${IFACE}\}`" fi if [ -n "$gateway" ] && [ "${gateway%/*}" = "$IFACE" ] then /sbin/route add -net default gw "${gateway#*/}" dev "${gateway%/*}" \ netmask 0.0.0.0 metric 1 >/dev/null 2>&1 || { local error=$? ifconfig "${IFACE}" down >/dev/null 2>&1 eend ${error} return ${error} } fi #enabling rp_filter causes wacky packets to be auto-dropped by #the kernel if [ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter ] then echo 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter fi eend } stop() { local myalias="`get_options alias`" ebegin "Bringing ${IFACE} down" #do some cleanup in case the amount of aliases change if [ -n "$myalias" ] then local x="" local num=0 for x in $myalias do /sbin/ifconfig "${IFACE}:${num}" down >/dev/null 2>1 num=$((num + 1)) done fi /sbin/ifconfig "$IFACE" down >/dev/null 2>&1 eend $? }