summarylogtreecommitdiffstats
path: root/hostsblock.sh
diff options
context:
space:
mode:
authorJacob van der Kolk2017-08-01 14:58:59 -0400
committerJacob van der Kolk2017-08-01 14:58:59 -0400
commitddc82f30345dede90a3a6d79613bfda9859a57d0 (patch)
tree15a863021a0d6730dbe9d6897b28ff6d800e68b3 /hostsblock.sh
parentef7961111098c83e0b228f276e03a06ab974f0a1 (diff)
downloadaur-ddc82f30345dede90a3a6d79613bfda9859a57d0.tar.gz
Version 0.999.5-1; Fixed issues with hostsblock-urlblock symlink; typo
Diffstat (limited to 'hostsblock.sh')
-rwxr-xr-xhostsblock.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/hostsblock.sh b/hostsblock.sh
index 89224aec86df..721355bee508 100755
--- a/hostsblock.sh
+++ b/hostsblock.sh
@@ -77,11 +77,11 @@ _extract_entries() {
}
_check_url() {
- _url_escaped=$(echo "$@" | sed "s/\./\\\./g")
+ which pigz &>/dev/null
if [ $? -eq 0 ]; then
- _matches=$(pigz -dc "$annotate" | grep -F " $_url_escaped ")
+ _matches=$(pigz -dc "$annotate" | grep -F " $@ ")
else
- _matches=$(gzip -dc "$annotate" | grep -F " $_url_escaped ")
+ _matches=$(gzip -dc "$annotate" | grep -F " $@ ")
fi
_block_matches=$(echo "$_matches" | grep -- "^$redirecturl" | sed "s/.* \!\(.*\)$/\1/g" | tr '\n' ',' | sed "s/,$//g")
_redirect_matches=$(echo "$_matches" | grep -v "^$redirecturl" | \
@@ -280,6 +280,8 @@ if [ $_check -eq 1 ] || [ "${0##*/}" == "hostsblock-urlcheck" ]; then
# URLCHECK
[ -f "$tmpdir"/hostsblock/changed ] && rm -f "$tmpdir"/hostsblock/changed
echo "Checking to see if url is blocked or not..."
+ # If run from symlink "hostsblock-urlcheck" _URL will not be set by getopts
+ [ "$_URL" == "" ] && _URL="$1"
_check_url $(echo "$_URL" | sed -e "s/.*https*:\/\///g" -e "s/[\/?'\" :<>\(\)].*//g")
if [ -f "$tmpdir"/hostsblock/changed ]; then
if [ $_verbosity -ge 1 ]; then
@@ -464,7 +466,7 @@ else
# APPEND BLACKLIST ENTRIES
while read _blacklistline; do
- echo "$redirecturl $_blacklistline \! $blacklist" >> "$tmpdir"/"${annotate##*/}".tmp
+ echo "$redirecturl $_blacklistline \! $blacklist" >> "$tmpdir"/hostsblock/"${annotate##*/}".tmp
grep -Fqx "$_blacklistline" "$hostsfile" || echo "$redirecturl $_blacklistline" >> "$hostsfile"
done < "$blacklist" || _notify 1 "FAILED to append blacklisted entries to $hostsfile."