Fedora dependency installer overhaul

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>

Modify Fedora dependency installer

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>

Fedora now installs and arrays only non-installed packages. Fedora also noops the cache update, since it updates at every dnf call anyays.

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
Dan Schaper 2016-12-21 23:38:31 -08:00
parent 07a4f970d4
commit fb5578c0d4
No known key found for this signature in database
GPG key ID: 572E999E385B7BFC

View file

@ -105,23 +105,22 @@ elif [ $(command -v rpm) ]; then
PKG_MANAGER="yum" PKG_MANAGER="yum"
fi fi
PKG_CACHE="/var/cache/${PKG_MANAGER}" PKG_CACHE="/var/cache/${PKG_MANAGER}"
UPDATE_PKG_CACHE="${PKG_MANAGER} check-update" #Every yum/dnf call will autmomatically update the cache. No-op here, cach updates when
#We get available package count.
#Also a bare `dnf check-update will return 100 as a retval, blows up set -e
UPDATE_PKG_CACHE=":"
PKG_INSTALL="${PKG_MANAGER} install -y" PKG_INSTALL="${PKG_MANAGER} install -y"
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l" PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
INSTALLER_DEPS=(git iproute net-tools newt procps-ng) INSTALLER_DEPS=(git iproute net-tools newt procps-ng)
PIHOLE_DEPS=(bc bind-utils cronie curl dnsmasq epel-release findutils lighttpd lighttpd-fastcgi nmap-ncat php php-common php-cli sudo unzip wget) PIHOLE_DEPS=(bc bind-utils cronie curl dnsmasq findutils lighttpd lighttpd-fastcgi nmap-ncat php php-common php-cli sudo unzip wget)
if grep -q 'Fedora' /etc/redhat-release; then if ! grep -q 'Fedora' /etc/redhat-release; then
PIHOLE_DEPS=(${PIHOLE_DEPS#epel-release}); PIHOLE_DEPS=("${PIHOLE_DEPS[@]}" "epel-release");
fi fi
LIGHTTPD_USER="lighttpd" LIGHTTPD_USER="lighttpd"
LIGHTTPD_GROUP="lighttpd" LIGHTTPD_GROUP="lighttpd"
LIGHTTPD_CFG="lighttpd.conf.fedora" LIGHTTPD_CFG="lighttpd.conf.fedora"
DNSMASQ_USER="nobody" DNSMASQ_USER="nobody"
package_check_install() {
rpm -qa | grep ^"${1}"- > /dev/null || ${PKG_INSTALL} "${1}"
}
else else
echo "OS distribution not supported" echo "OS distribution not supported"
exit exit
@ -708,7 +707,7 @@ update_pacakge_cache() {
#update package lists #update package lists
echo ":::" echo ":::"
echo -n "::: ${PKG_MANAGER} update has not been run today. Running now..." echo -n "::: ${PKG_MANAGER} update has not been run today. Running now..."
${UPDATE_PKG_CACHE} &> /dev/null ${UPDATE_PKG_CACHE}
echo " done!" echo " done!"
fi fi
} }
@ -752,7 +751,21 @@ install_dependent_packages() {
fi fi
done done
debconf-apt-progress -- ${PKG_INSTALL} "${installArray[@]}" debconf-apt-progress -- ${PKG_INSTALL} "${installArray[@]}"
return 0
fi fi
#Fedora
for i in "${argArray1[@]}"; do
echo -n "::: Checking for $i..."
if dnf -q list installed "${i}" &> /dev/null; then
echo " installed!"
else
echo " added to install list!"
installArray+=("${i}")
fi
done
${PKG_INSTALL} "${installArray[@]}"
return 0
} }
CreateLogFile() { CreateLogFile() {