From fb5578c0d41c5668e28009138f811db335f1cf54 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 21 Dec 2016 23:38:31 -0800 Subject: [PATCH] Fedora dependency installer overhaul Signed-off-by: Dan Schaper Modify Fedora dependency installer Signed-off-by: Dan Schaper 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 --- automated install/basic-install.sh | 33 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d47034c2..8f58fa7b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -105,23 +105,22 @@ elif [ $(command -v rpm) ]; then PKG_MANAGER="yum" fi 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_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l" 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 - PIHOLE_DEPS=(${PIHOLE_DEPS#epel-release}); + if ! grep -q 'Fedora' /etc/redhat-release; then + PIHOLE_DEPS=("${PIHOLE_DEPS[@]}" "epel-release"); fi LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" DNSMASQ_USER="nobody" - - package_check_install() { - rpm -qa | grep ^"${1}"- > /dev/null || ${PKG_INSTALL} "${1}" - } else echo "OS distribution not supported" exit @@ -708,7 +707,7 @@ update_pacakge_cache() { #update package lists echo ":::" echo -n "::: ${PKG_MANAGER} update has not been run today. Running now..." - ${UPDATE_PKG_CACHE} &> /dev/null + ${UPDATE_PKG_CACHE} echo " done!" fi } @@ -751,8 +750,22 @@ install_dependent_packages() { installArray+=("${i}") fi done - debconf-apt-progress -- ${PKG_INSTALL} "${installArray[@]}" + debconf-apt-progress -- ${PKG_INSTALL} "${installArray[@]}" + return 0 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() {