]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/convert-dns-settings
04a5344f7e44de703959b4fc7ba2810cdd906f64
2 ###############################################################################
4 # IPFire.org - A Linux-based firewall #
5 # Copyright (C) 2020 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
23 # Do not convert anything if we already have some servers set
24 if [ ! -s "/var/ipfire/dns/servers" ]; then
26 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
28 if [ -s "/var/ipfire/ppp/settings" ]; then
29 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ppp
/settings
)
31 # Remove DNS, DNS1 and DNS2
32 sed -i "/^DNS[12]?=/d" /var
/ipfire
/ppp
/settings
33 elif [ -s "/var/ipfire/dns/settings" ]; then
34 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/dns
/settings
)
39 for var
in DNS0 DNS1 DNS2
; do
40 if [ -n "${!var}" ]; then
41 echo "${i},${!var},,enabled,"
44 done > /var
/ipfire
/dns
/servers
46 # Empty the old settings file
47 : > /var
/ipfire
/dns
/settings
49 # Disable using ISP name servers when we already have some configured
50 if [ ${i} -gt 3 ]; then
51 echo "USE_ISP_NAMESERVERS=off" \
52 >> /var
/ipfire
/dns
/settings
56 # Set correct ownership.
57 chown nobody
:nobody
/var
/ipfire
/dns
/settings
59 # Convert old unbound settings file
60 if [ -e "/etc/sysconfig/unbound" ]; then
62 local ENABLE_SAFE_SEARCH
66 eval $
(/usr
/local
/bin
/readhash
/etc
/sysconfig
/unbound
)
69 if [ "${ENABLE_SAFE_SEARCH}" = "on" ]; then
70 echo "ENABLE_SAFE_SEARCH=${ENABLE_SAFE_SEARCH}" \
71 >> /var
/ipfire
/dns
/settings
75 if [ "${FORCE_TCP}" = "on" ]; then
76 echo "PROTO=TCP" >> /var
/ipfire
/dns
/settings
79 # Run in recursor mode
80 if [ "${USE_FORWARDERS}" = "0" ]; then
82 : > /var
/ipfire
/dns
/servers
85 rm -f "/etc/sysconfig/unbound"
88 # Set correct ownership.
89 chown nobody
:nobody
/var
/ipfire
/dns
/servers
91 # Make DHCP leases readable for nobody
92 chown
644 /etc
/unbound
/dhcp-leases.conf