default.script 664 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. if [[ -z $1 ]]; then
  3. echo "Error: should be run by udhcpc"
  4. exit 1
  5. fi
  6. RESOLV_CONF=/tmp/resolv.conf
  7. case $1 in
  8. (deconfig)
  9. ip addr flush $interface
  10. ;;
  11. (renew|bound)
  12. ip addr add $ip/${mask:-24} brd + dev $interface
  13. if [[ -n $router ]]; then
  14. echo "deleting routers"
  15. while ip route del default >&- 2>&-; do :; done
  16. for i in $router; do
  17. echo "adding router $i"
  18. ip route add to default via $i
  19. done
  20. fi
  21. echo -n >$RESOLV_CONF
  22. ${domain:+echo search $domain} >>$RESOLV_CONF
  23. for i in $dns; do
  24. echo "adding dns $i"
  25. echo "nameserver $i" >>$RESOLV_CONF
  26. done
  27. # user rules
  28. [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
  29. ;;
  30. esac
  31. exit $?