You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB

2 years ago
  1. #!/bin/sh
  2. # Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert.
  3. #
  4. # Based on the busybox example scripts and the old udhcp source
  5. # package default.* scripts.
  6. RESOLV_CONF="/etc/resolv.conf"
  7. case $1 in
  8. bound|renew)
  9. [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
  10. [ -n "$subnet" ] && NETMASK="netmask $subnet"
  11. /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
  12. if [ -n "$router" ]; then
  13. echo "$0: Resetting default routes"
  14. while /sbin/route del default gw 0.0.0.0 dev $interface; do :; done
  15. metric=0
  16. for i in $router; do
  17. /sbin/route add default gw $i dev $interface metric $metric
  18. metric=$(($metric + 1))
  19. done
  20. fi
  21. # Update resolver configuration file
  22. R=""
  23. [ -n "$domain" ] && R="domain $domain
  24. "
  25. for i in $dns; do
  26. echo "$0: Adding DNS $i"
  27. R="${R}nameserver $i
  28. "
  29. done
  30. if [ -x /sbin/resolvconf ]; then
  31. echo -n "$R" | resolvconf -a "${interface}.udhcpc"
  32. else
  33. echo -n "$R" > "$RESOLV_CONF"
  34. fi
  35. ;;
  36. deconfig)
  37. if [ -x /sbin/resolvconf ]; then
  38. resolvconf -d "${interface}.udhcpc"
  39. fi
  40. /sbin/ifconfig $interface 0.0.0.0
  41. ;;
  42. leasefail)
  43. echo "$0: Lease failed: $message"
  44. ;;
  45. nak)
  46. echo "$0: Received a NAK: $message"
  47. ;;
  48. *)
  49. echo "$0: Unknown udhcpc command: $1";
  50. exit 1;
  51. ;;
  52. esac