mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-02-27 13:38:16 +00:00
Apply Google shell style guide conventions
This commit is contained in:
parent
27a15f0567
commit
10ad32de9b
1 changed files with 128 additions and 130 deletions
|
@ -45,8 +45,7 @@ echo ":::"
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ $EUID -eq 0 ]];then
|
||||||
echo "::: You are root."
|
echo "::: You are root."
|
||||||
else
|
else
|
||||||
echo "::: sudo will be used for the install."
|
# Check if sudo is actually installed
|
||||||
# Check if it is actually installed
|
|
||||||
# If it isn't, exit because the install cannot complete
|
# If it isn't, exit because the install cannot complete
|
||||||
if [ -x "$(command -v sudo)" ];then
|
if [ -x "$(command -v sudo)" ];then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
|
@ -54,6 +53,7 @@ else
|
||||||
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "::: sudo utility found and will be used for the install."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compatibility
|
# Compatibility
|
||||||
|
@ -80,7 +80,7 @@ if [ -x "$(command -v apt-get)" ];then
|
||||||
LIGHTTPD_CFG="lighttpd.conf.debian"
|
LIGHTTPD_CFG="lighttpd.conf.debian"
|
||||||
package_check() {
|
package_check() {
|
||||||
# Returns 0 if package found locally, non-zero if package missing
|
# Returns 0 if package found locally, non-zero if package missing
|
||||||
dpkg-query -W "$1" 2>/dev/null
|
dpkg-query -W "$1" 2>&1 > /dev/null
|
||||||
}
|
}
|
||||||
elif [ -x "$(command -v rpm)" ];then
|
elif [ -x "$(command -v rpm)" ];then
|
||||||
# Fedora Family
|
# Fedora Family
|
||||||
|
@ -123,7 +123,7 @@ spinner()
|
||||||
printf " \b\b\b\b"
|
printf " \b\b\b\b"
|
||||||
}
|
}
|
||||||
|
|
||||||
findIPRoute() {
|
find_IPv4_route() {
|
||||||
# Find IP used to route to outside world
|
# Find IP used to route to outside world
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||||
IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||||
|
@ -132,7 +132,7 @@ findIPRoute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
welcomeDialogs() {
|
welcome_dialogs() {
|
||||||
# Display the welcome dialog
|
# Display the welcome dialog
|
||||||
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer" "This installer will transform your Raspberry Pi into a network-wide ad blocker!" ${r} ${c}
|
whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer" "This installer will transform your Raspberry Pi into a network-wide ad blocker!" ${r} ${c}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ In the next section, you can choose to use your current network settings (DHCP)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
verifyFreeDiskSpace() {
|
verify_free_disk_space() {
|
||||||
|
|
||||||
# 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.)
|
# 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.
|
# - Fourdee: Local ensures the variable is only created, and accessible within this function/void. Generally considered a "good" coding practice for non-global variables.
|
||||||
|
@ -179,7 +179,7 @@ verifyFreeDiskSpace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
chooseInterface() {
|
choose_interface() {
|
||||||
# Turn the available interfaces into an array so it can be used with a whiptail dialog
|
# Turn the available interfaces into an array so it can be used with a whiptail dialog
|
||||||
interfacesArray=()
|
interfacesArray=()
|
||||||
firstLoop=1
|
firstLoop=1
|
||||||
|
@ -208,16 +208,21 @@ chooseInterface() {
|
||||||
echo "::: Cancel selected, exiting...."
|
echo "::: Cancel selected, exiting...."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use4andor6() {
|
whiptail_IPv6_address() {
|
||||||
|
# Show the IPv6 address used for blocking
|
||||||
|
IPv6addr=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||||
|
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$IPv6addr will be used to block ads." ${r} ${c}
|
||||||
|
}
|
||||||
|
|
||||||
|
use_IPv4_and_or_IPv6() {
|
||||||
# Let use select IPv4 and/or IPv6
|
# Let use select IPv4 and/or IPv6
|
||||||
cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" ${r} ${c} 2)
|
cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" ${r} ${c} 2)
|
||||||
options=(IPv4 "Block ads over IPv4" on
|
options=(IPv4 "Block ads over IPv4" on
|
||||||
IPv6 "Block ads over IPv6" off)
|
IPv6 "Block ads over IPv6" off)
|
||||||
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
||||||
if [[ $? = 0 ]];then
|
if [[ $? -eq 0 ]];then
|
||||||
for choice in ${choices}
|
for choice in ${choices}
|
||||||
do
|
do
|
||||||
case ${choice} in
|
case ${choice} in
|
||||||
|
@ -226,25 +231,25 @@ use4andor6() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${useIPv4} ] && [ ! ${useIPv6} ]; then
|
if [[ "${useIPv4}" ]] && [[ ! "${useIPv6}" ]]; then
|
||||||
getStaticIPv4Settings
|
get_static_IPv4_settings
|
||||||
setStaticIPv4
|
set_static_IPv4
|
||||||
echo "::: Using IPv4 on $IPv4addr"
|
echo "::: IPv4 address: $IPv4addr"
|
||||||
echo "::: IPv6 will NOT be used."
|
echo "::: IPv6 address: NOT USED."
|
||||||
fi
|
fi
|
||||||
if [ ! ${useIPv4} ] && [ ${useIPv6} ]; then
|
if [[ ! "${useIPv4}" ]] && [[ "${useIPv6}" ]]; then
|
||||||
useIPv6dialog
|
whiptail_IPv6_address
|
||||||
echo "::: IPv4 will NOT be used."
|
echo "::: IPv4 address: NOT USED."
|
||||||
echo "::: Using IPv6 on $piholeIPv6"
|
echo "::: IPv6 address: $IPv6addr"
|
||||||
fi
|
fi
|
||||||
if [ ${useIPv4} ] && [ ${useIPv6} ]; then
|
if [[ "${useIPv4}" ]] && [[ "${useIPv6}" ]]; then
|
||||||
getStaticIPv4Settings
|
get_static_IPv4_settings
|
||||||
setStaticIPv4
|
set_static_IPv4
|
||||||
useIPv6dialog
|
whiptail_IPv6_address
|
||||||
echo "::: Using IPv4 on $IPv4addr"
|
echo "::: IPv4 address: $IPv4addr"
|
||||||
echo "::: Using IPv6 on $piholeIPv6"
|
echo "::: IPv6 address: $IPv6addr"
|
||||||
fi
|
fi
|
||||||
if [ ! ${useIPv4} ] && [ ! ${useIPv6} ]; then
|
if [[ ! "${useIPv4}" ]] && [[ ! "${useIPv6}" ]]; then
|
||||||
echo "::: Cannot continue, neither IPv4 or IPv6 selected"
|
echo "::: Cannot continue, neither IPv4 or IPv6 selected"
|
||||||
echo "::: Exiting"
|
echo "::: Exiting"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -256,13 +261,7 @@ use4andor6() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
useIPv6dialog() {
|
get_static_IPv4_settings() {
|
||||||
# Show the IPv6 address used for blocking
|
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
|
||||||
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." ${r} ${c}
|
|
||||||
}
|
|
||||||
|
|
||||||
getStaticIPv4Settings() {
|
|
||||||
# Ask if the user wants to use DHCP settings as their static IP
|
# Ask if the user wants to use DHCP settings as their static IP
|
||||||
if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address?
|
if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address?
|
||||||
IP address: $IPv4addr
|
IP address: $IPv4addr
|
||||||
|
@ -313,7 +312,7 @@ It is also possible to use a DHCP reservation, but if you are going to do that,
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
setDHCPCD() {
|
set_dhcpcd() {
|
||||||
# Append these lines to dhcpcd.conf to enable a static IP
|
# Append these lines to dhcpcd.conf to enable a static IP
|
||||||
echo "## interface $piholeInterface
|
echo "## interface $piholeInterface
|
||||||
static ip_address=$IPv4addr
|
static ip_address=$IPv4addr
|
||||||
|
@ -321,13 +320,13 @@ setDHCPCD() {
|
||||||
static domain_name_servers=$IPv4gw" | ${SUDO} tee -a /etc/dhcpcd.conf >/dev/null
|
static domain_name_servers=$IPv4gw" | ${SUDO} tee -a /etc/dhcpcd.conf >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
setStaticIPv4() {
|
set_static_IPv4() {
|
||||||
if [[ -f /etc/dhcpcd.conf ]];then
|
if [[ -f /etc/dhcpcd.conf ]];then
|
||||||
# Debian Family
|
# Debian Family
|
||||||
if grep -q "$IPv4addr" /etc/dhcpcd.conf; then
|
if grep -q "$IPv4addr" /etc/dhcpcd.conf; then
|
||||||
echo "::: Static IP already configured"
|
echo "::: Static IP already configured"
|
||||||
else
|
else
|
||||||
setDHCPCD
|
set_dhcpcd
|
||||||
${SUDO} ip addr replace dev "$piholeInterface" "$IPv4addr"
|
${SUDO} ip addr replace dev "$piholeInterface" "$IPv4addr"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
||||||
|
@ -387,7 +386,7 @@ function valid_ip()
|
||||||
return ${stat}
|
return ${stat}
|
||||||
}
|
}
|
||||||
|
|
||||||
setDNS(){
|
set_upstream_dns(){
|
||||||
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 6)
|
DNSChoseCmd=(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
|
||||||
|
@ -478,7 +477,7 @@ setDNS(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
versionCheckDNSmasq(){
|
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
|
||||||
dnsFile1="/etc/dnsmasq.conf"
|
dnsFile1="/etc/dnsmasq.conf"
|
||||||
dnsFile2="/etc/dnsmasq.conf.orig"
|
dnsFile2="/etc/dnsmasq.conf.orig"
|
||||||
|
@ -523,7 +522,7 @@ versionCheckDNSmasq(){
|
||||||
${SUDO} sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsFile1}
|
${SUDO} sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' ${dnsFile1}
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts() {
|
install_scripts() {
|
||||||
# Install the scripts from /etc/.pihole to their various locations
|
# Install the scripts from /etc/.pihole to their various locations
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Installing scripts to /opt/pihole..."
|
echo -n "::: Installing scripts to /opt/pihole..."
|
||||||
|
@ -549,11 +548,11 @@ installScripts() {
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installConfigs() {
|
install_configs() {
|
||||||
# Install the configs from /etc/.pihole to their various locations
|
# Install the configs from /etc/.pihole to their various locations
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Installing configs..."
|
echo "::: Installing configs..."
|
||||||
versionCheckDNSmasq
|
version_check_dnsmasq
|
||||||
if [ ! -d "/etc/lighttpd" ]; then
|
if [ ! -d "/etc/lighttpd" ]; then
|
||||||
${SUDO} mkdir /etc/lighttpd
|
${SUDO} mkdir /etc/lighttpd
|
||||||
${SUDO} chown "$USER":root /etc/lighttpd
|
${SUDO} chown "$USER":root /etc/lighttpd
|
||||||
|
@ -566,7 +565,7 @@ installConfigs() {
|
||||||
${SUDO} chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress
|
${SUDO} chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress
|
||||||
}
|
}
|
||||||
|
|
||||||
stopServices() {
|
stop_service() {
|
||||||
# Stop dnsmasq and lighttpd
|
# Stop dnsmasq and lighttpd
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Stopping services..."
|
echo -n "::: Stopping services..."
|
||||||
|
@ -579,13 +578,14 @@ stopServices() {
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installPackages() {
|
install_packages() {
|
||||||
|
# accepts an array as argument
|
||||||
declare -a argArray1=("${!1}")
|
declare -a argArray1=("${!1}")
|
||||||
|
|
||||||
for i in "${argArray1[@]}"; do
|
for i in "${argArray1[@]}"; do
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
package_check "${i}" > /dev/null
|
package_check "${i}"
|
||||||
if ! [ "$?" -eq 0 ]; then
|
if ! [[ "$?" -eq 0 ]]; then
|
||||||
echo -n " Not found! Installing...."
|
echo -n " Not found! Installing...."
|
||||||
${SUDO} ${PKG_INSTALL} "$i" > /dev/null 2>&1
|
${SUDO} ${PKG_INSTALL} "$i" > /dev/null 2>&1
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
@ -593,19 +593,18 @@ installPackages() {
|
||||||
echo " already installed!"
|
echo " already installed!"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
installerDependencies() {
|
installer_dependencies() {
|
||||||
#Running apt-get update/upgrade with minimal output can cause some issues with
|
#Running apt-get update/upgrade with minimal output can cause some issues with
|
||||||
#requiring user input (e.g password for phpmyadmin see #218)
|
#requiring user input (e.g password for phpmyadmin see #218)
|
||||||
#We'll change the logic up here, to check to see if there are any updates availible and
|
#We'll change the logic up here, to check to see if there are any updates availible and
|
||||||
# if so, advise the user to run apt-get update/upgrade at their own discretion
|
# if so, advise the user to run apt-get update/upgrade at their own discretion
|
||||||
|
|
||||||
|
|
||||||
#Check to see if apt-get update has already been run today
|
#Check to see if package manager update has already been run today
|
||||||
# it needs to have been run at least once on new installs!
|
# it needs to have been run at least once on new installs!
|
||||||
timestamp=$(stat -c %Y ${PKG_CACHE})
|
timestamp=$(stat -c %Y ${PKG_CACHE})
|
||||||
timestampAsDate=$(date -d @"$timestamp" "+%b %e")
|
timestampAsDate=$(date -d @"$timestamp" "+%b %e")
|
||||||
|
@ -632,16 +631,16 @@ installerDependencies() {
|
||||||
fi
|
fi
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Checking installer dependencies..."
|
echo "::: Checking installer dependencies..."
|
||||||
installPackages INSTALLER_DEPS[@]
|
install_packages INSTALLER_DEPS[@]
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForDependencies() {
|
check_dependencies() {
|
||||||
# Install dependencies for Pi-Hole
|
# Install dependencies for Pi-Hole
|
||||||
echo "::: Checking Pi-Hole dependencies:"
|
echo "::: Checking Pi-Hole dependencies:"
|
||||||
installPackages PIHOLE_DEPS[@]
|
install_packages PIHOLE_DEPS[@]
|
||||||
}
|
}
|
||||||
|
|
||||||
getGitFiles() {
|
setup_local_repos() {
|
||||||
# Setup git repos for base files and web admin
|
# Setup git repos for base files and web admin
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Checking for existing base files..."
|
echo "::: Checking for existing base files..."
|
||||||
|
@ -693,8 +692,7 @@ update_repo() {
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create_log_file() {
|
||||||
CreateLogFile() {
|
|
||||||
# Create logfiles if necessary
|
# Create logfiles if necessary
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Creating log file and changing owner to dnsmasq..."
|
echo -n "::: Creating log file and changing owner to dnsmasq..."
|
||||||
|
@ -708,7 +706,7 @@ CreateLogFile() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installPiholeWeb() {
|
install_admin_web() {
|
||||||
# Install the web interface
|
# Install the web interface
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Installing pihole custom index page..."
|
echo -n "::: Installing pihole custom index page..."
|
||||||
|
@ -732,7 +730,7 @@ installPiholeWeb() {
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
installCron() {
|
install_cron() {
|
||||||
# Install the cron job
|
# Install the cron job
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Installing latest Cron script..."
|
echo -n "::: Installing latest Cron script..."
|
||||||
|
@ -740,8 +738,8 @@ installCron() {
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
runGravity() {
|
run_gravity() {
|
||||||
# Rub gravity.sh to build blacklists
|
# Run gravity.sh to build blacklists
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Preparing to run gravity.sh to refresh hosts..."
|
echo "::: Preparing to run gravity.sh to refresh hosts..."
|
||||||
if ls /etc/pihole/list* 1> /dev/null 2>&1; then
|
if ls /etc/pihole/list* 1> /dev/null 2>&1; then
|
||||||
|
@ -752,7 +750,7 @@ runGravity() {
|
||||||
${SUDO} /opt/pihole/gravity.sh
|
${SUDO} /opt/pihole/gravity.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
setUser(){
|
set_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..."
|
||||||
if id -u pihole > /dev/null 2>&1; then
|
if id -u pihole > /dev/null 2>&1; then
|
||||||
|
@ -763,7 +761,7 @@ setUser(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
configureFirewall() {
|
configure_firewall() {
|
||||||
# Allow HTTP and DNS traffic
|
# Allow HTTP and DNS traffic
|
||||||
if [ -x "$(command -v firewall-cmd)" ]; then
|
if [ -x "$(command -v firewall-cmd)" ]; then
|
||||||
${SUDO} firewall-cmd --state > /dev/null
|
${SUDO} firewall-cmd --state > /dev/null
|
||||||
|
@ -784,64 +782,7 @@ configureFirewall() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
finalExports() {
|
configure_SELinux() {
|
||||||
#If it already exists, lets overwrite it with the new values.
|
|
||||||
if [[ -f ${setupVars} ]];then
|
|
||||||
${SUDO} rm ${setupVars}
|
|
||||||
fi
|
|
||||||
${SUDO} echo "piholeInterface=${piholeInterface}" >> ${setupVars}
|
|
||||||
${SUDO} echo "IPv4addr=${IPv4addr}" >> ${setupVars}
|
|
||||||
${SUDO} echo "piholeIPv6=${piholeIPv6}" >> ${setupVars}
|
|
||||||
${SUDO} echo "piholeDNS1=${piholeDNS1}" >> ${setupVars}
|
|
||||||
${SUDO} echo "piholeDNS2=${piholeDNS2}" >> ${setupVars}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
installPihole() {
|
|
||||||
# Install base files and web interface
|
|
||||||
checkForDependencies # done
|
|
||||||
stopServices
|
|
||||||
setUser
|
|
||||||
if [ ! -d "/var/www/html" ]; then
|
|
||||||
${SUDO} mkdir -p /var/www/html
|
|
||||||
fi
|
|
||||||
${SUDO} chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/www/html
|
|
||||||
${SUDO} chmod 775 /var/www/html
|
|
||||||
${SUDO} usermod -a -G ${LIGHTTPD_GROUP} pihole
|
|
||||||
if [ -x "$(command -v lighty-enable-mod)" ]; then
|
|
||||||
${SUDO} lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
|
||||||
else
|
|
||||||
printf "\n:::\tWarning: 'lighty-enable-mod' utility not found. Please ensure fastcgi is enabled if you experience issues.\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
getGitFiles
|
|
||||||
installScripts
|
|
||||||
installConfigs
|
|
||||||
CreateLogFile
|
|
||||||
configureSelinux
|
|
||||||
installPiholeWeb
|
|
||||||
installCron
|
|
||||||
runGravity
|
|
||||||
configureFirewall
|
|
||||||
finalExports
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePihole() {
|
|
||||||
# Install base files and web interface
|
|
||||||
checkForDependencies # done
|
|
||||||
stopServices
|
|
||||||
getGitFiles
|
|
||||||
installScripts
|
|
||||||
installConfigs
|
|
||||||
CreateLogFile
|
|
||||||
configureSelinux
|
|
||||||
installPiholeWeb
|
|
||||||
installCron
|
|
||||||
runGravity
|
|
||||||
configureFirewall
|
|
||||||
}
|
|
||||||
|
|
||||||
configureSelinux() {
|
|
||||||
if [ -x "$(command -v getenforce)" ]; then
|
if [ -x "$(command -v getenforce)" ]; then
|
||||||
printf "\n::: SELinux Detected\n"
|
printf "\n::: SELinux Detected\n"
|
||||||
printf ":::\tChecking for SELinux policy development packages..."
|
printf ":::\tChecking for SELinux policy development packages..."
|
||||||
|
@ -872,12 +813,69 @@ configureSelinux() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final_exports() {
|
||||||
|
#If it already exists, lets overwrite it with the new values.
|
||||||
|
if [[ -f ${setupVars} ]];then
|
||||||
|
${SUDO} rm ${setupVars}
|
||||||
|
fi
|
||||||
|
${SUDO} echo "piholeInterface=${piholeInterface}" >> ${setupVars}
|
||||||
|
${SUDO} echo "IPv4addr=${IPv4addr}" >> ${setupVars}
|
||||||
|
${SUDO} echo "piholeIPv6=${IPv6addr}" >> ${setupVars}
|
||||||
|
${SUDO} echo "piholeDNS1=${piholeDNS1}" >> ${setupVars}
|
||||||
|
${SUDO} echo "piholeDNS2=${piholeDNS2}" >> ${setupVars}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
install() {
|
||||||
|
# Install base files and web interface
|
||||||
|
check_dependencies # done
|
||||||
|
stop_service
|
||||||
|
set_user
|
||||||
|
if [ ! -d "/var/www/html" ]; then
|
||||||
|
${SUDO} mkdir -p /var/www/html
|
||||||
|
fi
|
||||||
|
${SUDO} chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/www/html
|
||||||
|
${SUDO} chmod 775 /var/www/html
|
||||||
|
${SUDO} usermod -a -G ${LIGHTTPD_GROUP} pihole
|
||||||
|
if [ -x "$(command -v lighty-enable-mod)" ]; then
|
||||||
|
${SUDO} lighty-enable-mod fastcgi fastcgi-php > /dev/null
|
||||||
|
else
|
||||||
|
printf "\n:::\tWarning: 'lighty-enable-mod' utility not found. Please ensure fastcgi is enabled if you experience issues.\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
setup_local_repos
|
||||||
|
install_scripts
|
||||||
|
install_configs
|
||||||
|
create_log_file
|
||||||
|
configure_SELinux
|
||||||
|
install_admin_web
|
||||||
|
install_cron
|
||||||
|
run_gravity
|
||||||
|
configure_firewall
|
||||||
|
final_exports
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
# Install base files and web interface
|
||||||
|
check_dependencies # done
|
||||||
|
stop_service
|
||||||
|
setup_local_repos
|
||||||
|
install_scripts
|
||||||
|
install_configs
|
||||||
|
create_log_file
|
||||||
|
configure_SELinux
|
||||||
|
install_admin_web
|
||||||
|
install_cron
|
||||||
|
run_gravity
|
||||||
|
configure_firewall
|
||||||
|
}
|
||||||
|
|
||||||
displayFinalMessage() {
|
displayFinalMessage() {
|
||||||
# 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: ${IPv4addr%/*}
|
IPv4: ${IPv4addr%/*}
|
||||||
IPv6: $piholeIPv6
|
IPv6: $IPv6addr
|
||||||
|
|
||||||
If you set a new IP address, you should restart the Pi.
|
If you set a new IP address, you should restart the Pi.
|
||||||
|
|
||||||
|
@ -910,7 +908,7 @@ updateDialogs(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######## SCRIPT ############
|
######## MAIN MAIN MAIN ########
|
||||||
if [[ -f ${setupVars} ]];then
|
if [[ -f ${setupVars} ]];then
|
||||||
. ${setupVars}
|
. ${setupVars}
|
||||||
|
|
||||||
|
@ -928,27 +926,27 @@ if [[ $1 = "--i_do_not_follow_recommendations" ]]; then
|
||||||
echo "::: --i_do_not_follow_recommendations passed to script"
|
echo "::: --i_do_not_follow_recommendations passed to script"
|
||||||
echo "::: skipping free disk space verification!"
|
echo "::: skipping free disk space verification!"
|
||||||
else
|
else
|
||||||
verifyFreeDiskSpace
|
verify_free_disk_space
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install packages used by this installation script
|
# Install packages used by this installation script
|
||||||
installerDependencies
|
installer_dependencies
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
welcomeDialogs
|
welcome_dialogs
|
||||||
${SUDO} mkdir -p /etc/pihole/
|
${SUDO} mkdir -p /etc/pihole/
|
||||||
# Find IP used to route to outside world
|
# Find IP used to route to outside world
|
||||||
findIPRoute
|
find_IPv4_route
|
||||||
# Find interfaces and let the user choose one
|
# Find interfaces and let the user choose one
|
||||||
chooseInterface
|
choose_interface
|
||||||
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
||||||
use4andor6
|
use_IPv4_and_or_IPv6
|
||||||
# Decide what upstream DNS Servers to use
|
# Decide what upstream DNS Servers to use
|
||||||
setDNS
|
set_upstream_dns
|
||||||
# Install and log everything to a file
|
# Install and log everything to a file
|
||||||
installPihole | tee ${tmpLog}
|
install | tee ${tmpLog}
|
||||||
else
|
else
|
||||||
updatePihole | tee ${tmpLog}
|
update | tee ${tmpLog}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Move the log file into /etc/pihole for storage
|
# Move the log file into /etc/pihole for storage
|
||||||
|
@ -976,7 +974,7 @@ echo ":::"
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:"
|
||||||
echo "::: ${IPv4addr%/*}"
|
echo "::: ${IPv4addr%/*}"
|
||||||
echo "::: $piholeIPv6"
|
echo "::: $IPv6addr"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: If you set a new IP address, you should restart the Pi."
|
echo "::: If you set a new IP address, you should restart the Pi."
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue