From 4ce77101fbe9b2d55ed4bcda5c931cde3982d4be Mon Sep 17 00:00:00 2001 From: Jake Ginesin Date: Sat, 28 Jun 2025 05:39:23 -0400 Subject: [PATCH] 458 current 2025-06-28 05:38:55 25.05.20250424.f771eb4 6.12.24 * --- home/scripts/dns/dnsblock-norestart.sh | 8 ++++-- system/networking/blockers.sh | 34 ++++++++++++++++++-------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/home/scripts/dns/dnsblock-norestart.sh b/home/scripts/dns/dnsblock-norestart.sh index a74f0a0..ad73e91 100755 --- a/home/scripts/dns/dnsblock-norestart.sh +++ b/home/scripts/dns/dnsblock-norestart.sh @@ -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 "; 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 </dev/null <> /home/synchronous/lol -websites=("www.reddit.com" "www.youtube.com" "www.instagram.com" "www.facebook.com" "facebook.com" "www.craigslist.org" "www.ebay.com" "www.monkeytype.com" "www.typeracer.com" "www.twitter.com" "www.linkedin.com") +if [[ "$should_block" == "false" ]]; then + exit 1 +fi + +websites=( + "www.reddit.com" + "www.youtube.com" + "www.instagram.com" + "www.facebook.com" + "facebook.com" + "www.craigslist.org" + "www.ebay.com" + "www.monkeytype.com" + "www.typeracer.com" + "www.twitter.com" + "www.linkedin.com" +) op="" if [ "$2" == "up" ]; then op="on" -elif ["$2" == "pre-down" ]; then +elif [ "$2" == "down" ]; then op="off" else - exit 1; + exit 0 fi -for website in ${websites[@]}; do - sh /etc/profiles/per-user/synchronous/bin/dnsblock-norestart "$op" "$website" - # grep -v "$website" /etc/hosts > "$tempHosts" - # mv "$tempHosts" /etc/hosts +for website in "${websites[@]}"; do + /run/current-system/sw/bin/bash /etc/profiles/per-user/synchronous/bin/dnsblock-norestart "$op" "$website" 2> /home/synchronous/lol done sudo systemctl restart dnsmasq