set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-[[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
# Usage: use when switching from a trusted network to an untrusted one,
# like public wifi.
-cat >/etc/dnsmasq.d/untrusted-network.conf <<'EOF'
+if [[ ! -s /etc/dnsmasq.d/untrusted-network.conf ]]; then
+ cat >/etc/dnsmasq.d/untrusted-network.conf <<'EOF'
server=8.8.4.4
server=8.8.8.8
server=2001:4860:4860::8844
stop-dns-rebind
EOF
-systemctl reload dnsmasq
+ nscd -i hosts
+ systemctl restart dnsmasq
+fi