bin: separate and improve cleanbrowsing scripts

This commit is contained in:
xeruf 2021-07-04 18:32:06 +02:00
parent c9b11ff5a9
commit 8b6958162e
3 changed files with 26 additions and 15 deletions

View File

@ -145,21 +145,6 @@ alias lar='last | tac'
# Listen to loopback of mic # Listen to loopback of mic
alias listen='pactl load-module module-loopback; echo "Press Enter to stop"; read; pactl unload-module module-loopback' alias listen='pactl load-module module-loopback; echo "Press Enter to stop"; read; pactl unload-module module-loopback'
alias browse-safe='sudo systemctl disable --now systemd-resolved && sudo rm -f /etc/resolv.conf && echo "nameserver 185.228.168.10" | sudo tee /etc/resolv.conf && sudo chattr +i /etc/resolv.conf'
browse-unsafe() {
echo "Why do you want to browse unsafe?"
while test ${#intention} -lt 10
do read intention
done
jrnl intentions-nug "$intention"
trap 'echo Browsing safe; browse-safe' INT
sudo chattr -i /etc/resolv.conf &&
sudo mv /etc/resolv.conf /etc/resolv.conf.bak &&
sudo systemctl enable --now systemd-resolved &&
sleep ${1:-100}
browse-safe
}
xo() { xo() {
while test $# -gt 0; do while test $# -gt 0; do
xdg-open "$1" xdg-open "$1"

11
.local/bin/scripts/browse-safe Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# Replace systemd-resolved with the Adult Filter DNS of https://cleanbrowsing.org/filters
set -e
sudo systemctl disable --now systemd-resolved
resolvconf="/etc/resolv.conf"
dns="nameserver 185.228.168.10
nameserver 185.228.169.11"
test "$(cat "$resolvconf" 2>/dev/null)" = "$dns" && exit 0
test -f "$resolvconf" && sudo chattr -i "$resolvconf" && sudo rm -vf "$resolvconf"
echo "$dns" | sudo tee "$resolvconf"
sudo chattr +i "$resolvconf"

View File

@ -0,0 +1,15 @@
#!/bin/sh
# Temporarily disable cleanbrowsing
echo "Why do you want to browse unsafe?"
while test ${#intention} -lt 10
do read intention
done
jrnl intentions-nug "$intention"
trap 'echo Cancelling unsafe browsing && browse-safe; exit $?' INT
test -f "/etc/resolv.conf" &&
sudo chattr -i /etc/resolv.conf &&
sudo mv /etc/resolv.conf /etc/resolv.conf.bak
sudo systemctl enable --now systemd-resolved
sleep ${1:-100}
echo "Ending unsafe browsing"
browse-safe