]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/convert-dns-settings
fe4089ca3e3bf9623b999ff6c6a7cfbdb075ba48
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
25 # Array to store all found DNS servers.
28 # Loop through all PPP profiles
30 for file in /var
/ipfire
/ethernet
/settings
/var
/ipfire
/dns
/settings
/var
/ipfire
/ppp
/settings-
*; do
31 if [ -s "${file}" ]; then
33 eval $
(/usr
/local
/bin
/readhash
"${file}")
35 # Add the DNS servers to the array of SERVERS
37 for var
in DNS0 DNS1 DNS2
; do
38 SERVERS
+=( "${!var}" )
41 # Remove DNS0, DNS1 and DNS2 settings from profile file
42 sed -i "/^DNS[012]=/d" "${file}"
48 for server
in $
(printf "%s\n" "${SERVERS[@]}" |
sort -u); do
49 if [ -n "${server}" ]; then
50 echo "${i},${server},,enabled,"
53 done > /var
/ipfire
/dns
/servers
55 # Empty the old settings file
56 : > /var
/ipfire
/dns
/settings
58 # Disable using ISP name servers when we already have some configured
59 if [ ${i} -gt 3 ]; then
60 echo "USE_ISP_NAMESERVERS=off" \
61 >> /var
/ipfire
/dns
/settings
65 # Set correct ownership.
66 chown nobody
:nobody
/var
/ipfire
/dns
/settings
68 # Convert old unbound settings file
69 if [ -e "/etc/sysconfig/unbound" ]; then
71 local ENABLE_SAFE_SEARCH
75 eval $
(/usr
/local
/bin
/readhash
/etc
/sysconfig
/unbound
)
78 if [ "${ENABLE_SAFE_SEARCH}" = "on" ]; then
79 echo "ENABLE_SAFE_SEARCH=${ENABLE_SAFE_SEARCH}" \
80 >> /var
/ipfire
/dns
/settings
84 if [ "${FORCE_TCP}" = "on" ]; then
85 echo "PROTO=TCP" >> /var
/ipfire
/dns
/settings
88 # Run in recursor mode
89 if [ "${USE_FORWARDERS}" = "0" ]; then
91 : > /var
/ipfire
/dns
/servers
94 rm -f "/etc/sysconfig/unbound"
97 # Set correct ownership.
98 chown nobody
:nobody
/var
/ipfire
/dns
/servers
100 # Make DHCP leases readable for nobody
101 chmod 644 /etc
/unbound
/dhcp-leases.conf