#!/bin/bash # Test #X=$( ( echo REFUSED >&1 ) ; dig +short github.com ; dig +short shackspace.de ; dig +short citecs.de 2>&1 ) X=$( dig +short github.com ; dig +short shackspace.de ; dig +short citecs.de 2>&1 ) if grep -q REFUSED <<< "$X" ; then echo "DNS resolving failed on infra1.shackspace.de (found 'REFUSED')" echo "restarting dnsmasq..." systemctl status dnsmasq systemctl restart dnsmasq systemctl status dnsmasq else if [ "$X" = "" ] ; then echo "DNS resolving failed on infra1.shackspace.de (got empty answer)" echo "restarting dnsmasq..." systemctl status dnsmasq systemctl restart dnsmasq systemctl status dnsmasq fi fi