default.script 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # udhcpc script edited by Tim Riker <Tim@Rikers.org>
  3. RESOLV_CONF="/etc/resolv.conf"
  4. [ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; }
  5. NETMASK=""
  6. [ -n "$subnet" ] && NETMASK="netmask $subnet"
  7. BROADCAST=""
  8. [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
  9. case "$1" in
  10. deconfig)
  11. echo "Setting IP address 0.0.0.0 on $interface"
  12. ifconfig $interface 0.0.0.0
  13. ;;
  14. renew|bound)
  15. echo "Setting IP address $ip on $interface"
  16. ifconfig $interface $ip $NETMASK $BROADCAST
  17. if [ -n "$router" ] ; then
  18. echo "Deleting routers"
  19. while route del default gw 0.0.0.0 dev $interface ; do
  20. :
  21. done
  22. for i in $router ; do
  23. echo "Adding router $i"
  24. route add default gw $i dev $interface
  25. done
  26. fi
  27. echo "Recreating $RESOLV_CONF"
  28. echo -n > $RESOLV_CONF-$$
  29. [ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$
  30. for i in $dns ; do
  31. echo " Adding DNS server $i"
  32. echo "nameserver $i" >> $RESOLV_CONF-$$
  33. done
  34. mv $RESOLV_CONF-$$ $RESOLV_CONF
  35. ;;
  36. esac
  37. exit 0