# Some distros vary slightly so these fixes for dependencies may apply
# on Ubuntu 18.04.1 LTS we need to add the universe repository to gain access to dhcpcd5
@ -291,7 +294,7 @@ if is_command apt-get ; then
if awk 'BEGIN{a=1;b=0}/bionic main/{a=0}/bionic.*universe/{b=1}END{exit a + b}'${APT_SOURCES};then
if ! whiptail --defaultno --title "Dependencies Require Update to Allowed Repositories" --yesno "Would you like to enable 'universe' repository?\\n\\nThis repository is required by the following packages:\\n\\n- dhcpcd5""${r}""${c}";then
printf" %b Aborting installation: Dependencies could not be installed.\\n""${CROSS}"
exit1# exit the installer
exit1
else
printf" %b Enabling universe package repository for Ubuntu Bionic\\n""${INFO}"
cp -p ${APT_SOURCES}${APT_SOURCES}.backup # Backup current repo list
@ -323,7 +326,8 @@ if is_command apt-get ; then
phpInsNewer=true
fi
fi
# Check if installed php is v 7.0, or newer to determine packages to install
# Several other packages depend on the version of PHP. If PHP is not installed, or an insufficient version,
# those packages should fall back to the default (latest?)
if[["$phpInsNewer" !=true]];then
# Prefer the php metapackage if it's there
if apt-cache show php > /dev/null 2>&1;then
@ -337,7 +341,8 @@ if is_command apt-get ; then
exit1
fi
else
# Newer php is installed, its common, cgi & sqlite counterparts are deps
# Else, PHP is already installed at a version beyond v7.0, so the additional packages
# should match version with the current PHP version.
phpVer="php$phpInsMajor.$phpInsMinor"
fi
# We also need the correct version for `php-sqlite` (which differs across distros)
@ -349,13 +354,12 @@ if is_command apt-get ; then
printf" %b Aborting installation: No SQLite PHP module was found in APT repository.\\n""${CROSS}"
exit1
fi
# Since our install script is so large, we need several other programs to successfully get a machine provisioned
# These programs are stored in an array so they can be looped through later
# Packages required to run this install script (stored as an array)
INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig bind-utils)
@ -476,7 +480,7 @@ elif is_command rpm ; then
# Warn user of unsupported version of Fedora or CentOS
if ! whiptail --defaultno --title "Unsupported RPM based distribution" --yesno "Would you like to continue installation on an unsupported RPM based distribution?\\n\\nPlease ensure the following packages have been installed manually:\\n\\n- lighttpd\\n- lighttpd-fastcgi\\n- PHP version 7+""${r}""${c}";then
printf" %b Aborting installation due to unsupported RPM based distribution\\n""${CROSS}"
exit# exit the installer
exit
else
printf" %b Continuing installation with unsupported RPM based distribution\\n""${INFO}"
fi
@ -540,7 +544,8 @@ make_repo() {
# Check current branch. If it is master, then reset to the latest available tag.
# In case extra commits have been added after tagging/release (i.e in case of metadata updates/README.MD tweaks)
curBranch=$(git rev-parse --abbrev-ref HEAD)
if[["${curBranch}"=="master"]];then#If we're calling make_repo() then it should always be master, we may not need to check.
if[["${curBranch}"=="master"]];then
# If we're calling make_repo() then it should always be master, we may not need to check.
# A function that combines the functions previously made
# A function that combines the previous git functions to update or clone a repo
getGitFiles(){
# Setup named variables for the git repos
# We need the directory
@ -613,9 +618,8 @@ getGitFiles() {
# Attempt to make the repository, showing an error on failure
make_repo "${directory}""${remoteRepo}"||{printf"\\n %bError: Could not update local repository. Contact support.%b\\n""${COL_LIGHT_RED}""${COL_NC}";exit 1;}
fi
# echo a blank line
echo""
# and return success?
# Success via one of the two branches, as the commands would exit if they failed.
return0
}
@ -637,7 +641,7 @@ resetRepo() {
printf"%b %b %s\\n""${OVER}""${TICK}""${str}"
# Return to where we came from
popd&> /dev/null ||return1
# Returning success anyway?
# Function succeeded, as "git reset" would have triggered a return earlier if it failed
return0
}
@ -689,7 +693,7 @@ welcomeDialogs() {
In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." "${r}" "${c}"
}
# A function that let's the user pick an interface to use with Pi-hole
# A function that lets the user pick an interface to use with Pi-hole
chooseInterface(){
# Turn the available interfaces into an array so it can be used with a whiptail dialog
localinterfacesArray=()
@ -713,7 +717,7 @@ chooseInterface() {
else
# While reading through the available interfaces
whileread -r line;do
# use a variable to set the option as OFF to begin with
# Use a variable to set the option as OFF to begin with
mode="OFF"
# If it's the first loop,
if[["${firstLoop}" -eq 1]];then
@ -747,9 +751,9 @@ chooseInterface() {
testIPv6(){
# first will contain fda2 (ULA)
printf -v first "%s""${1%%:*}"
# value1 will contain 253 which is the decimal value corresponding to 0xfd
# value1 will contain 253 which is the decimal value corresponding to 0xFD
value1=$(((0x$first)/256))
# will contain 162 which is the decimal value corresponding to 0xa2
# value2 will contain 162 which is the decimal value corresponding to 0xA2
value2=$(((0x$first)%256))
# the ULA test is testing for fc00::/7 according to RFC 4193
if(((value1&254)==252));then
@ -779,8 +783,9 @@ useIPv6dialog() {
result=$(testIPv6 "$i")
# If it's a ULA address, use it and store it as a global variable
[["${result}"=="ULA"]]&&ULA_ADDRESS="${i%/*}"
# If it's a GUA address, we can still use it si store it as a global variable
# If it's a GUA address, use it and store it as a global variable
[["${result}"=="GUA"]]&&GUA_ADDRESS="${i%/*}"
# Else if it's a Link-local address, we cannot use it, so just continue
done
# Determine which address to be used: Prefer ULA over GUA or don't use any if none found
@ -858,7 +863,6 @@ use4andor6() {
fi
}
#
getStaticIPv4Settings(){
# Local, named variables
local ipSettingsCorrect
@ -905,9 +909,9 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
fi
}
# configure networking via dhcpcd
# Configure networking via dhcpcd
setDHCPCD(){
# check if the IP is already in the file
# Check if the IP is already in the file
if grep -q "${IPV4_ADDRESS}" /etc/dhcpcd.conf;then
printf" %b Static IP already configured\\n""${INFO}"
# If it's not,
@ -925,8 +929,8 @@ setDHCPCD() {
fi
}
# configure networking ifcfg-xxxx file found at /etc/sysconfig/network-scripts/
# this function requires the full path of an ifcfg file passed as an argument
# Configure networking ifcfg-xxxx file found at /etc/sysconfig/network-scripts/
# This function requires the full path of an ifcfg file passed as an argument
setIFCFG(){
# Local, named variables
local IFCFG_FILE
@ -934,12 +938,11 @@ setIFCFG() {
local CIDR
IFCFG_FILE=$1
printf -v IPADDR "%s""${IPV4_ADDRESS%%/*}"
# check if the desired IP is already set
# Check if the desired IP is already set
if grep -Eq "${IPADDR}(\\b|\\/)""${IFCFG_FILE}";then
printf" %b Static IP already configured\\n""${INFO}"
# Otherwise,
else
# Put the IP in variables without the CIDR notation
# Otherwise, put the IP in variables without the CIDR notation
printf -v CIDR "%s""${IPV4_ADDRESS##*/}"
# Backup existing interface configuration:
cp -p "${IFCFG_FILE}""${IFCFG_FILE}".pihole.orig
@ -981,24 +984,23 @@ setStaticIPv4() {
return0
fi
fi
# For the Debian family, if dhcpcd.conf exists,
# For the Debian family, if dhcpcd.conf exists then we can just configure using DHCPD.
if[[ -f "/etc/dhcpcd.conf"]];then
# configure networking via dhcpcd
setDHCPCD
return0
fi
# If a DHCPCD config file was not found, check for an ifcfg config file based on interface name
# If a DHCPCD config file was not found, check for an ifcfg config file based on the interface name
# Dialog for the user to enter custom upstream servers
# Prompt the user to enter custom upstream servers
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)||\
{printf" %bCancel was selected, exiting installer%b\\n""${COL_LIGHT_RED}""${COL_NC}";exit 1;}
# Clean user input and replace whitespace with comma.
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP""One or both entered IP addresses were invalid. Please try again.\\n\\n DNS Server 1: $PIHOLE_DNS_1\\n DNS Server 2: ${PIHOLE_DNS_2}"${r}${c}
# and set the variables back to nothing
# set the variables back to nothing,
if[["${PIHOLE_DNS_1}"=="${strInvalid}"]];then
PIHOLE_DNS_1=""
fi
if[["${PIHOLE_DNS_2}"=="${strInvalid}"]];then
PIHOLE_DNS_2=""
fi
# Since the settings will not work, stay in the loop
# and continue the loop.
DNSSettingsCorrect=False
# Otherwise,
else
# Show the settings
# Otherwise, show the DNS setting to the user, and break the loop if they confirm them.
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 valid
DNSSettingsCorrect=True
# Otherwise,
else
# If the settings are wrong, the loop continues
DNSSettingsCorrect=False
fi
fi
done
else
# Save the old Internal Field Separator in a variable
# Save the old Internal Field Separator in a variable,
OIFS=$IFS
# and set the new one to newline
IFS=$'\n'
@ -1187,16 +1184,16 @@ setLogging() {
# Get the user's choice
LogChoices=$("${LogToggleCommand[@]}""${LogChooseOptions[@]}" 2>&1 >/dev/tty)||(printf" %bCancel was selected, exiting installer%b\\n""${COL_LIGHT_RED}""${COL_NC}"&&exit 1)
case${LogChoices} in
# If it's on
# If it's on,
"On (Recommended)")
printf" %b Logging On.\\n""${INFO}"
# Set the GLOBAL variable to true so we know what they selected
# set the GLOBAL variable setting to true
QUERY_LOGGING=true
;;
# Otherwise, it's off,
Off)
printf" %b Logging Off.\\n""${INFO}"
# So set it to false
# set the GLOBAL variable setting to false
QUERY_LOGGING=false
;;
esac
@ -1252,7 +1249,7 @@ setAdminFlag() {
;;
esac
# Request user to install web server, if it has not been deselected before (INSTALL_WEB_SERVER=true is default).
# If the user wants to install the Web admin interface (i.e. it has not been deselected above)
if[["${INSTALL_WEB_SERVER}"==true]];then
# Get list of required PHP modules, excluding base package (common) and handler (cgi)
local i php_modules
@ -1291,18 +1288,18 @@ chooseBlocklists() {
# In a variable, show the choices available; exit if Cancel is selected