Heads and tags each curl entry / added comments
Each entry has a header line and an end line to easily extract it using sedstable
parent
621e9ebb2f
commit
668732be30
|
|
@ -1,6 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Create temporary files to hold the old configs
|
||||
sed -n '1,/# start of removeadhosts/p' /etc/hosts > /tmp/removeadhosts-head
|
||||
sed -n '/# start of removeadhosts/,/# Custom ad list/p' /etc/hosts | sed -e '/# Custom ad list/d' -e '1d' > /tmp/removeadhosts-curl
|
||||
|
||||
# Copy back all the custom entries
|
||||
cat /tmp/removeadhosts-head | tee /etc/hosts >/dev/null
|
||||
rm /tmp/removeadhosts-head
|
||||
echo "Appended old hosts"
|
||||
|
|
@ -12,13 +16,16 @@ else
|
|||
echo '# start of removeadhosts' >> /etc/hosts
|
||||
fi
|
||||
|
||||
|
||||
# Download entries from the listings list
|
||||
echo 'Downloading ad list'
|
||||
if [ -e /etc/removeadhosts/adlistings.txt ]
|
||||
then
|
||||
cat /etc/removeadhosts/adlistings.txt | \
|
||||
while read SITE; do
|
||||
echo "# removeadhosts site - $SITE" >> /etc/hosts
|
||||
curl $SITE 2>/dev/null | tee -a /etc/hosts >/dev/null
|
||||
echo "0.0.0.0 $CMD" >> /etc/hosts
|
||||
echo "# removeadhosts site - end" >> /etc/hosts
|
||||
done
|
||||
fi
|
||||
|
||||
|
|
@ -29,6 +36,8 @@ then
|
|||
fi
|
||||
rm /tmp/removeadhosts-curl
|
||||
|
||||
|
||||
# Add entries from adlist
|
||||
echo 'Adding custom items from /etc/removeadhosts'
|
||||
if [ -e /etc/removeadhosts/adlist.txt ]
|
||||
then
|
||||
|
|
|
|||
Loading…
Reference in New Issue