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
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Create temporary files to hold the old configs
|
||||||
sed -n '1,/# start of removeadhosts/p' /etc/hosts > /tmp/removeadhosts-head
|
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
|
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
|
cat /tmp/removeadhosts-head | tee /etc/hosts >/dev/null
|
||||||
rm /tmp/removeadhosts-head
|
rm /tmp/removeadhosts-head
|
||||||
echo "Appended old hosts"
|
echo "Appended old hosts"
|
||||||
|
|
@ -12,13 +16,16 @@ else
|
||||||
echo '# start of removeadhosts' >> /etc/hosts
|
echo '# start of removeadhosts' >> /etc/hosts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Download entries from the listings list
|
||||||
echo 'Downloading ad list'
|
echo 'Downloading ad list'
|
||||||
if [ -e /etc/removeadhosts/adlistings.txt ]
|
if [ -e /etc/removeadhosts/adlistings.txt ]
|
||||||
then
|
then
|
||||||
cat /etc/removeadhosts/adlistings.txt | \
|
cat /etc/removeadhosts/adlistings.txt | \
|
||||||
while read SITE; do
|
while read SITE; do
|
||||||
|
echo "# removeadhosts site - $SITE" >> /etc/hosts
|
||||||
curl $SITE 2>/dev/null | tee -a /etc/hosts >/dev/null
|
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
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -29,6 +36,8 @@ then
|
||||||
fi
|
fi
|
||||||
rm /tmp/removeadhosts-curl
|
rm /tmp/removeadhosts-curl
|
||||||
|
|
||||||
|
|
||||||
|
# Add entries from adlist
|
||||||
echo 'Adding custom items from /etc/removeadhosts'
|
echo 'Adding custom items from /etc/removeadhosts'
|
||||||
if [ -e /etc/removeadhosts/adlist.txt ]
|
if [ -e /etc/removeadhosts/adlist.txt ]
|
||||||
then
|
then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue