Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #!/bin/sh
  2. # udhcpc script edited by Tim Riker <Tim at Rikers.org>
  3. [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
  4. RESOLV_CONF="/etc/resolv.conf"
  5. [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
  6. [ -n "$subnet" ] && NETMASK="netmask $subnet"
  7. # return 0 if root is mounted on a network filesystem
  8. root_is_nfs() {
  9. grep -qe '^/dev/root.*\(nfs\|smbfs\|ncp\|coda\) .*' /proc/mounts
  10. }
  11. have_bin_ip=0
  12. if [ -x /bin/ip ]; then
  13. have_bin_ip=1
  14. fi
  15. case "$1" in
  16. deconfig)
  17. if ! root_is_nfs ; then
  18. if [ $have_bin_ip -eq 1 ]; then
  19. ip addr flush dev $interface
  20. ip link set dev $interface up
  21. else
  22. /sbin/ifconfig $interface 0.0.0.0
  23. fi
  24. fi
  25. ;;
  26.  
  27. renew|bound)
  28. if [ $have_bin_ip -eq 1 ]; then
  29. ip addr add dev $interface local $ip/$mask $BROADCAST
  30. else
  31. /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
  32. fi
  33.  
  34. if [ -n "$router" ] ; then
  35. if ! root_is_nfs ; then
  36. if [ $have_bin_ip -eq 1 ]; then
  37. while ip route del default 2>/dev/null ; do
  38. :
  39. done
  40. else
  41. while route del default gw 0.0.0.0 dev $interface 2>/dev/null ; do
  42. :
  43. done
  44. fi
  45. fi
  46. metric=0
  47. for i in $router ; do
  48. if [ $have_bin_ip -eq 1 ]; then
  49. ip route add default via $i metric $((metric++))
  50. else
  51. route add default gw $i dev $interface metric $((metric++)) 2>/dev/null
  52. fi
  53. done
  54. fi
  55. echo -n > $RESOLV_CONF
  56. [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
  57. for i in $dns ; do
  58. echo adding dns $i
  59. echo nameserver $i >> $RESOLV_CONF
  60. done
  61. ;;
  62. esac
  63. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement