mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-16 12:29:03 +00:00
Imbue gravity.sh with some consistency
Mish-mash of tabs and spaces used for indentation. Mostly tabs though, so going with those. Also indenting blocks and enforcing the loop statement; do done style over the newline for do since it seemed to be more common.
This commit is contained in:
parent
5ebfa5ecf7
commit
aac8e45397
1 changed files with 64 additions and 69 deletions
23
gravity.sh
23
gravity.sh
|
@ -56,7 +56,7 @@ eventHorizon=${basename}.2.eventHorizon.txt
|
||||||
accretionDisc=${basename}.3.accretionDisc.txt
|
accretionDisc=${basename}.3.accretionDisc.txt
|
||||||
|
|
||||||
# Warn users still using pihole.conf that it no longer has any effect (I imagine about 2 people use it)
|
# Warn users still using pihole.conf that it no longer has any effect (I imagine about 2 people use it)
|
||||||
if [[ -r ${piholeDir}/pihole.conf ]];then
|
if [[ -r ${piholeDir}/pihole.conf ]]; then
|
||||||
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
|
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ gravity_collapse() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
||||||
if [[ -d ${piholeDir} ]];then
|
if [[ -d ${piholeDir} ]]; then
|
||||||
# Temporary hack to allow non-root access to pihole directory
|
# Temporary hack to allow non-root access to pihole directory
|
||||||
# Will update later, needed for existing installs, new installs should
|
# Will update later, needed for existing installs, new installs should
|
||||||
# create this directory as non-root
|
# create this directory as non-root
|
||||||
|
@ -113,7 +113,7 @@ gravity_collapse() {
|
||||||
gravity_patternCheck() {
|
gravity_patternCheck() {
|
||||||
patternBuffer=$1
|
patternBuffer=$1
|
||||||
# check if the patternbuffer is a non-zero length file
|
# check if the patternbuffer is a non-zero length file
|
||||||
if [[ -s "$patternBuffer" ]];then
|
if [[ -s "$patternBuffer" ]]; then
|
||||||
# Some of the blocklists are copyright, they need to be downloaded
|
# Some of the blocklists are copyright, they need to be downloaded
|
||||||
# and stored as is. They can be processed for content after they
|
# and stored as is. They can be processed for content after they
|
||||||
# have been saved.
|
# have been saved.
|
||||||
|
@ -151,8 +151,7 @@ gravity_transport() {
|
||||||
gravity_spinup() {
|
gravity_spinup() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
||||||
for ((i = 0; i < "${#sources[@]}"; i++))
|
for ((i = 0; i < "${#sources[@]}"; i++)); do
|
||||||
do
|
|
||||||
url=${sources[$i]}
|
url=${sources[$i]}
|
||||||
# Get just the domain from the URL
|
# Get just the domain from the URL
|
||||||
domain=$(echo "$url" | cut -d'/' -f3)
|
domain=$(echo "$url" | cut -d'/' -f3)
|
||||||
|
@ -190,8 +189,7 @@ gravity_Schwarzchild() {
|
||||||
# Find all active domains and compile them into one file and remove CRs
|
# Find all active domains and compile them into one file and remove CRs
|
||||||
echo -n "::: Aggregating list of domains..."
|
echo -n "::: Aggregating list of domains..."
|
||||||
truncate -s 0 ${piholeDir}/${matterAndLight}
|
truncate -s 0 ${piholeDir}/${matterAndLight}
|
||||||
for i in "${activeDomains[@]}"
|
for i in "${activeDomains[@]}"; do
|
||||||
do
|
|
||||||
cat "$i" | tr -d '\r' >> ${piholeDir}/${matterAndLight}
|
cat "$i" | tr -d '\r' >> ${piholeDir}/${matterAndLight}
|
||||||
done
|
done
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
@ -214,8 +212,7 @@ gravity_Whitelist() {
|
||||||
echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..."
|
echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..."
|
||||||
|
|
||||||
urls=()
|
urls=()
|
||||||
for url in "${sources[@]}"
|
for url in "${sources[@]}"; do
|
||||||
do
|
|
||||||
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
||||||
urls=("${urls[@]}" ${tmp})
|
urls=("${urls[@]}" ${tmp})
|
||||||
done
|
done
|
||||||
|
@ -248,7 +245,7 @@ gravity_hostFormat() {
|
||||||
echo "::: Error: Unable to determine fully qualified domain name of host"
|
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||||
fi
|
fi
|
||||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
||||||
if [[ -n "${IPv6_address}" ]];then
|
if [[ -n "${IPv6_address}" ]]; then
|
||||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||||
echo -e "$IPv4addr $hostname\n$IPv6_address $hostname\n$IPv4addr pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
echo -e "$IPv4addr $hostname\n$IPv6_address $hostname\n$IPv4addr pi.hole\n$IPv6_address pi.hole" > ${piholeDir}/${accretionDisc}
|
||||||
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" -v ipv6addr="$IPv6_address" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
@ -266,8 +263,7 @@ gravity_hostFormat() {
|
||||||
# blackbody - remove any remnant files from script processes
|
# blackbody - remove any remnant files from script processes
|
||||||
gravity_blackbody() {
|
gravity_blackbody() {
|
||||||
# Loop through list files
|
# Loop through list files
|
||||||
for file in ${piholeDir}/*.${justDomainsExtension}
|
for file in ${piholeDir}/*.${justDomainsExtension}; do
|
||||||
do
|
|
||||||
# If list is in active array then leave it (noop) else rm the list
|
# If list is in active array then leave it (noop) else rm the list
|
||||||
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
||||||
:
|
:
|
||||||
|
@ -333,8 +329,7 @@ gravity_reload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for var in "$@"
|
for var in "$@"; do
|
||||||
do
|
|
||||||
case "$var" in
|
case "$var" in
|
||||||
"-f" | "--force" ) forceGrav=true;;
|
"-f" | "--force" ) forceGrav=true;;
|
||||||
"-h" | "--help" ) helpFunc;;
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
|
Loading…
Add table
Reference in a new issue