#!/sbin/runscript # Writen by guido socher # Distributed under the terms of the GNU General Public License v2 #usedhcp=1 usedhcp=0 usestaticdns=1 depend() { need localmount after bootmisc hostname net.lo } start() { local retval=0 if ethwireck eth0; then einfo "eth0: physical layer up ..." else ewarn "eth0: no wire plugged" return 1 fi if [ "$usedhcp" == "1" ]; then ebegin "eth0: starting dhcpcd" /sbin/dhcpcd -t 10 -p eth0 retval=$? else ebegin "eth0: static config for 10.0.0.5" ifconfig eth0 10.0.0.5 netmask 255.255.255.0 route add default gw 10.0.0.2 fi if [ "${retval}" = "0" ]; then # kill it we don't want it running, the dhcp server in routers # is smart enough to not re-use the same IP as long as we # are on the net if [ -r /var/run/dhcpcd-eth0.pid ]; then kill `cat /var/run/dhcpcd-eth0.pid` fi if [ -f /etc/resolv.conf.flockedns -a "$usestaticdns" == "1" ]; then einfo "eth0: using /etc/resolv.conf.flockedns ..." if [ -f /etc/resolv.conf ]; then mv -f /etc/resolv.conf /etc/resolv.conf.bak fi cp /etc/resolv.conf.flockedns /etc/resolv.conf fi else eend ${retval} "Failed to bring ${IFACE} up" return ${retval} fi eend 0 } stop() { ebegin "Bringing eth0 down" # we killed dhcpcd already above, don't do it here again: #/sbin/dhcpcd -k eth0 #sleep 1 /sbin/ifconfig eth0 down if route -n | egrep -q "^0.0.0.0"; then route del default fi eend 0 } # vim:ts=4 et sw=4