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:
Marcus Hildum 2016-10-21 23:02:45 -07:00
parent 5ebfa5ecf7
commit aac8e45397

View file

@ -56,7 +56,7 @@ eventHorizon=${basename}.2.eventHorizon.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)
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."
fi
@ -95,7 +95,7 @@ gravity_collapse() {
fi
# 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
# Will update later, needed for existing installs, new installs should
# create this directory as non-root
@ -113,7 +113,7 @@ gravity_collapse() {
gravity_patternCheck() {
patternBuffer=$1
# 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
# and stored as is. They can be processed for content after they
# have been saved.
@ -151,8 +151,7 @@ gravity_transport() {
gravity_spinup() {
echo ":::"
# 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
for ((i = 0; i < "${#sources[@]}"; i++)); do
url=${sources[$i]}
# Get just the domain from the URL
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
echo -n "::: Aggregating list of domains..."
truncate -s 0 ${piholeDir}/${matterAndLight}
for i in "${activeDomains[@]}"
do
for i in "${activeDomains[@]}"; do
cat "$i" | tr -d '\r' >> ${piholeDir}/${matterAndLight}
done
echo " done!"
@ -214,8 +212,7 @@ gravity_Whitelist() {
echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..."
urls=()
for url in "${sources[@]}"
do
for url in "${sources[@]}"; do
tmp=$(echo "$url" | awk -F '/' '{print $3}')
urls=("${urls[@]}" ${tmp})
done
@ -248,7 +245,7 @@ gravity_hostFormat() {
echo "::: Error: Unable to determine fully qualified domain name of host"
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 [[ -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)
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}
@ -266,8 +263,7 @@ gravity_hostFormat() {
# blackbody - remove any remnant files from script processes
gravity_blackbody() {
# Loop through list files
for file in ${piholeDir}/*.${justDomainsExtension}
do
for file in ${piholeDir}/*.${justDomainsExtension}; do
# If list is in active array then leave it (noop) else rm the list
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
:
@ -333,8 +329,7 @@ gravity_reload() {
}
for var in "$@"
do
for var in "$@"; do
case "$var" in
"-f" | "--force" ) forceGrav=true;;
"-h" | "--help" ) helpFunc;;