mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Standardize function declaration
There were no fewer than three styles of function declaration going on in these files, so I attempted to standardize them to the typical myfucn() { } style.
This commit is contained in:
parent
16e4f79f09
commit
28eeaf201b
9 changed files with 55 additions and 63 deletions
|
@ -10,8 +10,7 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
helpFunc()
|
helpFunc() {
|
||||||
{
|
|
||||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
@ -71,7 +70,7 @@ if [[ -f ${piholeIPv6file} ]];then
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HandleOther(){
|
HandleOther() {
|
||||||
#check validity of domain
|
#check validity of domain
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||||
if [ -z "$validDomain" ]; then
|
if [ -z "$validDomain" ]; then
|
||||||
|
@ -81,7 +80,7 @@ HandleOther(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
PopBlacklistFile(){
|
PopBlacklistFile() {
|
||||||
#check blacklist file exists, and if not, create it
|
#check blacklist file exists, and if not, create it
|
||||||
if [[ ! -f ${blacklist} ]];then
|
if [[ ! -f ${blacklist} ]];then
|
||||||
touch ${blacklist}
|
touch ${blacklist}
|
||||||
|
@ -95,7 +94,7 @@ PopBlacklistFile(){
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
AddDomain(){
|
AddDomain() {
|
||||||
#| sed 's/\./\\./g'
|
#| sed 's/\./\\./g'
|
||||||
bool=false
|
bool=false
|
||||||
grep -Ex -q "$1" ${blacklist} || bool=true
|
grep -Ex -q "$1" ${blacklist} || bool=true
|
||||||
|
@ -114,7 +113,7 @@ AddDomain(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveDomain(){
|
RemoveDomain() {
|
||||||
|
|
||||||
bool=false
|
bool=false
|
||||||
grep -Ex -q "$1" ${blacklist} || bool=true
|
grep -Ex -q "$1" ${blacklist} || bool=true
|
||||||
|
@ -133,7 +132,7 @@ RemoveDomain(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ModifyHostFile(){
|
ModifyHostFile() {
|
||||||
if ${addmode}; then
|
if ${addmode}; then
|
||||||
#add domains to the hosts file
|
#add domains to the hosts file
|
||||||
if [[ -r ${blacklist} ]];then
|
if [[ -r ${blacklist} ]];then
|
||||||
|
|
|
@ -17,7 +17,7 @@ gravity="/etc/pihole/gravity.list"
|
||||||
|
|
||||||
today=$(date "+%b %e")
|
today=$(date "+%b %e")
|
||||||
|
|
||||||
CalcBlockedDomains(){
|
CalcBlockedDomains() {
|
||||||
CheckIPv6
|
CheckIPv6
|
||||||
if [ -e "$gravity" ]; then
|
if [ -e "$gravity" ]; then
|
||||||
#Are we IPV6 or IPV4?
|
#Are we IPV6 or IPV4?
|
||||||
|
@ -33,7 +33,7 @@ CalcBlockedDomains(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CalcQueriesToday(){
|
CalcQueriesToday() {
|
||||||
if [ -e "$piLog" ];then
|
if [ -e "$piLog" ];then
|
||||||
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
||||||
else
|
else
|
||||||
|
@ -41,7 +41,7 @@ CalcQueriesToday(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CalcblockedToday(){
|
CalcblockedToday() {
|
||||||
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
||||||
blockedToday=$(cat ${piLog} | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
blockedToday=$(cat ${piLog} | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
||||||
else
|
else
|
||||||
|
@ -49,7 +49,7 @@ CalcblockedToday(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CalcPercentBlockedToday(){
|
CalcPercentBlockedToday() {
|
||||||
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
||||||
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
||||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||||
|
@ -61,7 +61,7 @@ CalcPercentBlockedToday(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckIPv6(){
|
CheckIPv6() {
|
||||||
piholeIPv6file="/etc/pihole/.useIPv6"
|
piholeIPv6file="/etc/pihole/.useIPv6"
|
||||||
if [[ -f ${piholeIPv6file} ]];then
|
if [[ -f ${piholeIPv6file} ]];then
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||||
|
@ -69,7 +69,7 @@ CheckIPv6(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
outputJSON(){
|
outputJSON() {
|
||||||
CalcQueriesToday
|
CalcQueriesToday
|
||||||
CalcblockedToday
|
CalcblockedToday
|
||||||
CalcPercentBlockedToday
|
CalcPercentBlockedToday
|
||||||
|
@ -79,7 +79,7 @@ outputJSON(){
|
||||||
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
||||||
}
|
}
|
||||||
|
|
||||||
normalChrono(){
|
normalChrono() {
|
||||||
for (( ; ; ))
|
for (( ; ; ))
|
||||||
do
|
do
|
||||||
clear
|
clear
|
||||||
|
@ -121,7 +121,7 @@ normalChrono(){
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
displayHelp(){
|
displayHelp() {
|
||||||
echo "::: Displays stats about your piHole!"
|
echo "::: Displays stats about your piHole!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: sudo pihole -c [optional:-j]"
|
echo "::: Usage: sudo pihole -c [optional:-j]"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#/usr/bin/env bash
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
# (c) 2015, 2016 by Jacob Salmela
|
# (c) 2015, 2016 by Jacob Salmela
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
|
@ -61,11 +61,11 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Private functions exist here ###
|
### Private functions exist here ###
|
||||||
function log_write {
|
log_write() {
|
||||||
echo "$1" >> "${DEBUG_LOG}"
|
echo "$1" >> "${DEBUG_LOG}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function version_check {
|
version_check() {
|
||||||
log_write "############################################################"
|
log_write "############################################################"
|
||||||
log_write "########## Installed Versions ##########"
|
log_write "########## Installed Versions ##########"
|
||||||
log_write "############################################################"
|
log_write "############################################################"
|
||||||
|
@ -83,7 +83,7 @@ function version_check {
|
||||||
php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed."
|
php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed."
|
||||||
}
|
}
|
||||||
|
|
||||||
function distro_check {
|
distro_check() {
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "######## Installed OS Distribution #########" >> ${DEBUG_LOG}
|
echo "######## Installed OS Distribution #########" >> ${DEBUG_LOG}
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
@ -96,7 +96,7 @@ function distro_check {
|
||||||
echo >> ${DEBUG_LOG}
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ip_check {
|
ip_check() {
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "######## IP Address Information #########" >> ${DEBUG_LOG}
|
echo "######## IP Address Information #########" >> ${DEBUG_LOG}
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
@ -166,7 +166,7 @@ function ip_check {
|
||||||
echo >> ${DEBUG_LOG}
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostnameCheck {
|
hostnameCheck() {
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "######## Hostname Information #########" >> ${DEBUG_LOG}
|
echo "######## Hostname Information #########" >> ${DEBUG_LOG}
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
@ -188,7 +188,7 @@ function hostnameCheck {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function portCheck {
|
portCheck() {
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "######## Open Port Information #########" >> ${DEBUG_LOG}
|
echo "######## Open Port Information #########" >> ${DEBUG_LOG}
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
@ -200,7 +200,7 @@ function portCheck {
|
||||||
echo >> ${DEBUG_LOG}
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testResolver {
|
testResolver() {
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
echo "############ Resolver Functions Check ############" >> ${DEBUG_LOG}
|
echo "############ Resolver Functions Check ############" >> ${DEBUG_LOG}
|
||||||
echo "############################################################" >> ${DEBUG_LOG}
|
echo "############################################################" >> ${DEBUG_LOG}
|
||||||
|
@ -262,7 +262,7 @@ function testResolver {
|
||||||
echo >> ${DEBUG_LOG}
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkProcesses {
|
checkProcesses() {
|
||||||
echo "#######################################" >> ${DEBUG_LOG}
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "########### Processes Check ###########" >> ${DEBUG_LOG}
|
echo "########### Processes Check ###########" >> ${DEBUG_LOG}
|
||||||
echo "#######################################" >> ${DEBUG_LOG}
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
@ -279,7 +279,7 @@ function checkProcesses {
|
||||||
echo >> ${DEBUG_LOG}
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
function debugLighttpd {
|
debugLighttpd() {
|
||||||
echo "::: Writing lighttpd to debug log..."
|
echo "::: Writing lighttpd to debug log..."
|
||||||
echo "#######################################" >> ${DEBUG_LOG}
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
echo "############ lighttpd.conf ############" >> ${DEBUG_LOG}
|
echo "############ lighttpd.conf ############" >> ${DEBUG_LOG}
|
||||||
|
@ -420,7 +420,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||||
function dumpPiHoleLog {
|
dumpPiHoleLog() {
|
||||||
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
||||||
echo -e "::: Writing current Pi-hole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
|
echo -e "::: Writing current Pi-hole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
|
||||||
echo "#######################################" >> ${DEBUG_LOG}
|
echo "#######################################" >> ${DEBUG_LOG}
|
||||||
|
@ -439,7 +439,7 @@ function dumpPiHoleLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Anything to be done after capturing of pihole.log terminates
|
# Anything to be done after capturing of pihole.log terminates
|
||||||
function finalWork {
|
finalWork() {
|
||||||
echo "::: Finshed debugging!"
|
echo "::: Finshed debugging!"
|
||||||
echo "::: The debug log can be uploaded to Termbin.com for easier sharing."
|
echo "::: The debug log can be uploaded to Termbin.com for easier sharing."
|
||||||
read -r -p "::: Would you like to upload the log? [y/N] " response
|
read -r -p "::: Would you like to upload the log? [y/N] " response
|
||||||
|
|
|
@ -17,8 +17,7 @@ webInterfaceDir="/var/www/html/admin"
|
||||||
piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
|
piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
|
||||||
piholeFilesDir="/etc/.pihole"
|
piholeFilesDir="/etc/.pihole"
|
||||||
|
|
||||||
spinner()
|
spinner() {
|
||||||
{
|
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local delay=0.50
|
local delay=0.50
|
||||||
local spinstr='/-\|'
|
local spinstr='/-\|'
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
latest=false
|
latest=false
|
||||||
current=false
|
current=false
|
||||||
|
|
||||||
normalOutput(){
|
normalOutput() {
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ normalOutput(){
|
||||||
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"
|
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||||
}
|
}
|
||||||
|
|
||||||
webOutput(){
|
webOutput() {
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
do
|
do
|
||||||
case "$var" in
|
case "$var" in
|
||||||
|
@ -48,7 +48,7 @@ webOutput(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
coreOutput(){
|
coreOutput() {
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
do
|
do
|
||||||
case "$var" in
|
case "$var" in
|
||||||
|
@ -71,8 +71,7 @@ coreOutput(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
helpFunc()
|
helpFunc() {
|
||||||
{
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Show Pi-hole/Web Admin versions"
|
echo "::: Show Pi-hole/Web Admin versions"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
|
||||||
helpFunc()
|
helpFunc() {
|
||||||
{
|
|
||||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: pihole -w domain1 [domain2 ...]"
|
echo "::: Usage: pihole -w domain1 [domain2 ...]"
|
||||||
|
@ -71,7 +70,7 @@ if [[ -f ${piholeIPv6file} ]];then
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HandleOther(){
|
HandleOther() {
|
||||||
#check validity of domain
|
#check validity of domain
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
||||||
if [ -z "$validDomain" ]; then
|
if [ -z "$validDomain" ]; then
|
||||||
|
@ -81,7 +80,7 @@ HandleOther(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
PopWhitelistFile(){
|
PopWhitelistFile() {
|
||||||
#check whitelist file exists, and if not, create it
|
#check whitelist file exists, and if not, create it
|
||||||
if [[ ! -f ${whitelist} ]];then
|
if [[ ! -f ${whitelist} ]];then
|
||||||
touch ${whitelist}
|
touch ${whitelist}
|
||||||
|
@ -96,7 +95,7 @@ PopWhitelistFile(){
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
AddDomain(){
|
AddDomain() {
|
||||||
#| sed 's/\./\\./g'
|
#| sed 's/\./\\./g'
|
||||||
bool=false
|
bool=false
|
||||||
|
|
||||||
|
@ -118,7 +117,7 @@ AddDomain(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveDomain(){
|
RemoveDomain() {
|
||||||
|
|
||||||
bool=false
|
bool=false
|
||||||
grep -Ex -q "$1" ${whitelist} || bool=true
|
grep -Ex -q "$1" ${whitelist} || bool=true
|
||||||
|
@ -137,7 +136,7 @@ RemoveDomain(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ModifyHostFile(){
|
ModifyHostFile() {
|
||||||
if ${addmode}; then
|
if ${addmode}; then
|
||||||
#remove domains in from hosts file
|
#remove domains in from hosts file
|
||||||
if [[ -r ${whitelist} ]];then
|
if [[ -r ${whitelist} ]];then
|
||||||
|
|
|
@ -121,8 +121,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
####### FUNCTIONS ##########
|
####### FUNCTIONS ##########
|
||||||
spinner()
|
spinner() {
|
||||||
{
|
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local delay=0.50
|
local delay=0.50
|
||||||
local spinstr='/-\|'
|
local spinstr='/-\|'
|
||||||
|
@ -389,8 +388,7 @@ setStaticIPv4() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function valid_ip()
|
valid_ip() {
|
||||||
{
|
|
||||||
local ip=$1
|
local ip=$1
|
||||||
local stat=1
|
local stat=1
|
||||||
|
|
||||||
|
@ -406,7 +404,7 @@ function valid_ip()
|
||||||
return ${stat}
|
return ${stat}
|
||||||
}
|
}
|
||||||
|
|
||||||
setDNS(){
|
setDNS() {
|
||||||
DNSChooseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 6)
|
DNSChooseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 6)
|
||||||
DNSChooseOptions=(Google "" on
|
DNSChooseOptions=(Google "" on
|
||||||
OpenDNS "" off
|
OpenDNS "" off
|
||||||
|
@ -497,7 +495,7 @@ setDNS(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
version_check_dnsmasq(){
|
version_check_dnsmasq() {
|
||||||
# Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory
|
# Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory
|
||||||
local dnsmasq_conf="/etc/dnsmasq.conf"
|
local dnsmasq_conf="/etc/dnsmasq.conf"
|
||||||
local dnsmasq_conf_orig="/etc/dnsmasq.conf.orig"
|
local dnsmasq_conf_orig="/etc/dnsmasq.conf.orig"
|
||||||
|
@ -542,7 +540,7 @@ version_check_dnsmasq(){
|
||||||
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsmasq_conf}
|
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsmasq_conf}
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_legacy_scripts(){
|
remove_legacy_scripts() {
|
||||||
#Tidy up /usr/local/bin directory if installing over previous install.
|
#Tidy up /usr/local/bin directory if installing over previous install.
|
||||||
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug)
|
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug)
|
||||||
for i in "${oldFiles[@]}"; do
|
for i in "${oldFiles[@]}"; do
|
||||||
|
@ -642,7 +640,7 @@ update_pacakge_cache() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_package_updates_available(){
|
notify_package_updates_available() {
|
||||||
# Let user know if they have outdated packages on their system and
|
# Let user know if they have outdated packages on their system and
|
||||||
# advise them to run a package update at soonest possible.
|
# advise them to run a package update at soonest possible.
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
@ -659,7 +657,7 @@ notify_package_updates_available(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_dependent_packages(){
|
install_dependent_packages() {
|
||||||
# Install packages passed in via argument array
|
# Install packages passed in via argument array
|
||||||
# No spinner - conflicts with set -e
|
# No spinner - conflicts with set -e
|
||||||
declare -a argArray1=("${!1}")
|
declare -a argArray1=("${!1}")
|
||||||
|
@ -765,7 +763,7 @@ runGravity() {
|
||||||
/opt/pihole/gravity.sh
|
/opt/pihole/gravity.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
create_pihole_user(){
|
create_pihole_user() {
|
||||||
# Check if user pihole exists and create if not
|
# Check if user pihole exists and create if not
|
||||||
echo "::: Checking if user 'pihole' exists..."
|
echo "::: Checking if user 'pihole' exists..."
|
||||||
id -u pihole &> /dev/null && echo "::: User 'pihole' already exists" || (echo "::: User 'pihole' doesn't exist. Creating..." && useradd -r -s /usr/sbin/nologin pihole)
|
id -u pihole &> /dev/null && echo "::: User 'pihole' already exists" || (echo "::: User 'pihole' doesn't exist. Creating..." && useradd -r -s /usr/sbin/nologin pihole)
|
||||||
|
@ -876,7 +874,7 @@ The install log is in /etc/pihole.
|
||||||
View the web interface at http://pi.hole/admin or http://${IPv4_address%/*}/admin" ${r} ${c}
|
View the web interface at http://pi.hole/admin or http://${IPv4_address%/*}/admin" ${r} ${c}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_dialogs(){
|
update_dialogs() {
|
||||||
# reconfigure
|
# reconfigure
|
||||||
if [ "$reconfigure" = true ]; then
|
if [ "$reconfigure" = true ]; then
|
||||||
opt1a="Repair"
|
opt1a="Repair"
|
||||||
|
|
|
@ -58,8 +58,7 @@ else
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
spinner()
|
spinner() {
|
||||||
{
|
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local delay=0.50
|
local delay=0.50
|
||||||
local spinstr='/-\|'
|
local spinstr='/-\|'
|
||||||
|
@ -73,9 +72,9 @@ spinner()
|
||||||
printf " \b\b\b\b"
|
printf " \b\b\b\b"
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAndPurge {
|
removeAndPurge() {
|
||||||
# Purge dependencies
|
# Purge dependencies
|
||||||
echo ":::"
|
echo ":::"
|
||||||
for i in "${PIHOLE_DEPS[@]}"; do
|
for i in "${PIHOLE_DEPS[@]}"; do
|
||||||
package_check ${i} > /dev/null
|
package_check ${i} > /dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
@ -104,7 +103,7 @@ echo ":::"
|
||||||
removeNoPurge
|
removeNoPurge
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeNoPurge {
|
removeNoPurge() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Only web directories/files that are created by pihole should be removed.
|
# Only web directories/files that are created by pihole should be removed.
|
||||||
echo "::: Removing the Pi-hole Web server files..."
|
echo "::: Removing the Pi-hole Web server files..."
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
# Run this script as root or under sudo
|
# Run this script as root or under sudo
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
|
||||||
helpFunc()
|
helpFunc() {
|
||||||
{
|
|
||||||
echo "::: Pull in domains from adlists"
|
echo "::: Pull in domains from adlists"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: pihole -g"
|
echo "::: Usage: pihole -g"
|
||||||
|
@ -196,7 +195,7 @@ gravity_Schwarzchild() {
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
gravity_Blacklist(){
|
gravity_Blacklist() {
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries if they exist
|
||||||
echo -n "::: Running blacklist script to update HOSTS file...."
|
echo -n "::: Running blacklist script to update HOSTS file...."
|
||||||
${blacklistScript} -f -nr -q > /dev/null
|
${blacklistScript} -f -nr -q > /dev/null
|
||||||
|
|
Loading…
Reference in a new issue