458 current 2025-06-28 05:38:55 25.05.20250424.f771eb4 6.12.24 *

This commit is contained in:
2025-06-28 05:39:23 -04:00
parent 9e4f8876c0
commit 4ce77101fb
2 changed files with 30 additions and 12 deletions

View File

@@ -1,5 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $(id -u) -ne 0 ]]; then
echo "This script must be run as root." >&2
exit 1
fi
OP=${1:-}; DOMAIN=${2:-}
[[ $OP =~ ^(on|off)$ && -n $DOMAIN ]] || {
echo "usage: dnsblock on|off <domain>"; exit 1; }
@@ -7,10 +11,10 @@ OP=${1:-}; DOMAIN=${2:-}
FILE="/var/lib/dnsmasq/conf.d/block-$DOMAIN.conf"
if [[ $OP == on ]]; then
sudo tee "$FILE" >/dev/null <<EOF
tee "$FILE" >/dev/null <<EOF
address=/${DOMAIN}/0.0.0.0
address=/${DOMAIN}/::
EOF
else
sudo rm -f "$FILE"
rm -f "$FILE"
fi