"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "automated install/basic-install.sh" between
pi-hole-5.3.1.tar.gz and pi-hole-5.4.tar.gz

About: Pi-hole is a DNS sinkhole that protects your devices from unwanted content like Internet advertisements, without installing any client-side software.

basic-install.sh  (pi-hole-5.3.1):basic-install.sh  (pi-hole-5.4)
skipping to change at line 96 skipping to change at line 96
# Give settings their default values. These may be changed by prompts later in t he script. # Give settings their default values. These may be changed by prompts later in t he script.
QUERY_LOGGING=true QUERY_LOGGING=true
INSTALL_WEB_INTERFACE=true INSTALL_WEB_INTERFACE=true
PRIVACY_LEVEL=0 PRIVACY_LEVEL=0
CACHE_SIZE=10000 CACHE_SIZE=10000
if [ -z "${USER}" ]; then if [ -z "${USER}" ]; then
USER="$(id -un)" USER="$(id -un)"
fi fi
# Check if we are running on a real terminal and find the rows and columns # whiptail dialog dimensions: 20 rows and 70 chars width assures to fit on small
# If there is no real terminal, we will default to 80x24 screens and is known to hold all content.
if [ -t 0 ] ; then r=20
screen_size=$(stty size) c=70
else
screen_size="24 80"
fi
# Determine terminal rows and columns by parsing screen_size
printf -v rows '%d' "${screen_size%% *}"
printf -v columns '%d' "${screen_size##* }"
# Divide by two so the dialogs take up half of the screen, which looks nice.
r=$(( rows / 2 ))
c=$(( columns / 2 ))
# Unless the screen is tiny
r=$(( r < 20 ? 20 : r ))
c=$(( c < 70 ? 70 : c ))
######## Undocumented Flags. Shhh ######## ######## Undocumented Flags. Shhh ########
# These are undocumented flags; some of which we can use when repairing an insta llation # These are undocumented flags; some of which we can use when repairing an insta llation
# The runUnattended flag is one example of this # The runUnattended flag is one example of this
reconfigure=false reconfigure=false
runUnattended=false runUnattended=false
INSTALL_WEB_SERVER=true INSTALL_WEB_SERVER=true
# Check arguments for the undocumented flags # Check arguments for the undocumented flags
for var in "$@"; do for var in "$@"; do
case "$var" in case "$var" in
skipping to change at line 187 skipping to change at line 173
local check_command="$1" local check_command="$1"
command -v "${check_command}" >/dev/null 2>&1 command -v "${check_command}" >/dev/null 2>&1
} }
os_check() { os_check() {
if [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then if [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
# This function gets a list of supported OS versions from a TXT record a t versions.pi-hole.net # This function gets a list of supported OS versions from a TXT record a t versions.pi-hole.net
# and determines whether or not the script is running on one of those sy stems # and determines whether or not the script is running on one of those sy stems
local remote_os_domain valid_os valid_version valid_response detected_os detected_version display_warning cmdResult digReturnCode response local remote_os_domain valid_os valid_version valid_response detected_os detected_version display_warning cmdResult digReturnCode response
remote_os_domain="versions.pi-hole.net" remote_os_domain=${OS_CHECK_DOMAIN_NAME:-"versions.pi-hole.net"}
detected_os=$(grep "\bID\b" /etc/os-release | cut -d '=' -f2 | tr -d '"' ) detected_os=$(grep "\bID\b" /etc/os-release | cut -d '=' -f2 | tr -d '"' )
detected_version=$(grep VERSION_ID /etc/os-release | cut -d '=' -f2 | tr -d '"') detected_version=$(grep VERSION_ID /etc/os-release | cut -d '=' -f2 | tr -d '"')
cmdResult="$(dig +short -t txt ${remote_os_domain} @ns1.pi-hole.net 2>&1 ; echo $?)" cmdResult="$(dig +short -t txt "${remote_os_domain}" @ns1.pi-hole.net 2> &1; echo $?)"
# Gets the return code of the previous command (last line) # Gets the return code of the previous command (last line)
digReturnCode="${cmdResult##*$'\n'}" digReturnCode="${cmdResult##*$'\n'}"
if [ ! "${digReturnCode}" == "0" ]; then if [ ! "${digReturnCode}" == "0" ]; then
valid_response=false valid_response=false
else else
# Dig returned 0 (success), so get the actual response, and loop thr ough it to determine if the detected variables above are valid # Dig returned 0 (success), so get the actual response, and loop thr ough it to determine if the detected variables above are valid
response="${cmdResult%%$'\n'*}" response="${cmdResult%%$'\n'*}"
# If the value of ${response} is a single 0, then this is the return code, not an actual response. # If the value of ${response} is a single 0, then this is the return code, not an actual response.
if [ "${response}" == 0 ]; then if [ "${response}" == 0 ]; then
skipping to change at line 277 skipping to change at line 263
else else
printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GR EEN}" "${COL_NC}" printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GR EEN}" "${COL_NC}"
fi fi
else else
printf " %b %bPIHOLE_SKIP_OS_CHECK env variable set to true - installer will continue%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}" printf " %b %bPIHOLE_SKIP_OS_CHECK env variable set to true - installer will continue%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}"
fi fi
} }
# Compatibility # Compatibility
distro_check() { package_manager_detect() {
# If apt-get is installed, then we know it's part of the Debian family # If apt-get is installed, then we know it's part of the Debian family
if is_command apt-get ; then if is_command apt-get ; then
# Set some global variables here # Set some global variables here
# We don't set them earlier since the family might be Red Hat, so these valu es would be different # We don't set them earlier since the family might be Red Hat, so these valu es would be different
PKG_MANAGER="apt-get" PKG_MANAGER="apt-get"
# A variable to store the command used to update the package cache # A variable to store the command used to update the package cache
UPDATE_PKG_CACHE="${PKG_MANAGER} update" UPDATE_PKG_CACHE="${PKG_MANAGER} update"
# The command we will use to actually install packages # The command we will use to actually install packages
PKG_INSTALL=("${PKG_MANAGER}" -qq --no-install-recommends install) PKG_INSTALL=("${PKG_MANAGER}" -qq --no-install-recommends install)
# grep -c will return 1 if there are no matches. This is an acceptable condi tion, so we OR TRUE to prevent set -e exiting the script. # grep -c will return 1 if there are no matches. This is an acceptable condi tion, so we OR TRUE to prevent set -e exiting the script.
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Ins t || true" PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Ins t || true"
# 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 acces
s to dhcpcd5
APT_SOURCES="/etc/apt/sources.list"
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 Allowe
d Repositories" --yesno "Would you like to enable 'universe' repository?\\n\\nTh
is repository is required by the following packages:\\n\\n- dhcpcd5" "${r}" "${c
}"; then
printf " %b Aborting installation: Dependencies could not be instal
led.\\n" "${CROSS}"
exit 1
else
printf " %b Enabling universe package repository for Ubuntu Bionic\
\n" "${INFO}"
cp -p ${APT_SOURCES} ${APT_SOURCES}.backup # Backup current repo lis
t
printf " %b Backed up current configuration to %s\\n" "${TICK}" "${
APT_SOURCES}.backup"
add-apt-repository universe
printf " %b Enabled %s\\n" "${TICK}" "'universe' repository"
fi
fi
# Update package cache. This is required already here to assure apt-cache ca lls have package lists available. # Update package cache. This is required already here to assure apt-cache ca lls have package lists available.
update_package_cache || exit 1 update_package_cache || exit 1
# Debian 7 doesn't have iproute2 so check if it's available first # Debian 7 doesn't have iproute2 so check if it's available first
if apt-cache show iproute2 > /dev/null 2>&1; then if apt-cache show iproute2 > /dev/null 2>&1; then
iproute_pkg="iproute2" iproute_pkg="iproute2"
# Otherwise, check if iproute is available # Otherwise, check if iproute is available
elif apt-cache show iproute > /dev/null 2>&1; then elif apt-cache show iproute > /dev/null 2>&1; then
iproute_pkg="iproute" iproute_pkg="iproute"
# Else print error and exit # Else print error and exit
else else
skipping to change at line 355 skipping to change at line 326
fi fi
# We also need the correct version for `php-sqlite` (which differs across di stros) # We also need the correct version for `php-sqlite` (which differs across di stros)
if apt-cache show "${phpVer}-sqlite3" > /dev/null 2>&1; then if apt-cache show "${phpVer}-sqlite3" > /dev/null 2>&1; then
phpSqlite="sqlite3" phpSqlite="sqlite3"
elif apt-cache show "${phpVer}-sqlite" > /dev/null 2>&1; then elif apt-cache show "${phpVer}-sqlite" > /dev/null 2>&1; then
phpSqlite="sqlite" phpSqlite="sqlite"
else else
printf " %b Aborting installation: No SQLite PHP module was found in AP T repository.\\n" "${CROSS}" printf " %b Aborting installation: No SQLite PHP module was found in AP T repository.\\n" "${CROSS}"
exit 1 exit 1
fi fi
# Packages required to perfom the os_check (stored as an array)
OS_CHECK_DEPS=(grep dnsutils)
# Packages required to run this install script (stored as an array) # Packages required to run this install script (stored as an array)
INSTALLER_DEPS=(dhcpcd5 git "${iproute_pkg}" whiptail dnsutils) INSTALLER_DEPS=(git "${iproute_pkg}" whiptail)
# Packages required to run Pi-hole (stored as an array) # Packages required to run Pi-hole (stored as an array)
PIHOLE_DEPS=(cron curl iputils-ping lsof netcat psmisc sudo unzip wget idn2 sqlite3 libcap2-bin dns-root-data libcap2) PIHOLE_DEPS=(cron curl iputils-ping lsof netcat psmisc sudo unzip idn2 sqlit e3 libcap2-bin dns-root-data libcap2)
# Packages required for the Web admin interface (stored as an array) # Packages required for the Web admin interface (stored as an array)
# It's useful to separate this from Pi-hole, since the two repos are also se tup separately # It's useful to separate this from Pi-hole, since the two repos are also se tup separately
PIHOLE_WEB_DEPS=(lighttpd "${phpVer}-common" "${phpVer}-cgi" "${phpVer}-${ph PIHOLE_WEB_DEPS=(lighttpd "${phpVer}-common" "${phpVer}-cgi" "${phpVer}-${ph
pSqlite}" "${phpVer}-xml" "${phpVer}-json" "${phpVer}-intl") pSqlite}" "${phpVer}-xml" "${phpVer}-intl")
# Prior to PHP8.0, JSON functionality is provided as dedicated module, requi
red by Pi-hole AdminLTE: https://www.php.net/manual/json.installation.php
if [[ "${phpInsNewer}" != true || "${phpInsMajor}" -lt 8 ]]; then
PIHOLE_WEB_DEPS+=("${phpVer}-json")
fi
# The Web server user, # The Web server user,
LIGHTTPD_USER="www-data" LIGHTTPD_USER="www-data"
# group, # group,
LIGHTTPD_GROUP="www-data" LIGHTTPD_GROUP="www-data"
# and config file # and config file
LIGHTTPD_CFG="lighttpd.conf.debian" LIGHTTPD_CFG="lighttpd.conf.debian"
# This function waits for dpkg to unlock, which signals that the previous ap t-get command has finished. # This function waits for dpkg to unlock, which signals that the previous ap t-get command has finished.
test_dpkg_lock() { test_dpkg_lock() {
i=0 i=0
skipping to change at line 397 skipping to change at line 374
# Then check if dnf or yum is the package manager # Then check if dnf or yum is the package manager
if is_command dnf ; then if is_command dnf ; then
PKG_MANAGER="dnf" PKG_MANAGER="dnf"
else else
PKG_MANAGER="yum" PKG_MANAGER="yum"
fi fi
# These variable names match the ones in the Debian family. See above for an explanation of what they are for. # These variable names match the ones in the Debian family. See above for an explanation of what they are for.
PKG_INSTALL=("${PKG_MANAGER}" install -y) PKG_INSTALL=("${PKG_MANAGER}" install -y)
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.sr c)' | wc -l" PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.sr c)' | wc -l"
INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig bind-utils) OS_CHECK_DEPS=(grep bind-utils)
INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig)
PIHOLE_DEPS=(cronie curl findutils nmap-ncat sudo unzip libidn2 psmisc sqlit e libcap lsof) PIHOLE_DEPS=(cronie curl findutils nmap-ncat sudo unzip libidn2 psmisc sqlit e libcap lsof)
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo php-xm l php-json php-intl) PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo php-xm l php-json php-intl)
LIGHTTPD_USER="lighttpd" LIGHTTPD_USER="lighttpd"
LIGHTTPD_GROUP="lighttpd" LIGHTTPD_GROUP="lighttpd"
LIGHTTPD_CFG="lighttpd.conf.fedora" LIGHTTPD_CFG="lighttpd.conf.fedora"
# If the host OS is Fedora, # If the host OS is Fedora,
if grep -qiE 'fedora|fedberry' /etc/redhat-release; then if grep -qiE 'fedora|fedberry' /etc/redhat-release; then
# all required packages should be available by default with the latest f edora release # all required packages should be available by default with the latest f edora release
: # continue : # continue
# or if host OS is CentOS, # or if host OS is CentOS,
skipping to change at line 689 skipping to change at line 667
# A function for displaying the dialogs the user sees when first running the ins taller # A function for displaying the dialogs the user sees when first running the ins taller
welcomeDialogs() { welcomeDialogs() {
# Display the welcome dialog using an appropriately sized window via the cal culation conducted earlier in the script # Display the welcome dialog using an appropriately sized window via the cal culation 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 blocke r!" "${r}" "${c}" whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer " "\\n\\nThis installer will transform your device into a network-wide ad blocke r!" "${r}" "${c}"
# Request that users donate if they enjoy the software since we all work on it in our free time # Request that users donate if they enjoy the software since we all work on it in our free time
whiptail --msgbox --backtitle "Plea" --title "Free and open source" "\\n\\nT he Pi-hole is free, but powered by your donations: https://pi-hole.net/donate/" "${r}" "${c}" whiptail --msgbox --backtitle "Plea" --title "Free and open source" "\\n\\nT he Pi-hole is free, but powered by your donations: https://pi-hole.net/donate/" "${r}" "${c}"
# Explain the need for a static address # Explain the need for a static address
whiptail --msgbox --backtitle "Initiating network interface" --title "Static IP Needed" "\\n\\nThe Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to fu nction properly. if whiptail --defaultno --backtitle "Initiating network interface" --title " Static IP Needed" --yesno "\\n\\nThe Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.
In the next section, you can choose to use your current network settings (DHCP) IMPORTANT: If you have not already done so, you must ensure that this device has
or to manually edit them." "${r}" "${c}" a static IP. Either through DHCP reservation, or by manually assigning one. Dep
ending on your operating system, there are many ways to achieve this.
Choose yes to indicate that you have understood this message, and wish to contin
ue" "${r}" "${c}"; then
#Nothing to do, continue
echo
else
printf " %b Installer exited at static IP message.\\n" "${INFO}"
exit 1
fi
} }
# A function that lets 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() { chooseInterface() {
# Turn the available interfaces into an array so it can be used with a whipt ail dialog # Turn the available interfaces into an array so it can be used with a whipt ail dialog
local interfacesArray=() local interfacesArray=()
# Number of available interfaces # Number of available interfaces
local interfaceCount local interfaceCount
# Whiptail variable storage # Whiptail variable storage
local chooseInterfaceCmd local chooseInterfaceCmd
skipping to change at line 844 skipping to change at line 830
# Set the values to true # Set the values to true
case ${choice} in case ${choice} in
IPv4 ) useIPv4=true;; IPv4 ) useIPv4=true;;
IPv6 ) useIPv6=true;; IPv6 ) useIPv6=true;;
esac esac
done done
# If IPv4 is to be used, # If IPv4 is to be used,
if [[ "${useIPv4}" ]]; then if [[ "${useIPv4}" ]]; then
# Run our function to get the information we need # Run our function to get the information we need
find_IPv4_information find_IPv4_information
getStaticIPv4Settings if [[ -f "/etc/dhcpcd.conf" ]]; then
setStaticIPv4 # configure networking via dhcpcd
getStaticIPv4Settings
setDHCPCD
fi
fi fi
# If IPv6 is to be used, # If IPv6 is to be used,
if [[ "${useIPv6}" ]]; then if [[ "${useIPv6}" ]]; then
# Run our function to get this information # Run our function to get this information
useIPv6dialog useIPv6dialog
fi fi
# Echo the information to the user # Echo the information to the user
printf " %b IPv4 address: %s\\n" "${INFO}" "${IPV4_ADDRESS}" printf " %b IPv4 address: %s\\n" "${INFO}" "${IPV4_ADDRESS}"
printf " %b IPv6 address: %s\\n" "${INFO}" "${IPV6_ADDRESS}" printf " %b IPv6 address: %s\\n" "${INFO}" "${IPV6_ADDRESS}"
# If neither protocol is selected, # If neither protocol is selected,
skipping to change at line 930 skipping to change at line 919
static routers=${IPv4gw} static routers=${IPv4gw}
static domain_name_servers=${PIHOLE_DNS_1} ${PIHOLE_DNS_2}" | tee -a /et c/dhcpcd.conf >/dev/null static domain_name_servers=${PIHOLE_DNS_1} ${PIHOLE_DNS_2}" | tee -a /et c/dhcpcd.conf >/dev/null
# Then use the ip command to immediately set the new address # Then use the ip command to immediately set the new address
ip addr replace dev "${PIHOLE_INTERFACE}" "${IPV4_ADDRESS}" ip addr replace dev "${PIHOLE_INTERFACE}" "${IPV4_ADDRESS}"
# Also give a warning that the user may need to reboot their system # Also give a warning that the user may need to reboot their system
printf " %b Set IP address to %s\\n" "${TICK}" "${IPV4_ADDRESS%/*}" printf " %b Set IP address to %s\\n" "${TICK}" "${IPV4_ADDRESS%/*}"
printf " %b You may need to restart after the install is complete\\n" " ${INFO}" printf " %b You may need to restart after the install is complete\\n" " ${INFO}"
fi 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
setIFCFG() {
# Local, named variables
local IFCFG_FILE
local IPADDR
local CIDR
IFCFG_FILE=$1
printf -v IPADDR "%s" "${IPV4_ADDRESS%%/*}"
# Check if the desired IP is already set
if grep -Eq "${IPADDR}(\\b|\\/)" "${IFCFG_FILE}"; then
printf " %b Static IP already configured\\n" "${INFO}"
else
# 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
# Build Interface configuration file using the GLOBAL variables we have
{
echo "# Configured via Pi-hole installer"
echo "DEVICE=$PIHOLE_INTERFACE"
echo "BOOTPROTO=none"
echo "ONBOOT=yes"
echo "IPADDR=$IPADDR"
echo "PREFIX=$CIDR"
echo "GATEWAY=$IPv4gw"
echo "DNS1=$PIHOLE_DNS_1"
echo "DNS2=$PIHOLE_DNS_2"
echo "USERCTL=no"
}> "${IFCFG_FILE}"
chmod 644 "${IFCFG_FILE}"
chown root:root "${IFCFG_FILE}"
# Use ip to immediately set the new address
ip addr replace dev "${PIHOLE_INTERFACE}" "${IPV4_ADDRESS}"
# If NetworkMangler command line interface exists and ready to mangle,
if is_command nmcli && nmcli general status &> /dev/null; then
# Tell NetworkManagler to read our new sysconfig file
nmcli con load "${IFCFG_FILE}" > /dev/null
fi
# Show a warning that the user may need to restart
printf " %b Set IP address to %s\\n You may need to restart after the
install is complete\\n" "${TICK}" "${IPV4_ADDRESS%%/*}"
fi
}
setStaticIPv4() {
# Local, named variables
local IFCFG_FILE
local CONNECTION_NAME
# If a static interface is already configured, we are done.
if [[ -r "/etc/sysconfig/network/ifcfg-${PIHOLE_INTERFACE}" ]]; then
if grep -q '^BOOTPROTO=.static.' "/etc/sysconfig/network/ifcfg-${PIHOLE_
INTERFACE}"; then
return 0
fi
fi
# For the Debian family, if dhcpcd.conf exists then we can just configure us
ing DHCPD.
if [[ -f "/etc/dhcpcd.conf" ]]; then
setDHCPCD
return 0
fi
# If a DHCPCD config file was not found, check for an ifcfg config file base
d on the interface name
if [[ -f "/etc/sysconfig/network-scripts/ifcfg-${PIHOLE_INTERFACE}" ]];then
# If it exists, then we can configure using IFCFG
IFCFG_FILE=/etc/sysconfig/network-scripts/ifcfg-${PIHOLE_INTERFACE}
setIFCFG "${IFCFG_FILE}"
return 0
fi
# If an ifcfg config does not exists for the interface name, search for one
based on the connection name via network manager
if is_command nmcli && nmcli general status &> /dev/null; then
CONNECTION_NAME=$(nmcli dev show "${PIHOLE_INTERFACE}" | grep 'GENERAL.C
ONNECTION' | cut -d: -f2 | sed 's/^System//' | xargs | tr ' ' '_')
IFCFG_FILE=/etc/sysconfig/network-scripts/ifcfg-${CONNECTION_NAME}
if [[ -f "${IFCFG_FILE}" ]];then
# If it exists,
setIFCFG "${IFCFG_FILE}"
return 0
else
printf " %b Warning: sysconfig network script not found. Creating $
{IFCFG_FILE}\\n" "${INFO}"
touch "${IFCFG_FILE}"
setIFCFG "${IFCFG_FILE}"
return 0
fi
fi
# If previous conditions failed, show an error and exit
printf " %b Warning: Unable to locate configuration file to set static IPv4
address\\n" "${INFO}"
exit 1
}
# Check an IP address to see if it is a valid one # Check an IP address to see if it is a valid one
valid_ip() { valid_ip() {
# Local, named variables # Local, named variables
local ip=${1} local ip=${1}
local stat=1 local stat=1
# Regex matching one IPv4 component, i.e. an integer from 0 to 255. # Regex matching one IPv4 component, i.e. an integer from 0 to 255.
# See https://tools.ietf.org/html/rfc1340 # See https://tools.ietf.org/html/rfc1340
local ipv4elem="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)"; local ipv4elem="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)";
# Regex matching an optional port (starting with '#') range of 1-65536 # Regex matching an optional port (starting with '#') range of 1-65536
skipping to change at line 1332 skipping to change at line 1234
} }
# Check if /etc/dnsmasq.conf is from pi-hole. If so replace with an original an d install new in .d directory # Check if /etc/dnsmasq.conf is from pi-hole. If so replace with an original an d install new in .d directory
version_check_dnsmasq() { version_check_dnsmasq() {
# Local, named variables # Local, named variables
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"
local dnsmasq_pihole_id_string="addn-hosts=/etc/pihole/gravity.list" local dnsmasq_pihole_id_string="addn-hosts=/etc/pihole/gravity.list"
local dnsmasq_pihole_id_string2="# Dnsmasq config for Pi-hole's FTLDNS" local dnsmasq_pihole_id_string2="# Dnsmasq config for Pi-hole's FTLDNS"
local dnsmasq_original_config="${PI_HOLE_LOCAL_REPO}/advanced/dnsmasq.conf.o riginal" local dnsmasq_original_config="${PI_HOLE_LOCAL_REPO}/advanced/dnsmasq.conf.o riginal"
local dnsmasq_pihole_01_snippet="${PI_HOLE_LOCAL_REPO}/advanced/01-pihole.co local dnsmasq_pihole_01_source="${PI_HOLE_LOCAL_REPO}/advanced/01-pihole.con
nf" f"
local dnsmasq_pihole_01_location="/etc/dnsmasq.d/01-pihole.conf" local dnsmasq_pihole_01_target="/etc/dnsmasq.d/01-pihole.conf"
local dnsmasq_rfc6761_06_source="${PI_HOLE_LOCAL_REPO}/advanced/06-rfc6761.c
onf"
local dnsmasq_rfc6761_06_target="/etc/dnsmasq.d/06-rfc6761.conf"
# If the dnsmasq config file exists # If the dnsmasq config file exists
if [[ -f "${dnsmasq_conf}" ]]; then if [[ -f "${dnsmasq_conf}" ]]; then
printf " %b Existing dnsmasq.conf found..." "${INFO}" printf " %b Existing dnsmasq.conf found..." "${INFO}"
# If a specific string is found within this file, we presume it's from o lder versions on Pi-hole, # If a specific string is found within this file, we presume it's from o lder versions on Pi-hole,
if grep -q "${dnsmasq_pihole_id_string}" "${dnsmasq_conf}" || if grep -q "${dnsmasq_pihole_id_string}" "${dnsmasq_conf}" ||
grep -q "${dnsmasq_pihole_id_string2}" "${dnsmasq_conf}"; then grep -q "${dnsmasq_pihole_id_string2}" "${dnsmasq_conf}"; then
printf " it is from a previous Pi-hole install.\\n" printf " it is from a previous Pi-hole install.\\n"
printf " %b Backing up dnsmasq.conf to dnsmasq.conf.orig..." "${INF O}" printf " %b Backing up dnsmasq.conf to dnsmasq.conf.orig..." "${INF O}"
# so backup the original file, # so backup the original file,
skipping to change at line 1362 skipping to change at line 1266
printf " it is not a Pi-hole file, leaving alone!\\n" printf " it is not a Pi-hole file, leaving alone!\\n"
fi fi
else else
# If a file cannot be found, # If a file cannot be found,
printf " %b No dnsmasq.conf found... restoring default dnsmasq.conf..." "${INFO}" printf " %b No dnsmasq.conf found... restoring default dnsmasq.conf..." "${INFO}"
# restore the default one # restore the default one
install -D -m 644 -T "${dnsmasq_original_config}" "${dnsmasq_conf}" install -D -m 644 -T "${dnsmasq_original_config}" "${dnsmasq_conf}"
printf "%b %b No dnsmasq.conf found... restoring default dnsmasq.conf.. .\\n" "${OVER}" "${TICK}" printf "%b %b No dnsmasq.conf found... restoring default dnsmasq.conf.. .\\n" "${OVER}" "${TICK}"
fi fi
printf " %b Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..." "${ INFO}" printf " %b Installing %s..." "${INFO}" "${dnsmasq_pihole_01_target}"
# Check to see if dnsmasq directory exists (it may not due to being a fresh install and dnsmasq no longer being a dependency) # Check to see if dnsmasq directory exists (it may not due to being a fresh install and dnsmasq no longer being a dependency)
if [[ ! -d "/etc/dnsmasq.d" ]];then if [[ ! -d "/etc/dnsmasq.d" ]];then
install -d -m 755 "/etc/dnsmasq.d" install -d -m 755 "/etc/dnsmasq.d"
fi fi
# Copy the new Pi-hole DNS config file into the dnsmasq.d directory # Copy the new Pi-hole DNS config file into the dnsmasq.d directory
install -D -m 644 -T "${dnsmasq_pihole_01_snippet}" "${dnsmasq_pihole_01_loc install -D -m 644 -T "${dnsmasq_pihole_01_source}" "${dnsmasq_pihole_01_targ
ation}" et}"
printf "%b %b Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf\\n" " printf "%b %b Installed %s\n" "${OVER}" "${TICK}" "${dnsmasq_pihole_01_tar
${OVER}" "${TICK}" get}"
# Replace our placeholder values with the GLOBAL DNS variables that we popul ated earlier # Replace our placeholder values with the GLOBAL DNS variables that we popul ated earlier
# First, swap in the interface to listen on, # First, swap in the interface to listen on,
sed -i "s/@INT@/$PIHOLE_INTERFACE/" "${dnsmasq_pihole_01_location}" sed -i "s/@INT@/$PIHOLE_INTERFACE/" "${dnsmasq_pihole_01_target}"
if [[ "${PIHOLE_DNS_1}" != "" ]]; then if [[ "${PIHOLE_DNS_1}" != "" ]]; then
# then swap in the primary DNS server. # then swap in the primary DNS server.
sed -i "s/@DNS1@/$PIHOLE_DNS_1/" "${dnsmasq_pihole_01_location}" sed -i "s/@DNS1@/$PIHOLE_DNS_1/" "${dnsmasq_pihole_01_target}"
else else
# Otherwise, remove the line which sets DNS1. # Otherwise, remove the line which sets DNS1.
sed -i '/^server=@DNS1@/d' "${dnsmasq_pihole_01_location}" sed -i '/^server=@DNS1@/d' "${dnsmasq_pihole_01_target}"
fi fi
# Ditto if DNS2 is not empty # Ditto if DNS2 is not empty
if [[ "${PIHOLE_DNS_2}" != "" ]]; then if [[ "${PIHOLE_DNS_2}" != "" ]]; then
sed -i "s/@DNS2@/$PIHOLE_DNS_2/" "${dnsmasq_pihole_01_location}" sed -i "s/@DNS2@/$PIHOLE_DNS_2/" "${dnsmasq_pihole_01_target}"
else else
sed -i '/^server=@DNS2@/d' "${dnsmasq_pihole_01_location}" sed -i '/^server=@DNS2@/d' "${dnsmasq_pihole_01_target}"
fi fi
# Set the cache size # Set the cache size
sed -i "s/@CACHE_SIZE@/$CACHE_SIZE/" ${dnsmasq_pihole_01_location} sed -i "s/@CACHE_SIZE@/$CACHE_SIZE/" "${dnsmasq_pihole_01_target}"
sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' "${dnsmas q_conf}" sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' "${dnsmas q_conf}"
# If the user does not want to enable logging, # If the user does not want to enable logging,
if [[ "${QUERY_LOGGING}" == false ]] ; then if [[ "${QUERY_LOGGING}" == false ]] ; then
# disable it by commenting out the directive in the DNS config file # disable it by commenting out the directive in the DNS config file
sed -i 's/^log-queries/#log-queries/' "${dnsmasq_pihole_01_location}" sed -i 's/^log-queries/#log-queries/' "${dnsmasq_pihole_01_target}"
else else
# Otherwise, enable it by uncommenting the directive in the DNS config f ile # Otherwise, enable it by uncommenting the directive in the DNS config f ile
sed -i 's/^#log-queries/log-queries/' "${dnsmasq_pihole_01_location}" sed -i 's/^#log-queries/log-queries/' "${dnsmasq_pihole_01_target}"
fi fi
printf " %b Installing %s..." "${INFO}" "${dnsmasq_rfc6761_06_source}"
install -D -m 644 -T "${dnsmasq_rfc6761_06_source}" "${dnsmasq_rfc6761_06_ta
rget}"
printf "%b %b Installed %s\n" "${OVER}" "${TICK}" "${dnsmasq_rfc6761_06_ta
rget}"
} }
# Clean an existing installation to prepare for upgrade/reinstall # Clean an existing installation to prepare for upgrade/reinstall
clean_existing() { clean_existing() {
# Local, named variables # Local, named variables
# ${1} Directory to clean # ${1} Directory to clean
local clean_directory="${1}" local clean_directory="${1}"
# Pop the first argument, and shift all addresses down by one (i.e. ${2} bec omes ${1}) # Pop the first argument, and shift all addresses down by one (i.e. ${2} bec omes ${1})
shift shift
# Then, we can access all arguments ($@) without including the directory to clean # Then, we can access all arguments ($@) without including the directory to clean
skipping to change at line 1663 skipping to change at line 1571
# Local, named variables # Local, named variables
local str="Update local cache of available packages" local str="Update local cache of available packages"
printf " %b %s..." "${INFO}" "${str}" printf " %b %s..." "${INFO}" "${str}"
# Create a command from the package cache variable # Create a command from the package cache variable
if eval "${UPDATE_PKG_CACHE}" &> /dev/null; then if eval "${UPDATE_PKG_CACHE}" &> /dev/null; then
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
else else
# Otherwise, show an error and exit # Otherwise, show an error and exit
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}" printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
printf " %bError: Unable to update package cache. Please try \"%s\"%b" "${COL_LIGHT_RED}" "${UPDATE_PKG_CACHE}" "${COL_NC}" printf " %bError: Unable to update package cache. Please try \"%s\"%b" "${COL_LIGHT_RED}" "sudo ${UPDATE_PKG_CACHE}" "${COL_NC}"
return 1 return 1
fi fi
} }
# 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.
notify_package_updates_available() { notify_package_updates_available() {
# Local, named variables # Local, named variables
local str="Checking ${PKG_MANAGER} for upgraded packages" local str="Checking ${PKG_MANAGER} for upgraded packages"
printf "\\n %b %s..." "${INFO}" "${str}" printf "\\n %b %s..." "${INFO}" "${str}"
skipping to change at line 1690 skipping to change at line 1598
else else
printf "%b %b %s... %s updates available\\n" "${OVER}" "${TICK}" "$ {str}" "${updatesToInstall}" printf "%b %b %s... %s updates available\\n" "${OVER}" "${TICK}" "$ {str}" "${updatesToInstall}"
printf " %b %bIt is recommended to update your OS after installing the Pi-hole!%b\\n\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}" printf " %b %bIt is recommended to update your OS after installing the Pi-hole!%b\\n\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}"
fi fi
else else
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}" printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
printf " Kernel update detected. If the install fails, please reboo t and try again\\n" printf " Kernel update detected. If the install fails, please reboo t and try again\\n"
fi fi
} }
# This counter is outside of install_dependent_packages so that it can count the
number of times the function is called.
counter=0
install_dependent_packages() { install_dependent_packages() {
# Local, named variables should be used here, especially for an iterator
# Add one to the counter
counter=$((counter+1))
if [[ "${counter}" == 1 ]]; then
# On the first loop, print a special message
printf " %b Installer Dependency checks...\\n" "${INFO}"
else
# On all subsequent loops, print a generic message.
printf " %b Main Dependency checks...\\n" "${INFO}"
fi
# 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 installArray declare -a installArray
# Debian based package install - debconf will download the entire package li st # Debian based package install - debconf will download the entire package li st
# so we just create an array of packages not currently installed to cut down on the # so we just create an array of packages not currently installed to cut down on the
# amount of download traffic. # amount of download traffic.
# NOTE: We may be able to use this installArray in the future to create a li st of package that were # NOTE: We may be able to use this installArray in the future to create a li st of package that were
# installed by us, and remove only the installed packages, and not the entir e list. # installed by us, and remove only the installed packages, and not the entir e list.
skipping to change at line 1941 skipping to change at line 1836
# Look for DNS server settings which would have to be reapplied # Look for DNS server settings which would have to be reapplied
ProcessDNSSettings ProcessDNSSettings
# Look for DHCP server settings which would have to be reapplied # Look for DHCP server settings which would have to be reapplied
ProcessDHCPSettings ProcessDHCPSettings
} }
# Install the logrotate script # Install the logrotate script
installLogrotate() { installLogrotate() {
local str="Installing latest logrotate script" local str="Installing latest logrotate script"
local target=/etc/pihole/logrotate
printf "\\n %b %s..." "${INFO}" "${str}" printf "\\n %b %s..." "${INFO}" "${str}"
if [[ -f ${target} ]]; then
printf "\\n\\t%b Existing logrotate file found. No changes made.\\n" "${
INFO}"
# Return value isn't that important, using 2 to indicate that it's not a
fatal error but
# the function did not complete.
return 2
fi
# Copy the file over from the local repo # Copy the file over from the local repo
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/Templates/logrotate /etc /pihole/logrotate install -D -m 644 -T "${PI_HOLE_LOCAL_REPO}"/advanced/Templates/logrotate ${ target}
# Different operating systems have different user / group # Different operating systems have different user / group
# settings for logrotate that makes it impossible to create # settings for logrotate that makes it impossible to create
# a static logrotate file that will work with e.g. # a static logrotate file that will work with e.g.
# Rasbian and Ubuntu at the same time. Hence, we have to # Rasbian and Ubuntu at the same time. Hence, we have to
# customize the logrotate script here in order to reflect # customize the logrotate script here in order to reflect
# the local properties of the /var/log directory # the local properties of the /var/log directory
logusergroup="$(stat -c '%U %G' /var/log)" logusergroup="$(stat -c '%U %G' /var/log)"
# If there is a usergroup for log rotation, # If there is a usergroup for log rotation,
if [[ ! -z "${logusergroup}" ]]; then if [[ -n "${logusergroup}" ]]; then
# replace the line in the logrotate script with that usergroup. # replace the line in the logrotate script with that usergroup.
sed -i "s/# su #/su ${logusergroup}/g;" /etc/pihole/logrotate sed -i "s/# su #/su ${logusergroup}/g;" ${target}
fi fi
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" printf "%b %b %s\\n" "${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. # 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. S ort them out here. # Refactoring of install script has changed the name of a couple of variables. S ort them out here.
accountForRefactor() { accountForRefactor() {
sed -i 's/piholeInterface/PIHOLE_INTERFACE/g' "${setupVars}" sed -i 's/piholeInterface/PIHOLE_INTERFACE/g' "${setupVars}"
sed -i 's/IPv4_address/IPV4_ADDRESS/g' "${setupVars}" sed -i 's/IPv4_address/IPV4_ADDRESS/g' "${setupVars}"
sed -i 's/IPv4addr/IPV4_ADDRESS/g' "${setupVars}" sed -i 's/IPv4addr/IPV4_ADDRESS/g' "${setupVars}"
skipping to change at line 2031 skipping to change at line 1934
printf " %b Failure in dependent config copy function.\\n" "${CROSS}" printf " %b Failure in dependent config copy function.\\n" "${CROSS}"
exit 1 exit 1
fi fi
# If the user wants to install the dashboard, # If the user wants to install the dashboard,
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
# do so # do so
installPiholeWeb installPiholeWeb
fi fi
# Install the cron file # Install the cron file
installCron installCron
# Install the logrotate file # Install the logrotate file
installLogrotate installLogrotate || true
# Check if dnsmasq is present. If so, disable it and back up any possible # Check if dnsmasq is present. If so, disable it and back up any possible
# config file # config file
disable_dnsmasq disable_dnsmasq
# install a man page entry for pihole # install a man page entry for pihole
install_manpage install_manpage
# Update setupvars.conf with any variables that may or may not have been cha nged during the install # Update setupvars.conf with any variables that may or may not have been cha nged during the install
finalExports finalExports
} }
skipping to change at line 2117 skipping to change at line 2022
Your Admin Webpage login password is ${pwstring}" Your Admin Webpage login password is ${pwstring}"
fi fi
# Final completion message to user # Final completion message to user
whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using:
IPv4: ${IPV4_ADDRESS%/*} IPv4: ${IPV4_ADDRESS%/*}
IPv6: ${IPV6_ADDRESS:-"Not Configured"} IPv6: ${IPV6_ADDRESS:-"Not Configured"}
If you set a new IP address, you should restart the Pi. If you have not done so already, the above IP should be set to static.
The install log is in /etc/pihole. The install log is in /etc/pihole.
${additional}" "${r}" "${c}" ${additional}" "${r}" "${c}"
} }
update_dialogs() { update_dialogs() {
# If pihole -r "reconfigure" option was selected, # If pihole -r "reconfigure" option was selected,
if [[ "${reconfigure}" = true ]]; then if [[ "${reconfigure}" = true ]]; then
# set some variables that will be used # set some variables that will be used
opt1a="Repair" opt1a="Repair"
opt1b="This will retain existing settings" opt1b="This will retain existing settings"
strAdd="You will remain on the same version" strAdd="You will remain on the same version"
else else
# Otherwise, set some variables with different values # Otherwise, set some variables with different values
opt1a="Update" opt1a="Update"
opt1b="This will retain existing settings." opt1b="This will retain existing settings."
strAdd="You will be updated to the latest version." strAdd="You will be updated to the latest version."
fi fi
opt2a="Reconfigure" opt2a="Reconfigure"
opt2b="This will reset your Pi-hole and allow you to enter new settings." opt2b="Resets Pi-hole and allows re-selecting settings."
# Display the information to the user # Display the information to the user
UpdateCmd=$(whiptail --title "Existing Install Detected!" --menu "\\n\\nWe h ave detected an existing install.\\n\\nPlease choose from the following options: \\n($strAdd)" "${r}" "${c}" 2 \ UpdateCmd=$(whiptail --title "Existing Install Detected!" --menu "\\n\\nWe h ave detected an existing install.\\n\\nPlease choose from the following options: \\n($strAdd)" "${r}" "${c}" 2 \
"${opt1a}" "${opt1b}" \ "${opt1a}" "${opt1b}" \
"${opt2a}" "${opt2b}" 3>&2 2>&1 1>&3) || \ "${opt2a}" "${opt2b}" 3>&2 2>&1 1>&3) || \
{ printf " %bCancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED} " "${COL_NC}"; exit 1; } { printf " %bCancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED} " "${COL_NC}"; exit 1; }
# Set the variable based on if the user chooses # Set the variable based on if the user chooses
case ${UpdateCmd} in case ${UpdateCmd} in
# repair, or # repair, or
skipping to change at line 2323 skipping to change at line 2228
if curl -sSL --fail "${url}/${binary}" -o "${binary}"; then if curl -sSL --fail "${url}/${binary}" -o "${binary}"; then
# If the download worked, get sha1 of the binary we just downloaded for verification. # If the download worked, get sha1 of the binary we just downloaded for verification.
curl -sSL --fail "${url}/${binary}.sha1" -o "${binary}.sha1" curl -sSL --fail "${url}/${binary}.sha1" -o "${binary}.sha1"
# If we downloaded binary file (as opposed to text), # If we downloaded binary file (as opposed to text),
if sha1sum --status --quiet -c "${binary}".sha1; then if sha1sum --status --quiet -c "${binary}".sha1; then
printf "transferred... " printf "transferred... "
# Before stopping FTL, we download the macvendor database # Before stopping FTL, we download the macvendor database
curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFI G_DIR}/macvendor.db" || true curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFI G_DIR}/macvendor.db" || true
chmod 644 "${PI_HOLE_CONFIG_DIR}/macvendor.db"
chown pihole:pihole "${PI_HOLE_CONFIG_DIR}/macvendor.db"
# Stop pihole-FTL service if available # Stop pihole-FTL service if available
stop_service pihole-FTL &> /dev/null stop_service pihole-FTL &> /dev/null
# Install the new version with the correct permissions # Install the new version with the correct permissions
install -T -m 0755 "${binary}" /usr/bin/pihole-FTL install -T -m 0755 "${binary}" /usr/bin/pihole-FTL
# Move back into the original directory the user was in # Move back into the original directory the user was in
popd > /dev/null || { printf "Unable to return to original directory after FTL binary download.\\n"; return 1; } popd > /dev/null || { printf "Unable to return to original directory after FTL binary download.\\n"; return 1; }
skipping to change at line 2629 skipping to change at line 2532
exit $? exit $?
else else
# Otherwise, tell the user they need to run the script as root, and bail # Otherwise, tell the user they need to run the script as root, and bail
printf "%b %b Sudo utility check\\n" "${OVER}" "${CROSS}" printf "%b %b Sudo utility check\\n" "${OVER}" "${CROSS}"
printf " %b Sudo is needed for the Web Interface to run pihole comm ands\\n\\n" "${INFO}" printf " %b Sudo is needed for the Web Interface to run pihole comm ands\\n\\n" "${INFO}"
printf " %b %bPlease re-run this installer as root${COL_NC}\\n" "${ INFO}" "${COL_LIGHT_RED}" printf " %b %bPlease re-run this installer as root${COL_NC}\\n" "${ INFO}" "${COL_LIGHT_RED}"
exit 1 exit 1
fi fi
fi fi
# Check for supported distribution # Check for supported package managers so that we may install dependencies
distro_check package_manager_detect
# Notify user of package availability
notify_package_updates_available
# Install packages necessary to perform os_check
printf " %b Checking for / installing Required dependencies for OS Check...
\\n" "${INFO}"
install_dependent_packages "${OS_CHECK_DEPS[@]}"
# Check that the installed OS is officially supported - display warning if n
ot
os_check
# Install packages used by this installation script
printf " %b Checking for / installing Required dependencies for this instal
l script...\\n" "${INFO}"
install_dependent_packages "${INSTALLER_DEPS[@]}"
# Check if SELinux is Enforcing
checkSelinux
# If the setup variable file exists, # If the setup variable file exists,
if [[ -f "${setupVars}" ]]; then if [[ -f "${setupVars}" ]]; then
# if it's running unattended, # if it's running unattended,
if [[ "${runUnattended}" == true ]]; then if [[ "${runUnattended}" == true ]]; then
printf " %b Performing unattended setup, no whiptail dialogs will b e displayed\\n" "${INFO}" printf " %b Performing unattended setup, no whiptail dialogs will b e displayed\\n" "${INFO}"
# Use the setup variables # Use the setup variables
useUpdateVars=true useUpdateVars=true
# also disable debconf-apt-progress dialogs # also disable debconf-apt-progress dialogs
export DEBIAN_FRONTEND="noninteractive" export DEBIAN_FRONTEND="noninteractive"
else else
# If running attended, show the available options (repair/reconfigur e) # If running attended, show the available options (repair/reconfigur e)
update_dialogs update_dialogs
fi fi
fi fi
# Start the installer
# Notify user of package availability
notify_package_updates_available
# Install packages used by this installation script
install_dependent_packages "${INSTALLER_DEPS[@]}"
# Check that the installed OS is officially supported - display warning if n
ot
os_check
# Check if SELinux is Enforcing
checkSelinux
if [[ "${useUpdateVars}" == false ]]; then if [[ "${useUpdateVars}" == false ]]; then
# Display welcome dialogs # Display welcome dialogs
welcomeDialogs welcomeDialogs
# Create directory for Pi-hole storage # Create directory for Pi-hole storage
install -d -m 755 /etc/pihole/ install -d -m 755 /etc/pihole/
# Determine available interfaces # Determine available interfaces
get_available_interfaces get_available_interfaces
# Find interfaces and let the user choose one # Find interfaces and let the user choose one
chooseInterface chooseInterface
# Decide what upstream DNS Servers to use # Decide what upstream DNS Servers to use
skipping to change at line 2706 skipping to change at line 2613
# Download or update the scripts by updating the appropriate git repos # Download or update the scripts by updating the appropriate git repos
clone_or_update_repos clone_or_update_repos
# Install the Core dependencies # Install the Core dependencies
local dep_install_list=("${PIHOLE_DEPS[@]}") local dep_install_list=("${PIHOLE_DEPS[@]}")
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
# And, if the setting says so, install the Web admin interface dependenc ies # And, if the setting says so, install the Web admin interface dependenc ies
dep_install_list+=("${PIHOLE_WEB_DEPS[@]}") dep_install_list+=("${PIHOLE_WEB_DEPS[@]}")
fi fi
# Install packages used by the actual software
printf " %b Checking for / installing Required dependencies for Pi-hole sof
tware...\\n" "${INFO}"
install_dependent_packages "${dep_install_list[@]}" install_dependent_packages "${dep_install_list[@]}"
unset dep_install_list unset dep_install_list
# On some systems, lighttpd is not enabled on first install. We need to enab le it here if the user # On some systems, lighttpd is not enabled on first install. We need to enab le it here if the user
# has chosen to install the web interface, else the LIGHTTPD_ENABLED check w ill fail # has chosen to install the web interface, else the LIGHTTPD_ENABLED check w ill fail
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
enable_service lighttpd enable_service lighttpd
fi fi
# Determine if lighttpd is correctly enabled # Determine if lighttpd is correctly enabled
if check_service_active "lighttpd"; then if check_service_active "lighttpd"; then
skipping to change at line 2810 skipping to change at line 2719
if [[ "${useUpdateVars}" == false ]]; then if [[ "${useUpdateVars}" == false ]]; then
# If the Web interface was installed, # If the Web interface was installed,
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
printf " %b View the web interface at http://pi.hole/admin or http: //%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}" printf " %b View the web interface at http://pi.hole/admin or http: //%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}"
fi fi
# Explain to the user how to use Pi-hole as their DNS server # Explain to the user how to use Pi-hole as their DNS server
printf " %b You may now configure your devices to use the Pi-hole as th eir DNS server\\n" "${INFO}" printf " %b You may now configure your devices to use the Pi-hole as th eir DNS server\\n" "${INFO}"
[[ -n "${IPV4_ADDRESS%/*}" ]] && printf " %b Pi-hole DNS (IPv4): %s\\n" "${INFO}" "${IPV4_ADDRESS%/*}" [[ -n "${IPV4_ADDRESS%/*}" ]] && printf " %b Pi-hole DNS (IPv4): %s\\n" "${INFO}" "${IPV4_ADDRESS%/*}"
[[ -n "${IPV6_ADDRESS}" ]] && printf " %b Pi-hole DNS (IPv6): %s\\n" "$ {INFO}" "${IPV6_ADDRESS}" [[ -n "${IPV6_ADDRESS}" ]] && printf " %b Pi-hole DNS (IPv6): %s\\n" "$ {INFO}" "${IPV6_ADDRESS}"
printf " %b If you set a new IP address, please restart the server runn ing the Pi-hole\\n" "${INFO}" printf " %b If you have not done so already, the above IP should be set to static.\\n" "${INFO}"
INSTALL_TYPE="Installation" INSTALL_TYPE="Installation"
else else
INSTALL_TYPE="Update" INSTALL_TYPE="Update"
fi fi
# Display where the log file is # Display where the log file is
printf "\\n %b The install log is located at: %s\\n" "${INFO}" "${installLo gLoc}" printf "\\n %b The install log is located at: %s\\n" "${INFO}" "${installLo gLoc}"
printf "%b%s Complete! %b\\n" "${COL_LIGHT_GREEN}" "${INSTALL_TYPE}" "${COL_ NC}" printf "%b%s Complete! %b\\n" "${COL_LIGHT_GREEN}" "${INSTALL_TYPE}" "${COL_ NC}"
if [[ "${INSTALL_TYPE}" == "Update" ]]; then if [[ "${INSTALL_TYPE}" == "Update" ]]; then
 End of changes. 43 change blocks. 
205 lines changed or deleted 108 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)