aboutsummaryrefslogtreecommitdiff
blob: a7a4a522a1440693f06640a9d0c3c8ab744e8f67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

if [ -z "$1" ]
then
	echo "Error: should be called from udhcpc"
	exit 1
fi

case ${1} in
	bound|renew)
		[ -n "$broadcast" ] && BROADCAST="broadcast ${broadcast}"
		[ -n "$subnet" ] && NETMASK="netmask ${subnet}"
		[ -n "$rootpath" ] && echo "${rootpath}" > /rootpath
		[ -n "$hostname" ] && hostname "${hostname}"

		busybox ifconfig "${interface}" ${ip} ${BROADCAST} ${NETMASK}

		if [ -n "${router}" ]
		then
			while busybox route del default gw 0.0.0.0 dev "${interface}" >/dev/null 2>&1
			do
				:
			done

			for i in ${router}
			do
				busybox route add default gw ${i}
			done
		fi

		[ -n "$domain" ] && echo "domain ${domain}" >> /etc/resolv.conf

		if [ -n "${dns}" ]
		then
			for i in ${dns}
			do
				echo "nameserver ${i}" >> /etc/resolv.conf
			done
		fi
	;;
	deconfig|leasefail)
		busybox ifconfig "${interface}" 0.0.0.0
		while busybox route del default dev "${interface}" >/dev/null 2>&1
		do
			:
		done
	;;
	nak)
		echo "nak: ${message}"
	;;
	*)
		echo "unknown option $1" >&2
		echo "Usage: $0 {bound|deconfig|leasefail|nak|renew}" >&2
		exit 1
	;;
esac

exit 0