summaryrefslogtreecommitdiffstats
path: root/src.usr/share/udhcpc/default.script
blob: e88ccef453dd4c78831b9bee4d23c9b8ff3e8870 (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
#!/bin/sh

route()
{
	local cmd="${1}"
	local tgt="${2}"
	shift 2

	if [ -x /sbin/ip ]; then
		/sbin/ip route "${cmd}" "${tgt}" via "${@}"
	elif [ -x /sbin/route ]; then
		/sbin/route "${cmd}" "${tgt}" gw "${@}"
	fi
}

case "${1}" in
	'deconfig')
		/sbin/ifconfig "${interface}" 0.0.0.0
		;;
	'renew' | 'bound')
		/sbin/ifconfig "${interface}" "${ip}" \
			${broadcast+broadcast ${broadcast}} \
			${netmask+netmask ${netmask}}
		if [ "x${router+set}" = 'xset' ]; then
			while route del default 0.0.0.0 dev "${interface}" \
					2>/dev/null; do
				:
			done
			for router in ${router}; do
				route add default "${router}" dev "${interface}"
			done
		fi
		exec 3>'/etc/resolv.conf'
		if [ "x${domain+set}" = 'xset' ]; then
			printf 'search %s\n' "${domain}" >&3
		fi
		for dns in ${dns}; do
			printf 'nameserver %s\n' "${dns}" >&3
		done
		exec 3>&-
		;;
esac

exit 0