mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Merge pull request #3269 from pi-hole/tweak/hosts-comments
Add support for comments in HOSTS-like files
This commit is contained in:
commit
0f20470a38
1 changed files with 6 additions and 4 deletions
10
gravity.sh
10
gravity.sh
|
@ -573,12 +573,14 @@ gravity_ParseFileIntoDomains() {
|
||||||
# It also helps with debugging so each stage of the script can be researched more in depth
|
# It also helps with debugging so each stage of the script can be researched more in depth
|
||||||
# 1) Remove carriage returns
|
# 1) Remove carriage returns
|
||||||
# 2) Convert all characters to lowercase
|
# 2) Convert all characters to lowercase
|
||||||
# 3) Remove lines containing "#" or "/"
|
# 3) Remove comments (text starting with "#", include possible spaces before the hash sign)
|
||||||
# 4) Remove leading tabs, spaces, etc.
|
# 4) Remove lines containing "/"
|
||||||
# 5) Delete lines not matching domain names
|
# 5) Remove leading tabs, spaces, etc.
|
||||||
|
# 6) Delete lines not matching domain names
|
||||||
< "${source}" tr -d '\r' | \
|
< "${source}" tr -d '\r' | \
|
||||||
tr '[:upper:]' '[:lower:]' | \
|
tr '[:upper:]' '[:lower:]' | \
|
||||||
sed -r '/(\/|#).*$/d' | \
|
sed 's/\s*#.*//g' | \
|
||||||
|
sed -r '/(\/).*$/d' | \
|
||||||
sed -r 's/^.*\s+//g' | \
|
sed -r 's/^.*\s+//g' | \
|
||||||
sed -r '/([^\.]+\.)+[^\.]{2,}/!d' > "${destination}"
|
sed -r '/([^\.]+\.)+[^\.]{2,}/!d' > "${destination}"
|
||||||
chmod 644 "${destination}"
|
chmod 644 "${destination}"
|
||||||
|
|
Loading…
Reference in a new issue