various fixes and updates
[distro-setup] / untrusted-network
index c9a43db3670acd75851ecee874545602cbb2dad4..b4fdb70e0e5304af943e683d34d0074d77c56e2b 100755 (executable)
@@ -3,12 +3,13 @@
 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
@@ -18,4 +19,6 @@ no-resolv
 stop-dns-rebind
 EOF
 
-systemctl reload dnsmasq
+  nscd -i hosts
+  systemctl restart dnsmasq
+fi