add system files
[GitHub/Stricted/sm-g903f-system.git] / etc / dhcpcd / dhcpcd-hooks / 20-dns.conf
1 # Set net.<iface>.dnsN properties that contain the
2 # DNS server addresses given by the DHCP server.
3
4 if [[ $interface == p2p* ]]
5 then
6 intf=p2p
7 else
8 intf=$interface
9 fi
10
11 set_dns_props()
12 {
13 case "${new_domain_name_servers}" in
14 "") return 0;;
15 esac
16
17 count=1
18 for i in 1 2 3 4; do
19 setprop dhcp.${intf}.dns${i} ""
20 done
21
22 count=1
23 for dnsaddr in ${new_domain_name_servers}; do
24 setprop dhcp.${intf}.dns${count} ${dnsaddr}
25 count=$(($count + 1))
26 done
27
28 separator=" "
29 if [ -z "$new_domain_name" ]; then
30 separator=""
31 else
32 if [ -z "$new_domain_search" ]; then
33 separator=""
34 fi
35 fi
36 setprop dhcp.${interface}.domain "${new_domain_name}$separator${new_domain_search}"
37 }
38
39 unset_dns_props()
40 {
41 for i in 1 2 3 4; do
42 setprop dhcp.${intf}.dns${i} ""
43 done
44
45 setprop dhcp.${interface}.domain ""
46 }
47
48 case "${reason}" in
49 BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_dns_props;;
50 EXPIRE|FAIL|IPV4LL|RELEASE|STOP) unset_dns_props;;
51 esac