simple.script 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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="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. metric=0
  23. for i in $router ; do
  24. echo "Adding router $i"
  25. route add default gw $i dev $interface metric $((metric++))
  26. done
  27. fi
  28. echo "Recreating $RESOLV_CONF"
  29. echo -n > $RESOLV_CONF-$$
  30. [ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$
  31. for i in $dns ; do
  32. echo " Adding DNS server $i"
  33. echo "nameserver $i" >> $RESOLV_CONF-$$
  34. done
  35. mv $RESOLV_CONF-$$ $RESOLV_CONF
  36. ;;
  37. esac
  38. exit 0