Removed updatePihole() function and updated if/then statements in installPihole() and main(). Corrected minor typos.
Signed-off-by: Fauxsys <fiber.cipher@gmail.com>
# Pi-hole itself has several dependencies that also need to be installed
@ -236,7 +236,7 @@ fi
# A function for checking if a folder is a git repository
is_repo(){
# Use a named, local variable instead of the vague $1, which is the first arguement passed to this function
# Use a named, local variable instead of the vague $1, which is the first argument passed to this function
# These local variables should always be lowercase
localdirectory="${1}"
# A local variable for the current directory
@ -312,7 +312,7 @@ update_repo() {
git pull --quiet &> /dev/null ||return$?
# Show a completion message
echo -e "${OVER}${TICK}${str}"
# Move back into the oiginal directory
# Move back into the original directory
cd"${curdir}"&> /dev/null ||return1
return0
}
@ -324,7 +324,7 @@ getGitFiles() {
localdirectory="${1}"
# as well as the repo URL
localremoteRepo="${2}"
# A local varible containing the message to be displayed
# A local variable containing the message to be displayed
localstr="Check for existing repository in ${1}"
# Show the message
echo -ne "${INFO}${str}..."
@ -338,7 +338,7 @@ getGitFiles() {
else
# Show an error
echo -e "${OVER}${CROSS}${str}"
# Attempt to make the repository, showing an error on falure
# Attempt to make the repository, showing an error on failure
make_repo "${directory}""${remoteRepo}"||{echo -e "\\n ${COL_LIGHT_RED}Error: Could not update local repository. Contact support.${COL_NC}";exit 1;}
fi
# echo a blank line
@ -349,11 +349,11 @@ getGitFiles() {
# Reset a repo to get rid of any local changed
resetRepo(){
# Use named varibles for arguments
# Use named variables for arguments
localdirectory="${1}"
# Move into the directory
cd"${directory}"&> /dev/null ||return1
# Store the message in a varible
# Store the message in a variable
str="Resetting repository within ${1}..."
# Show the message
echo -ne "${INFO}${str}"
@ -391,7 +391,7 @@ get_available_interfaces() {
# A function for displaying the dialogs the user sees when first running the installer
welcomeDialogs(){
# Display the welcome dialog using an approriately sized window via the calculation conducted earlier in the script
# Display the welcome dialog using an appropriately sized window via the calculation conducted earlier in the script
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer""\\n\\nThis installer will transform your device into a network-wide ad blocker!"${r}${c}
# Request that users donate if they enjoy the software since we all work on it in our free time
@ -409,7 +409,7 @@ verifyFreeDiskSpace() {
# 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.)
# - Fourdee: Local ensures the variable is only created, and accessible within this function/void. Generally considered a "good" coding practice for non-global variables.
localstr="Disk space check"
# Reqired space in KB
# Required space in KB
localrequired_free_kilobytes=51200
# Calculate existing free space on this machine
local existing_free_kilobytes
@ -491,7 +491,7 @@ chooseInterface() {
chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface (press space to select)"${r}${c}${interfaceCount})
# Now run the command using the interfaces saved into the array
# Save the old Interfal Field Separator in a variable
# Save the old Internal Field Separator in a variable
OIFS=$IFS
# and set the new one to a dot (period)
IFS='.'
@ -863,7 +863,7 @@ setDNS() {
fi
# Dialog for the user to enter custom upstream servers
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\\n\\nFor example '8.8.8.8, 8.8.4.4'" ${r}${c}"${prePopulate}" 3>&1 1>&2 2>&3)||\
piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), separated by a comma.\\n\\nFor example '8.8.8.8, 8.8.4.4'" ${r}${c}"${prePopulate}" 3>&1 1>&2 2>&3)||\
{echo -e "${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}";exit 1;}
#
PIHOLE_DNS_1=$(echo"${piholeDNS}"| sed 's/[, \t]\+/,/g'| awk -F, '{print$1}')
@ -890,11 +890,11 @@ setDNS() {
fi
# Since the settings will not work, stay in the loop
DNSSettingsCorrect=False
# Othwerise,
# Otherwise,
else
# Show the settings
if(whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\\n DNS Server 1: $PIHOLE_DNS_1\\n DNS Server 2: ${PIHOLE_DNS_2}"${r}${c});then
# and break from the loop since the servers are vaid
# and break from the loop since the servers are valid
DNSSettingsCorrect=True
# Otherwise,
else
@ -928,7 +928,7 @@ setLogging() {
# Set the GLOBAL variable to true so we know what they selected
QUERY_LOGGING=true
;;
# Othwerise, it's off,
# Otherwise, it's off,
Off)
echo -e "${INFO} Logging Off."
# So set it to false
@ -1096,7 +1096,7 @@ installScripts() {
cd"${PI_HOLE_LOCAL_REPO}"
# Install the scripts by:
# -o setting the owner to the user
# -Dm755 create all leading components of destiantion except the last, then copy the source to the destiantion and setting the permissions to 755
# -Dm755 create all leading components of destination except the last, then copy the source to the destination and setting the permissions to 755
# ask if the user wants to install Pi-hole's default firwall rules
# ask if the user wants to install Pi-hole's default firewall rules
whiptail --title "Firewall in use" --yesno "We have detected a running firewall\\n\\nPi-hole currently requires HTTP and DNS port access.\\n\\n\\n\\nInstall Pi-hole default firewall rules?"${r}${c}||\
{echo -e "${INFO} Not installing firewall rulesets.";return 0;}
echo -e "${TICK} Configuring FirewallD for httpd and pihole-FTL"
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;' "${setupVars}"
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;' "${setupVars}"
fi
# echo the information to the user
{
@ -1557,6 +1557,27 @@ installLogrotate() {
echo -e "${OVER}${TICK}${str}"
}
# At some point in the future this list can be pruned, for now we'll need it to ensure updates don't break.
# Refactoring of install script has changed the name of a couple of variables. Sort them out here.
accountForRefactor(){
sed -i 's/piholeInterface/PIHOLE_INTERFACE/g'${setupVars}
sed -i 's/IPv4_address/IPV4_ADDRESS/g'${setupVars}
sed -i 's/IPv4addr/IPV4_ADDRESS/g'${setupVars}
sed -i 's/IPv6_address/IPV6_ADDRESS/g'${setupVars}
sed -i 's/piholeIPv6/IPV6_ADDRESS/g'${setupVars}
sed -i 's/piholeDNS1/PIHOLE_DNS_1/g'${setupVars}
sed -i 's/piholeDNS2/PIHOLE_DNS_2/g'${setupVars}
sed -i 's/^INSTALL_WEB=/INSTALL_WEB_INTERFACE=/'${setupVars}
# Add 'INSTALL_WEB_SERVER', if its not been applied already: https://github.com/pi-hole/pi-hole/pull/2115
if ! grep -q '^INSTALL_WEB_SERVER='${setupVars};then
localwebserver_installed=false
if grep -q '^INSTALL_WEB_INTERFACE=true'${setupVars};then