publicarray / spksrc

Cross compilation framework to create native packages for the Synology's NAS
https://synocommunity.com/
Other
66 stars 14 forks source link

ToDo: use cron to automatically update blocklist approx. once a day #5

Closed publicarray closed 5 years ago

kc6108 commented 5 years ago

This is what I use to update the blacklist.txt file on my Netgear R9000 router just in case it helps any at all:

Create update_blacklist.sh:

  1. echo '#!/bin/sh' >/usr/bin/update_blacklist.sh
  2. echo 'wget -O /etc/blacklist.txt https://download.dnscrypt.info/blacklists/domains/mybase.txt' >>/usr/bin/update_blacklist.sh
  3. echo '[ $? -ne 0 ] && exit 1' >>/usr/bin/update_blacklist.sh
  4. echo '/etc/init.d/dnscrypt-proxy-2 restart' >>/usr/bin/update_blacklist.sh

Make update_blacklist.sh executable:

  1. chmod +x /usr/bin/update_blacklist.sh

Manually run (or to simply test) update_blacklist.sh:

  1. /usr/bin/update_blacklist.sh

Backup rc.local file (this command only does so if it hasn't already been done before):

  1. [ ! -e /etc/rc.local.orig ] && cp -p /etc/rc.local /etc/rc.local.orig

Create/Schedule Cronjob:

  1. echo >>/etc/rc.local
  2. echo 'mkdir -p /opt/tmp/cronblacklist/crontabs && echo "0 4 * /usr/bin/update_blacklist.sh" >/opt/tmp/cronblacklist/crontabs/root && crond -c /opt/tmp/cronblacklist/crontabs -T '"'"'$($CONFIG get time_zone)'"'"'' >/tmp/x.blacklist
  3. sed -n -i -e '/^exit 0/r /tmp/x.blacklist' -e 1x -e '2,${x;p}' -e '${x;p}' /etc/rc.local
  4. sed -i '$ { /^$/ d}' /etc/rc.local
  5. \rm /tmp/x.blacklist
publicarray commented 5 years ago

Thanks I have implemented a cron job in 6c09c9433526ab72e4cc4d9b6402152fb186cb27. It still requires testing for the DSM, but it works on the SRM.