From a12f808516a1e72a758b1a84b6a9bb52b2b0e7eb Mon Sep 17 00:00:00 2001 From: tuplink Date: Thu, 20 Oct 2016 14:09:11 -0400 Subject: [PATCH] add a bunch of quotes --- advanced/Scripts/blacklist.sh | 12 ++++++------ advanced/Scripts/whitelist.sh | 12 ++++++------ gravity.sh | 22 ++++++++++------------ pihole | 18 +++++++++--------- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 18380b1a..ad4164a4 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -50,8 +50,8 @@ HandleOther(){ PopBlacklistFile(){ #check blacklist file exists, and if not, create it - if [[ ! -f ${blacklistFile} ]];then - touch ${blacklistFile} + if [[ ! -f "${blacklistFile"} ]];then + touch "${blacklistFile}" fi for dom in "${domList[@]}"; do if "$addmode"; then @@ -65,13 +65,13 @@ PopBlacklistFile(){ AddDomain(){ #| sed 's/\./\\./g' bool=false - grep -Ex -q "$1" ${blacklistFile} || bool=true + grep -Ex -q "$1" "${blacklistFile}" || bool=true if ${bool}; then #domain not found in the blacklist file, add it! if ${verbose}; then echo -n "::: Adding $1 to blacklist file..." fi - echo "$1" >> ${blacklistFile} + echo "$1" >> "${blacklistFile}" echo " done!" else if ${verbose}; then @@ -83,7 +83,7 @@ AddDomain(){ RemoveDomain(){ bool=false - grep -Ex -q "$1" ${blacklistFile} || bool=true + grep -Ex -q "$1" "${blacklistFile"} || bool=true if ${bool}; then #Domain is not in the blacklist file, no need to Remove if ${verbose}; then @@ -94,7 +94,7 @@ RemoveDomain(){ if ${verbose}; then echo "::: Un-blacklisting $dom..." fi - echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${blacklistFile} + echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' "${blacklistFile}" fi } diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 06af9551..63162682 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -50,8 +50,8 @@ HandleOther(){ PopWhitelistFile(){ #check whitelist file exists, and if not, create it - if [[ ! -f ${whitelistFile} ]];then - touch ${whitelistFile} + if [[ ! -f "${whitelistFile}" ]];then + touch "${whitelistFile}" fi for dom in "${domList[@]}" do @@ -67,13 +67,13 @@ AddDomain(){ #| sed 's/\./\\./g' bool=false - grep -Ex -q "$1" ${whitelistFile} || bool=true + grep -Ex -q "$1" "${whitelistFile}" || bool=true if ${bool}; then #domain not found in the whitelist file, add it! if ${verbose}; then echo -n "::: Adding $1 to $whitelist..." fi - echo "$1" >> ${whitelistFile} + echo "$1" >> "${whitelistFile}" if ${verbose}; then echo " done!" fi @@ -87,14 +87,14 @@ AddDomain(){ RemoveDomain(){ bool=false - grep -Ex -q "$1" ${whitelistFile} || bool=true + grep -Ex -q "$1" "${whitelistFile}" || bool=true if ${bool}; then #Domain is not in the whitelist file, no need to Remove if ${verbose}; then echo "::: $1 is NOT whitelisted! No need to remove" fi else - echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${whitelistFile} + echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' "${whitelistFile}" fi } diff --git a/gravity.sh b/gravity.sh index c219b9d3..9db9c3d8 100755 --- a/gravity.sh +++ b/gravity.sh @@ -26,7 +26,7 @@ helpFunc() } -if [[ -f ${setupVars} ]];then +if [[ -f "${setupVars}" ]];then . /etc/pihole/setupVars.conf else echo "::: WARNING: /etc/pihole/setupVars.conf missing. Possible installation failure." @@ -38,20 +38,18 @@ fi IPv4_address=${IPv4_address%/*} # Variables for various stages of downloading and formatting the list -basename=pihole -piholeDir=/etc/${basename} -adList=${piholeDir}/gravity.list -justDomainsExtension=domains -matterAndLight=${basename}.0.matterandlight.txt -supernova=${basename}.1.supernova.txt -preEventHorizon=list.preEventHorizon -eventHorizon=${basename}.2.supernova.txt -accretionDisc=${basename}.3.accretionDisc.txt +adList="${piholeDir}/gravity.list" +justDomainsExtension="domains" +matterAndLight="${basename}.0.matterandlight.txt" +supernova="${basename}.1.supernova.txt" +preEventHorizon="list.preEventHorizon" +eventHorizon="${basename}.2.supernova.txt" +accretionDisc="${basename}.3.accretionDisc.txt" skipDownload=false # 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 @@ -115,7 +113,7 @@ gravity_transport() { # tmp file, so we don't have to store the (long!) lists in RAM patternBuffer=$(mktemp) heisenbergCompensator="" - if [[ -r ${saveLocation} ]]; then + if [[ -r "${saveLocation"} ]]; then # if domain has been saved, add file for date check to only download newer heisenbergCompensator="-z $saveLocation" fi diff --git a/pihole b/pihole index 355e3b40..59927e49 100755 --- a/pihole +++ b/pihole @@ -125,15 +125,15 @@ fi #Source the setupVars from install script for the IP export setupVars=/etc/pihole/setupVars.conf -export basename=pihole -export piholeDir=/etc/${basename} -export adList=${piholeDir}/gravity.list -export blacklistFile=${piholeDir}/blacklist.txt -export whitelistFile=${piholeDir}/whitelist.txt -export adListFile=${piholeDir}/adlists.list -export adListDefault=${piholeDir}/adlists.default -export whitelistScript=/opt/pihole/whitelist.sh -export blacklistScript=/opt/pihole/blacklist.sh +export basename="pihole" +export piholeDir="/etc/${basename}" +export adList="${piholeDir}/gravity.list" +export blacklistFile="${piholeDir}/blacklist.txt" +export whitelistFile="${piholeDir}/whitelist.txt" +export adListFile="${piholeDir}/adlists.list" +export adListDefault="${piholeDir}/adlists.default" +export whitelistScript="/opt/pihole/whitelist.sh" +export blacklistScript="/opt/pihole/blacklist.sh" # Handle redirecting to specific functions based on arguments