initial setup
commit
e82971ecc3
|
|
@ -0,0 +1,19 @@
|
|||
dir:
|
||||
mkdir -p /usr/local/share/removeadhosts
|
||||
install: dir
|
||||
cp src/* /usr/local/share/removeadhosts/
|
||||
chown -R root:root /usr/local/share/removeadhosts
|
||||
chmod +x /usr/local/share/removeadhosts/removeadhosts.sh
|
||||
cp /usr/local/share/removeadhosts/removeadhosts.service /etc/systemd/system/
|
||||
cp /usr/local/share/removeadhosts/removeadhosts.timer /etc/systemd/system/
|
||||
activate: install
|
||||
systemctl enable removeadhosts.timer
|
||||
systemctl start removeadhosts.timer
|
||||
deactivate:
|
||||
systemctl disable removeadhosts.timer
|
||||
systemctl stop removeadhosts.timer
|
||||
remove: deactivate
|
||||
rm -f /etc/systemd/system/removeadhosts*
|
||||
rm -fr /usr/local/share/removeadhosts/
|
||||
|
||||
reinstall: remove install
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=update the hosts file to remove ads
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/share/removeadhosts/removeadhosts.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
sed -n '1,/# start of removeadhosts/p' /etc/hosts > /tmp/removeadhosts
|
||||
cat /tmp/removeadhosts | tee /etc/hosts >/dev/null
|
||||
rm /tmp/removeadhosts
|
||||
echo "Appended old hosts"
|
||||
if grep -qinE '# start of removeadhosts' /etc/hosts
|
||||
then
|
||||
echo "This has been run before"
|
||||
else
|
||||
echo "First Run"
|
||||
echo '# start of removeadhosts' >> /etc/hosts
|
||||
fi
|
||||
|
||||
echo 'Downloading ad list'
|
||||
|
||||
curl https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts 2>/dev/null | tee -a /etc/hosts >/dev/null
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=update host file to remove ads weekly
|
||||
|
||||
[Timer]
|
||||
OnBootSec=15min
|
||||
OnUnitActiveSec=1w
|
||||
AccuracySec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Loading…
Reference in New Issue