~mikini/hometools

ref: 92802c96396eb22471c61d5bb7332cd617a338cb hometools/dnsmasqctl -rwxr-xr-x 655 bytes
92802c96 — Mikkel Kirkgaard Nielsen Add dnsmasqctl utility for switching dnsmasq.d-available entries 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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