fs/tar: make --no-recursion effective
[buildroot-gz.git] / package / busybox / udhcpc.script
blobad110d3a7fb642d9a71aded22cafd92134688325
1 #!/bin/sh
3 # udhcpc script edited by Tim Riker <Tim@Rikers.org>
5 [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
7 RESOLV_CONF="/etc/resolv.conf"
8 [ -e $RESOLV_CONF ] || touch $RESOLV_CONF
9 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
10 [ -n "$subnet" ] && NETMASK="netmask $subnet"
12 case "$1" in
13 deconfig)
14 /sbin/ifconfig $interface up
15 /sbin/ifconfig $interface 0.0.0.0
17 # drop info from this interface
18 # resolv.conf may be a symlink to /tmp/, so take care
19 TMPFILE=$(mktemp)
20 grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE
21 cat $TMPFILE > $RESOLV_CONF
22 rm -f $TMPFILE
24 if [ -x /usr/sbin/avahi-autoipd ]; then
25 /usr/sbin/avahi-autoipd -k $interface
29 leasefail|nak)
30 if [ -x /usr/sbin/avahi-autoipd ]; then
31 /usr/sbin/avahi-autoipd -wD $interface --no-chroot
35 renew|bound)
36 if [ -x /usr/sbin/avahi-autoipd ]; then
37 /usr/sbin/avahi-autoipd -k $interface
39 /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
41 if [ -n "$router" ] ; then
42 echo "deleting routers"
43 while route del default gw 0.0.0.0 dev $interface 2> /dev/null; do
45 done
47 for i in $router ; do
48 route add default gw $i dev $interface
49 done
52 # drop info from this interface
53 # resolv.conf may be a symlink to /tmp/, so take care
54 TMPFILE=$(mktemp)
55 grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE
56 cat $TMPFILE > $RESOLV_CONF
57 rm -f $TMPFILE
59 # prefer rfc3359 domain search list (option 119) if available
60 if [ -n "$search" ]; then
61 search_list=$search
62 elif [ -n "$domain" ]; then
63 search_list=$domain
66 [ -n "$search_list" ] &&
67 echo "search $search_list # $interface" >> $RESOLV_CONF
69 for i in $dns ; do
70 echo adding dns $i
71 echo "nameserver $i # $interface" >> $RESOLV_CONF
72 done
74 esac
76 HOOK_DIR="$0.d"
77 for hook in "${HOOK_DIR}/"*; do
78 [ -f "${hook}" -a -x "${hook}" ] || continue
79 "${hook}" "${@}"
80 done
82 exit 0