From 07a1c70bf4ffc666fb6eaba54031b081b5542b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Elizeche=20Land=C3=B3?= Date: Tue, 21 Nov 2017 02:50:05 -0300 Subject: [PATCH] Update adblock.sh for systemd to fix issue #735 (#736) * Update script to restart the dnsmasq service using systemctl(systemd) command instead of service(Upstart) * Use instead of legacy REF: https://github.com/koalaman/shellcheck/wiki/SC2006 * Replace non-standard egrep(deprecated) for grep -E. REF: https://github.com/koalaman/shellcheck/wiki/SC2196 --- roles/dns_adblocking/templates/adblock.sh.j2 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/roles/dns_adblocking/templates/adblock.sh.j2 b/roles/dns_adblocking/templates/adblock.sh.j2 index def11d3..08af362 100644 --- a/roles/dns_adblocking/templates/adblock.sh.j2 +++ b/roles/dns_adblocking/templates/adblock.sh.j2 @@ -1,8 +1,8 @@ #!/bin/sh # Block ads, malware, etc.. -TEMP=`mktemp` -TEMP_SORTED=`mktemp` +TEMP="$(mktemp)" +TEMP_SORTED="$(mktemp)" DNSMASQ_WHITELIST="/var/lib/dnsmasq/white.list" DNSMASQ_BLACKLIST="/var/lib/dnsmasq/black.list" DNSMASQ_BLOCKHOSTS="{{ config_prefix|default('/') }}etc/dnsmasq.d/block.hosts.conf" @@ -33,11 +33,13 @@ then #Filter the blacklist, suppressing whitelist matches # This is relatively slow =-( echo 'Filtering white list...' - egrep -v "^[[:space:]]*$" $DNSMASQ_WHITELIST | awk '/^[^#]/ {sub(/\r$/,"");print $1}' | grep -vf - "$TEMP_SORTED" > $DNSMASQ_BLOCKHOSTS + grep -v -E "^[[:space:]]*$" $DNSMASQ_WHITELIST | awk '/^[^#]/ {sub(/\r$/,"");print $1}' | grep -vf - "$TEMP_SORTED" > $DNSMASQ_BLOCKHOSTS else cat "$TEMP_SORTED" > $DNSMASQ_BLOCKHOSTS fi -service dnsmasq restart +echo 'Restarting dnsmasq service...' +#Restart the dnsmasq service +systemctl restart dnsmasq.service exit 0