X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=src%2Finitscripts%2Fsystem%2Funbound;fp=src%2Finitscripts%2Fsystem%2Funbound;h=dbcfc951f0d83a0e7870c27f32bf2eec6cc287ef;hp=34b3e06fda5179fdca1b963c0210b213d2d15fff;hb=606efa9c2a1515fdb76e2f710b2237335d1584ce;hpb=cdf1bea72448ac1f5704bd292ae1a5338a856d58;ds=sidebyside diff --git a/src/initscripts/system/unbound b/src/initscripts/system/unbound index 34b3e06fda..dbcfc951f0 100644 --- a/src/initscripts/system/unbound +++ b/src/initscripts/system/unbound @@ -41,6 +41,22 @@ read_name_servers() { done 2>/dev/null | xargs echo } +check_red_has_carrier_and_ip() { + # Interface configured ? + [ ! -e "/var/ipfire/red/iface" ] && return 0; + + # Interface present ? + [ ! -e "/sys/class/net/$( /var/ipfire/red/dns + unbound-control -q forward off + +} + own_hostname() { local hostname=$(hostname -f) # 1.1.1.1 is reserved for unused green, skip this @@ -473,7 +497,8 @@ disable_dnssec() { fix_time_if_dns_fail() { # If DNS still not work try to init ntp with # hardcoded ntp.ipfire.org (81.3.27.46) - if [ -e /var/ipfire/red/active ]; then + check_red_has_carrier_and_ip + if [ -e "/var/ipfire/red/iface" -a "${?}" = "1" ]; then host 0.ipfire.pool.ntp.org > /dev/null 2>&1 if [ "${?}" != "0" ]; then boot_mesg "DNS still not functioning... Trying to sync time with ntp.ipfire.org (81.3.27.46)..." @@ -807,6 +832,19 @@ case "$1" in fix_time_if_dns_fail ;; + remove-forwarders) + # Do not try updating forwarders when unbound is not running + if ! pgrep unbound &>/dev/null; then + exit 0 + fi + + remove_forwarders + + unbound-control flush_negative > /dev/null + unbound-control flush_bogus > /dev/null + ;; + + test-name-server) ns=${2} @@ -848,7 +886,7 @@ case "$1" in ;; *) - echo "Usage: $0 {start|stop|restart|status|update-forwarders|test-name-server|resolve}" + echo "Usage: $0 {start|stop|restart|status|update-forwarders|remove-forwarders|test-name-server|resolve}" exit 1 ;; esac