mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-18 06:08:21 +00:00
Use url
variable to store ${sources[$i]}
value to improve readability.
I also wanted to replace the for loop iterating over indices with something like: `for url in $sources[@]}` It made the use of `$i` in the save location more annoying though.
This commit is contained in:
parent
0ec6eab683
commit
d6d192cb0a
@ -47,19 +47,20 @@ fi
|
||||
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines
|
||||
for ((i = 0; i < "${#sources[@]}"; i++))
|
||||
do
|
||||
url=${sources[$i]}
|
||||
# Get just the domain from the URL
|
||||
domain=$(echo "${sources[$i]}" | cut -d'/' -f3)
|
||||
domain=$(echo "$url" | cut -d'/' -f3)
|
||||
|
||||
# Save the file as list.#.domain
|
||||
saveLocation=$origin/list.$i.$domain.$justDomainsExtension
|
||||
|
||||
# Use a case statement to download lists that need special cURL commands to complete properly
|
||||
case "$domain" in
|
||||
"adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation "${sources[$i]}");;
|
||||
"adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation $url);;
|
||||
|
||||
"pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation "${sources[$i]}");;
|
||||
"pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation $url);;
|
||||
|
||||
*) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" "${sources[$i]}");;
|
||||
*) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" $url);;
|
||||
esac
|
||||
|
||||
if [[ -n "$data" ]];then
|
||||
|
Loading…
Reference in New Issue
Block a user