From ccb9c919b137e6a47261082c170e465cf8c853c3 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Tue, 29 May 2018 17:44:53 -0500 Subject: [PATCH] Fixed installer bugs suppressed by bash bug. A bash was caused by a read-only variable overwritten when using source. The installer will now ask the user before attempting installation again. --- fluxion.sh | 9 +++++-- lib/installer/InstallerUtils.sh | 40 ++++++++++++++++++++++---------- lib/installer/managers/apt.sh | 12 ++++------ lib/installer/managers/emerge.sh | 2 -- lib/installer/managers/pacman.sh | 2 -- lib/installer/managers/yum.sh | 2 -- lib/installer/managers/zypp.sh | 2 -- 7 files changed, 40 insertions(+), 29 deletions(-) diff --git a/fluxion.sh b/fluxion.sh index b4f704a..8bf01a3 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -22,7 +22,7 @@ readonly FLUXIONNoiseFloor=-90 readonly FLUXIONNoiseCeiling=-60 readonly FLUXIONVersion=4 -readonly FLUXIONRevision=11 +readonly FLUXIONRevision=12 # Declare window ration bigger = smaller windows FLUXIONWindowRatio=4 @@ -275,7 +275,12 @@ fluxion_startup() { ) while ! installer_utils_check_dependencies requiredCLITools[@]; do - installer_utils_run_dependencies InstallerUtilsCheckDependencies[@] + if ! installer_utils_run_dependencies InstallerUtilsCheckDependencies[@]; then + echo + echo -e "${CRed}Dependency installation failed!$CClr" + echo "Press enter to retry, ctrl+c to exit..." + read bullshit + fi done echo -e "\n\n" # This echo is for spacing diff --git a/lib/installer/InstallerUtils.sh b/lib/installer/InstallerUtils.sh index 6a6978b..97e5fba 100755 --- a/lib/installer/InstallerUtils.sh +++ b/lib/installer/InstallerUtils.sh @@ -207,21 +207,21 @@ function installer_utils_run_update() { function installer_utils_check_dependencies() { if [ ! "$1" ]; then return 1; fi - local __installer_utils_run_dependencies__CLIToolsInfo=("${!1}") + local __installer_utils_check_dependencies__CLIToolsInfo=("${!1}") InstallerUtilsCheckDependencies=() - local __installer_utils_run_dependencies__CLIToolInfo - for __installer_utils_run_dependencies__CLIToolInfo in "${__installer_utils_run_dependencies__CLIToolsInfo[@]}"; do - local __installer_utils_run_dependencies__CLITool=${__installer_utils_run_dependencies__CLIToolInfo/:*/} - local __installer_utils_run_dependencies__identifier="$(printf "%-44s" "$__installer_utils_run_dependencies__CLITool")" - local __installer_utils_run_dependencies__state=".....$CGrn OK.$CClr" + local __installer_utils_check_dependencies__CLIToolInfo + for __installer_utils_check_dependencies__CLIToolInfo in "${__installer_utils_check_dependencies__CLIToolsInfo[@]}"; do + local __installer_utils_check_dependencies__CLITool=${__installer_utils_check_dependencies__CLIToolInfo/:*/} + local __installer_utils_check_dependencies__identifier="$(printf "%-44s" "$__installer_utils_check_dependencies__CLITool")" + local __installer_utils_check_dependencies__state=".....$CGrn OK.$CClr" - if ! hash "$__installer_utils_run_dependencies__CLITool" 2>/dev/null; then - __installer_utils_run_dependencies__state="$CRed Missing!$CClr" - InstallerUtilsCheckDependencies+=("$__installer_utils_run_dependencies__CLIToolInfo") + if ! hash "$__installer_utils_check_dependencies__CLITool" 2>/dev/null; then + __installer_utils_check_dependencies__state="$CRed Missing!$CClr" + InstallerUtilsCheckDependencies+=("$__installer_utils_check_dependencies__CLIToolInfo") fi - format_center_literals "$InstallerUtilsNoticeMark ${__installer_utils_run_dependencies__identifier// /.}$__installer_utils_run_dependencies__state" + format_center_literals "$InstallerUtilsNoticeMark ${__installer_utils_check_dependencies__identifier// /.}$__installer_utils_check_dependencies__state" echo -e "$FormatCenterLiterals" done @@ -245,7 +245,7 @@ function installer_utils_run_dependencies() { # The array below holds all the packages that will be installed. local __installer_utils_run_dependencies__dependenciesInfo=("${!1}") - local __installer_utils_run_dependencies__managers=(lib/installer/managers/*) + local __installer_utils_run_dependencies__managers=("$FLUXIONLibPath/installer/managers/"*) local __installer_utils_run_dependencies__manager for __installer_utils_run_dependencies__manager in "${__installer_utils_run_dependencies__managers[@]}"; do @@ -262,17 +262,33 @@ function installer_utils_run_dependencies() { prep_package_manager + unset __installer_utils_run_dependencies__installerStatus + for __installer_utils_run_dependencies__dependencyInfo in "${__installer_utils_run_dependencies__dependenciesInfo[@]}"; do local __installer_utils_run_dependencies__target=${__installer_utils_run_dependencies__dependencyInfo/:*/} local __installer_utils_run_dependencies__packages=${__installer_utils_run_dependencies__dependencyInfo/*:/} + unset __installer_utils_run_dependencies__packageStatus + + local __installer_utils_run_dependencies__package for __installer_utils_run_dependencies__package in ${__installer_utils_run_dependencies__packages//|/ }; do clear - if $PackageManagerCLT $PackageManagerCLTInstallOptions $__installer_utils_run_dependencies__package; then break + if $PackageManagerCLT $PackageManagerCLTInstallOptions $__installer_utils_run_dependencies__package; then + local __installer_utils_run_dependencies__packageStatus="installed" + break fi done + + if [ -z ${__installer_utils_run_dependencies__packageStatus+x} ]; then + __installer_utils_run_dependencies__installerStatus="failed" + break + fi done unprep_package_manager + + if [ "$__installer_utils_run_dependencies__installerStatus" = "failed" ]; then + return 3 + fi } # FLUXSCRIPT END diff --git a/lib/installer/managers/apt.sh b/lib/installer/managers/apt.sh index 5128f81..f00d3e3 100755 --- a/lib/installer/managers/apt.sh +++ b/lib/installer/managers/apt.sh @@ -7,8 +7,6 @@ if [ -f "/etc/debian_version" ]; then PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" - unprep_package_manager() { echo "$(cat /etc/apt/sources.list | grep -v 'deb http://http.kali.org/kali kali-rolling main non-free contrib # Installed By FLUXION')" >/etc/apt/sources.list } @@ -33,11 +31,11 @@ if [ -f "/etc/debian_version" ]; then fi # Cleanup package manager - sudo apt-get install -f -y | tee -a $PackageManagerLog - sudo apt-get autoremove -y | tee -a $PackageManagerLog - sudo apt-get autoclean -y | tee -a $PackageManagerLog - sudo apt-get clean -y | tee -a $PackageManagerLog - sudo apt-get update | tee -a $PackageManagerLog + apt-get install -f -y | tee -a $PackageManagerLog + apt-get autoremove -y | tee -a $PackageManagerLog + apt-get autoclean -y | tee -a $PackageManagerLog + apt-get clean -y | tee -a $PackageManagerLog + apt-get update | tee -a $PackageManagerLog } fi diff --git a/lib/installer/managers/emerge.sh b/lib/installer/managers/emerge.sh index 9ca53f2..28033b3 100755 --- a/lib/installer/managers/emerge.sh +++ b/lib/installer/managers/emerge.sh @@ -7,8 +7,6 @@ if [ -f "/etc/gentoo-release" ]; then PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" - unprep_package_manager() { echo "Nothing to unprepare." >$PackageManagerOutputDevice } diff --git a/lib/installer/managers/pacman.sh b/lib/installer/managers/pacman.sh index 76f5de2..f939e34 100755 --- a/lib/installer/managers/pacman.sh +++ b/lib/installer/managers/pacman.sh @@ -15,8 +15,6 @@ if [ -f "/etc/arch-release" ]; then PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" - unprep_package_manager() { echo "Nothing to unprepare." >$PackageManagerOutputDevice } diff --git a/lib/installer/managers/yum.sh b/lib/installer/managers/yum.sh index 3d21f3c..1f15913 100755 --- a/lib/installer/managers/yum.sh +++ b/lib/installer/managers/yum.sh @@ -7,8 +7,6 @@ if [ -f "/etc/redhat-release" ]; then PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" - unprep_package_manager() { echo "Nothing to unprepare." >$PackageManagerOutputDevice } diff --git a/lib/installer/managers/zypp.sh b/lib/installer/managers/zypp.sh index c3b8810..c28dbb8 100755 --- a/lib/installer/managers/zypp.sh +++ b/lib/installer/managers/zypp.sh @@ -7,8 +7,6 @@ if [ -f "/etc/SuSE-release" ]; then PackageManagerOutputDevice="/dev/stdout" - PackageManagerLog="/tmp/lib_package_manager.log" - unprep_package_manager() { echo "Nothing to unprepare." >$PackageManagerOutputDevice }