busybox/examples/udhcp/simple.script

48 lines
1.0 KiB
Plaintext
Raw Normal View History

2002-10-15 03:11:28 +05:30
#!/bin/sh
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
RESOLV_CONF="/etc/resolv.conf"
2009-04-17 01:34:09 +05:30
NETMASK=""
2002-10-15 03:11:28 +05:30
[ -n "$subnet" ] && NETMASK="netmask $subnet"
2009-04-17 01:34:09 +05:30
BROADCAST="broadcast +"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
2002-10-15 03:11:28 +05:30
case "$1" in
deconfig)
2009-04-17 01:34:09 +05:30
echo "Setting IP address 0.0.0.0 on $interface"
ifconfig $interface 0.0.0.0
2002-10-15 03:11:28 +05:30
;;
renew|bound)
2009-04-17 01:34:09 +05:30
echo "Setting IP address $ip on $interface"
ifconfig $interface $ip $NETMASK $BROADCAST
2002-10-15 03:11:28 +05:30
if [ -n "$router" ] ; then
2009-04-17 01:34:09 +05:30
echo "Deleting routers"
2002-10-15 03:11:28 +05:30
while route del default gw 0.0.0.0 dev $interface ; do
:
done
metric=0
2002-10-15 03:11:28 +05:30
for i in $router ; do
2009-04-17 01:34:09 +05:30
echo "Adding router $i"
route add default gw $i dev $interface metric $((metric++))
2002-10-15 03:11:28 +05:30
done
fi
2009-04-17 01:34:09 +05:30
echo "Recreating $RESOLV_CONF"
echo -n > $RESOLV_CONF-$$
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF-$$
2002-10-15 03:11:28 +05:30
for i in $dns ; do
2009-04-17 01:34:09 +05:30
echo " Adding DNS server $i"
echo nameserver $i >> $RESOLV_CONF-$$
2002-10-15 03:11:28 +05:30
done
2009-04-17 01:34:09 +05:30
mv $RESOLV_CONF-$$ $RESOLV_CONF
2002-10-15 03:11:28 +05:30
;;
esac
exit 0