458 current 2025-06-28 05:38:55 25.05.20250424.f771eb4 6.12.24 *
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user