fcgi: moved to github
[openwrt.org/packages.git] / ipv6 / wide-dhcpv6 / files / dhcp6c-dnsmasq.hotplug
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
#!/bin/sh

. /lib/functions.sh

getoption() {
	local cfg=$1
	config_get resolvfile "$cfg" resolvfile
}

config_load dhcp6c

local dns 
config_get dns basic dns none
[ $dns != "dnsmasq" ] && return 0

if [ "$ACTION" = "start" ]; then

	local domain_name_servers
	config_get domain_name_servers state domain_name_servers

	if [ -n "$domain_name_servers" ]; then

		config_load dhcp
	
		local resolvfile
		config_foreach getoption dnsmasq

		if [ -n "$resolvfile" ]; then

			cp -pf $resolvfile "$resolvfile.dhcp6c_backup"
	
			for nameserver in $domain_name_servers; do
				echo nameserver $nameserver >> $resolvfile
			done

		fi
	
	fi

fi

if [ "$ACTION" = "stop" ]; then

	config_load dhcp

	local resolvfile
	config_foreach getoption dnsmasq
	if [ -f "$resolvfile.dhcp6c_backup" ]; then
		mv -f "$resolvfile.dhcp6c_backup" $resolvfile
	fi 

fi


comments