no error handling in the curl command
Hello mmotti,
There is no error handling in your curl command. For example a 404 error, etc.
Below some code how I solved this. This is based on the actual (no-dbase) version of PiHile; so the previous version of your fetchFilterLists.sh.
`## define domains1="/etc/pihole/domains1.txt" domains2="/etc/pihole/domains2.txt" domains3="/etc/pihole/domains3.txt" domains4="/etc/pihole/domains4.txt" domains5="/etc/pihole/domains5.txt" domains6="/etc/pihole/domains6.txt"
## below an example of getting one of these files and put this in domains2.txt.
httpCode=$(curl -s -L --show-error https://raw.githubusercontent.com/justdomains/blocklists/master/lists/nocoin-justdomains.txt -w "%{http_code}" -o $domains2 2> /dev/null)
if [ ${httpCode} = "200" ]; then if [ ! -f $domains2 ]; then echo "$(timestamp) [i] An error occured whilst downloading nocoin-justdomains.txt. HTTP error code: ${httpCode}" fi else echo "$(timestamp) [i] An error occured whilst downloading nocoin-justdomains.txt. HTTP error code: ${httpCode}" echo "" > $domains2 ## create an empty file so the later cat process doesn't give an error fi
# not all downloaded list end with a new line, so add an empty line to the list, using echo
echo >> $domains2
# at the end cat all 6 files together
# remove lines with comments and blanc lines, sort the list and put it in a variable for further processing
filter_domains=$((cat $domains1 $domains2 $domains3 $domains4 $domains5 $domains6) | sed -e "/#/ d" -e "/^$/ d" | sort -u )`
I also have added some code to solve the "Notracking's domains only blocklist" issue in the same structure as written above. I added this and some other things to your scripts and this runs for months without any problems. Thanks for publishing these scripts.