Amnezia VPN Server settings
Download and update adblocker list for dnscrypt proxy
Creating the script
Open the terminal and type the below command :
nano update-adblocker.sh
and then copy / paste the below code inside the file "update-adblocker.sh"
#!/bin/bash
# Name: update-adblocker.sh
# Purpose: Download and update adblocker list for dnscrypt proxy
# Usage: Call it from the CLI or cron job https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
DEST="/etc/dnscrypt-proxy/blocked_names.txt"
#
# Blocks both adware + malware
# See for other lists https://github.com/StevenBlack/hosts
#SRC="https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-porn/hosts" Hosts 224.828
#SRC="https://hosts.ubuntu101.co.za/hosts" Hosts 698.866
#SRC="https://download.dnscrypt.info/blacklists/domains/mybase.txt" Hosts 465.625
SRC="https://hosts.ubuntu101.co.za/hosts"
TMP_B_FILE="$(mktemp)"
TMP_B_FILE_SORTED="$(mktemp)"
wget --timeout=10 --tries=5 -qO- "${SRC}" | grep -Ev "(localhost)" | grep -Ev "#" | sed -E "s/(0.0.0.0 |127.0.0.1 |255.255.255.255 )//" >> "${TMP_B_FILE}"
awk '/^[^#]/ { print $1 }' "${TMP_B_FILE}" | sort -u > "${TMP_B_FILE_SORTED}"
cp -f "${TMP_B_FILE_SORTED}" "$DEST"
rm -f "${TMP_B_FILE}" "${TMP_B_FILE_SORTED}"
sleep 5
systemctl restart dnscrypt-proxy.service
then press Ctrl + x it will prompt you [ Save modified buffer? ] press y and enter
Make the script executable
After that you need to make the script executable, so you will write the below command :
chmod +x update-adblocker.sh
Add the script to cron job to run automatically
To run the script daily follow the below steps, you can change according to your need.
crontab -e
then go at the end of the file and add the below line, change the your_path with your folder where the script is locate.
@daily /your_path/update-adblocker.sh
then press Ctrl + x it will prompt you [ Save modified buffer? ] press y and enter
You are done the script in the location /your_path/os-update.sh it will automatically run daily.
Download the script update-adblocker.sh
Attachment Link update-adblocker.sh
Below is the settings for the script that it will run daily with cron job to auto update the DNS servers.