Move Pi-hole dependency checks to main() and out of duplicated install and update functions. Bring them up a level in the subshells.

This commit is contained in:
Dan Schaper 2016-10-09 22:24:13 -07:00
parent d9e28a7422
commit 9d048b2fdf

View file

@ -616,19 +616,10 @@ notify_package_updates_available(){
} }
install_dependent_packages(){ install_dependent_packages(){
# Install packages passed in via argument array
declare -a argArray1=("${!1}") declare -a argArray1=("${!1}")
for i in "${argArray1[@]}"; do for i in "${argArray1[@]}"; do
echo -n "::: Checking for $i..."
package_check ${i} > /dev/null
echo " installed!"
done
}
checkForDependencies() {
# Install dependencies for Pi-Hole
echo "::: Checking Pi-Hole dependencies:"
for i in "${PIHOLE_DEPS[@]}"; do
echo -n "::: Checking for $i..." echo -n "::: Checking for $i..."
package_check_install ${i} > /dev/null package_check_install ${i} > /dev/null
echo " installed!" echo " installed!"
@ -787,7 +778,6 @@ finalExports() {
installPihole() { installPihole() {
# Install base files and web interface # Install base files and web interface
checkForDependencies # done
stopServices stopServices
setUser setUser
if [ ! -d "/var/www/html" ]; then if [ ! -d "/var/www/html" ]; then
@ -816,7 +806,6 @@ installPihole() {
updatePihole() { updatePihole() {
# Install base files and web interface # Install base files and web interface
checkForDependencies # done
stopServices stopServices
getGitFiles getGitFiles
installScripts installScripts
@ -934,6 +923,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