~mikini/hometools

92802c96396eb22471c61d5bb7332cd617a338cb — Mikkel Kirkgaard Nielsen 5 months ago a7feff9
Add dnsmasqctl utility for switching dnsmasq.d-available entries
1 files changed, 26 insertions(+), 0 deletions(-)

A dnsmasqctl
A dnsmasqctl => dnsmasqctl +26 -0
@@ 0,0 1,26 @@
#! /bin/bash

for fp in /etc/dnsmasq.d-available/*; do
  f=$(basename $fp)
  if [ -h /etc/dnsmasq.d/$f ]; then
      if read -p "disable $f? "; then
          if [ "$REPLY" = "y" ]; then
              sudo rm /etc/dnsmasq.d/$f
          fi
      fi
  elif [ ! -f /etc/dnsmasq.d/$f ]; then
      if read -p "enable $f? "; then
          if [ "$REPLY" = "y" ]; then
              sudo ln -sv /etc/dnsmasq.d-available/$f /etc/dnsmasq.d/
          fi
      fi
  else
      echo non-link file already present in /etc/dnsmasq.d/$f.
  fi
done

if read -p "restart dnsmasq? "; then
    if [ "$REPLY" = "y" ]; then
        sudo systemctl restart dnsmasq
    fi
fi