mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 06:10:20 +00:00
Monolithic changes in one commit again.
This commit is contained in:
parent
d169305e5d
commit
e6c0f38a7c
1 changed files with 41 additions and 56 deletions
|
@ -16,7 +16,7 @@
|
||||||
#
|
#
|
||||||
# curl -L install.pi-hole.net | bash
|
# curl -L install.pi-hole.net | bash
|
||||||
|
|
||||||
|
set -e
|
||||||
######## VARIABLES #########
|
######## VARIABLES #########
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,25 +65,23 @@ fi
|
||||||
if [ -x "$(command -v apt-get)" ];then
|
if [ -x "$(command -v apt-get)" ];then
|
||||||
#Debian Family
|
#Debian Family
|
||||||
#Decide if php should be `php5` or just `php` (Fixes issues with Ubuntu 16.04 LTS)
|
#Decide if php should be `php5` or just `php` (Fixes issues with Ubuntu 16.04 LTS)
|
||||||
phpVer="php"
|
|
||||||
apt-get install --dry-run php5 > /dev/null 2>&1
|
|
||||||
if [ $? == 0 ]; then
|
|
||||||
phpVer="php5"
|
phpVer="php5"
|
||||||
fi
|
apt-get install --dry-run php5 > /dev/null 2>&1 || phpVer="php"
|
||||||
#############################################
|
#############################################
|
||||||
PKG_MANAGER="apt-get"
|
PKG_MANAGER="apt-get"
|
||||||
PKG_CACHE="/var/lib/apt/lists/"
|
PKG_CACHE="/var/lib/apt/lists/"
|
||||||
UPDATE_PKG_CACHE="$PKG_MANAGER -qq update"
|
UPDATE_PKG_CACHE="$PKG_MANAGER -qq update"
|
||||||
PKG_UPDATE="$PKG_MANAGER upgrade"
|
PKG_UPDATE="$PKG_MANAGER upgrade"
|
||||||
PKG_INSTALL="$PKG_MANAGER --yes --quiet install"
|
PKG_INSTALL="$PKG_MANAGER --yes --quiet install"
|
||||||
PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst"
|
# grep -c will return 1 retVal on 0 matches, block this throwing the set -e with an OR TRUE
|
||||||
INSTALLER_DEPS=( apt-utils whiptail dhcpcd5)
|
PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
||||||
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd ${phpVer}-common ${phpVer}-cgi git curl unzip wget sudo netcat cron iproute2 )
|
INSTALLER_DEPS=( apt-utils whiptail git dhcpcd5)
|
||||||
|
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd ${phpVer}-common ${phpVer}-cgi curl unzip wget sudo netcat cron iproute2 )
|
||||||
LIGHTTPD_USER="www-data"
|
LIGHTTPD_USER="www-data"
|
||||||
LIGHTTPD_GROUP="www-data"
|
LIGHTTPD_GROUP="www-data"
|
||||||
LIGHTTPD_CFG="lighttpd.conf.debian"
|
LIGHTTPD_CFG="lighttpd.conf.debian"
|
||||||
package_check() {
|
package_check_install() {
|
||||||
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" || ${PKG_INSTALL} "$1"
|
||||||
}
|
}
|
||||||
elif [ -x "$(command -v rpm)" ];then
|
elif [ -x "$(command -v rpm)" ];then
|
||||||
# Fedora Family
|
# Fedora Family
|
||||||
|
@ -97,12 +95,12 @@ elif [ -x "$(command -v rpm)" ];then
|
||||||
PKG_UPDATE="$PKG_MANAGER update -y"
|
PKG_UPDATE="$PKG_MANAGER update -y"
|
||||||
PKG_INSTALL="$PKG_MANAGER install -y"
|
PKG_INSTALL="$PKG_MANAGER install -y"
|
||||||
PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]"
|
PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]"
|
||||||
INSTALLER_DEPS=( iproute net-tools procps-ng newt )
|
INSTALLER_DEPS=( iproute net-tools procps-ng newt git )
|
||||||
PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo nmap-ncat )
|
PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php curl unzip wget findutils cronie sudo nmap-ncat )
|
||||||
LIGHTTPD_USER="lighttpd"
|
LIGHTTPD_USER="lighttpd"
|
||||||
LIGHTTPD_GROUP="lighttpd"
|
LIGHTTPD_GROUP="lighttpd"
|
||||||
LIGHTTPD_CFG="lighttpd.conf.fedora"
|
LIGHTTPD_CFG="lighttpd.conf.fedora"
|
||||||
package_check() {
|
package_check_install() {
|
||||||
rpm -qa | grep ^$1- > /dev/null
|
rpm -qa | grep ^$1- > /dev/null
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -582,11 +580,10 @@ stop_service() {
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
installerDependencies() {
|
update_pacakge_cache() {
|
||||||
#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
|
|
||||||
# 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 apt-get 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})
|
||||||
|
@ -600,47 +597,33 @@ installerDependencies() {
|
||||||
${UPDATE_PKG_CACHE} > /dev/null 2>&1
|
${UPDATE_PKG_CACHE} > /dev/null 2>&1
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_package_updates_available(){
|
||||||
|
# Let user know if they have outdated packages on their system and
|
||||||
|
# advise them to run a package update at soonest possible.
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Checking $PKG_MANAGER for upgraded packages...."
|
echo -n "::: Checking $PKG_MANAGER for upgraded packages...."
|
||||||
updatesToInstall=$(eval "${PKG_COUNT}")
|
updatesToInstall=$(eval "${PKG_COUNT}")
|
||||||
echo " done!"
|
echo " done!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
if [[ ${updatesToInstall} -eq "0" ]]; then
|
if [[ ${updatesToInstall} -eq "0" ]]; then
|
||||||
echo "::: Your pi is up to date! Continuing with pi-hole installation..."
|
echo "::: Your system is up to date! Continuing with Pi-hole installation..."
|
||||||
else
|
else
|
||||||
echo "::: There are $updatesToInstall updates availible for your pi!"
|
echo "::: There are $updatesToInstall updates available for your system!"
|
||||||
echo "::: We recommend you run '$PKG_UPDATE' after installing Pi-Hole! "
|
echo "::: We recommend you run '$PKG_UPDATE' after installing Pi-Hole! "
|
||||||
echo ":::"
|
echo ":::"
|
||||||
fi
|
fi
|
||||||
echo ":::"
|
|
||||||
echo "::: Checking installer dependencies..."
|
|
||||||
for i in "${INSTALLER_DEPS[@]}"; do
|
|
||||||
echo -n "::: Checking for $i..."
|
|
||||||
package_check ${i} > /dev/null
|
|
||||||
if ! [ $? -eq 0 ]; then
|
|
||||||
echo -n " Not found! Installing...."
|
|
||||||
${PKG_INSTALL} "$i" > /dev/null 2>&1
|
|
||||||
echo " done!"
|
|
||||||
else
|
|
||||||
echo " already installed!"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForDependencies() {
|
install_dependent_packages(){
|
||||||
# Install dependencies for Pi-Hole
|
# Install packages passed in via argument array
|
||||||
echo "::: Checking Pi-Hole dependencies:"
|
declare -a argArray1=("${!1}")
|
||||||
|
|
||||||
for i in "${PIHOLE_DEPS[@]}"; do
|
for i in "${argArray1[@]}"; do
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
package_check ${i} > /dev/null
|
package_check_install ${i} > /dev/null
|
||||||
if ! [ $? -eq 0 ]; then
|
echo " installed!"
|
||||||
echo -n " Not found! Installing...."
|
|
||||||
${PKG_INSTALL} "$i" > /dev/null & spinner $!
|
|
||||||
echo " done!"
|
|
||||||
else
|
|
||||||
echo " already installed!"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,14 +802,8 @@ 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..."
|
||||||
package_check "selinux-policy-devel" > /dev/null
|
package_check_install "selinux-policy-devel" > /dev/null
|
||||||
if ! [ $? -eq 0 ]; then
|
echo " installed!"
|
||||||
echo -n " Not found! Installing...."
|
|
||||||
${PKG_INSTALL} "selinux-policy-devel" > /dev/null & spinner $!
|
|
||||||
echo " done!"
|
|
||||||
else
|
|
||||||
echo " already installed!"
|
|
||||||
fi
|
|
||||||
printf "::: Enabling httpd server side includes (SSI).. "
|
printf "::: Enabling httpd server side includes (SSI).. "
|
||||||
setsebool -P httpd_ssi_exec on
|
setsebool -P httpd_ssi_exec on
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
@ -904,8 +881,14 @@ else
|
||||||
verifyFreeDiskSpace
|
verifyFreeDiskSpace
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Update package cache
|
||||||
|
update_pacakge_cache
|
||||||
|
|
||||||
|
# Notify user of package availability
|
||||||
|
notify_package_updates_available
|
||||||
|
|
||||||
# Install packages used by this installation script
|
# Install packages used by this installation script
|
||||||
installerDependencies
|
install_dependent_packages INSTALLER_DEPS[@]
|
||||||
|
|
||||||
if [[ ${useUpdateVars} == false ]]; then
|
if [[ ${useUpdateVars} == false ]]; then
|
||||||
# Display welcome dialogs
|
# Display welcome dialogs
|
||||||
|
@ -928,6 +911,8 @@ if [[ ${useUpdateVars} == false ]]; then
|
||||||
use4andor6
|
use4andor6
|
||||||
# Decide what upstream DNS Servers to use
|
# Decide what upstream DNS Servers to use
|
||||||
setDNS
|
setDNS
|
||||||
|
# Install packages used by the Pi-hole
|
||||||
|
install_dependent_packages PIHOLE_DEPS[@]
|
||||||
# Install and log everything to a file
|
# Install and log everything to a file
|
||||||
installPihole | tee ${tmpLog}
|
installPihole | tee ${tmpLog}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue