Last active
July 30, 2017 20:19
-
-
Save yradunchev/397ae73e3eac84a806bc18ebac0eb3ea to your computer and use it in GitHub Desktop.
block access to sites with cron and unbound
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| readonly UCONF='/etc/unbound/unbound.conf' | |
| # toggle block on/off, kill chromium, restart unbound | |
| awk -v commentId='#' -v word='include: /etc/unbound/block.conf' ' | |
| $0 ~ "(^|[[:punct:][:space:]])" word "($|[[:punct:][:space:]])" { | |
| if (match($0, "^[[:space:]]*" commentId)) { | |
| $0 = substr($0, RSTART + RLENGTH); | |
| system("pkill --oldest chromium") | |
| system("systemctl restart unbound"); | |
| } | |
| else { | |
| $0 = commentId $0; | |
| system("systemctl restart unbound"); | |
| } | |
| } | |
| { print } | |
| ' ${UCONF} > tmpunboundconf.$$ && mv tmpunboundconf.$$ ${UCONF} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment