From 68a90dc684049c3f0c3d474ffc686f5b64937534 Mon Sep 17 00:00:00 2001 From: deltaxflux Date: Wed, 30 May 2018 00:38:10 +0200 Subject: [PATCH] Fix installer loop #523 --- lib/InterfaceUtils.sh | 8 ++++---- lib/installer/InstallerUtils.sh | 18 ++++++++++-------- lib/installer/managers/apt.sh | 4 ++++ lib/installer/managers/emerge.sh | 4 ++++ lib/installer/managers/pacman.sh | 4 ++++ lib/installer/managers/yum.sh | 4 ++++ lib/installer/managers/zypp.sh | 4 ++++ 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/lib/InterfaceUtils.sh b/lib/InterfaceUtils.sh index 1d8f3ba..8ed1da8 100755 --- a/lib/InterfaceUtils.sh +++ b/lib/InterfaceUtils.sh @@ -162,18 +162,18 @@ function interface_set_mode() { function interface_reidentify() { if [ ${#@} -ne 2 ]; then return 1; fi - + local -r __interface_reidentify__oldIdentifier=$1 local -r __interface_reidentify__newIdentifier=$2 - + if [[ $__interface_reidentify__newIdentifier == *" "* ]] then return 2 fi - + if ! interface_set_state $__interface_reidentify__oldIdentifier down then return 3 fi - + # TODO: Add alternatives to 'ip' in case of failure. ip link set $__interface_reidentify__oldIdentifier name $__interface_reidentify__newIdentifier return $? diff --git a/lib/installer/InstallerUtils.sh b/lib/installer/InstallerUtils.sh index 6a6978b..3e02823 100755 --- a/lib/installer/InstallerUtils.sh +++ b/lib/installer/InstallerUtils.sh @@ -210,7 +210,6 @@ function installer_utils_check_dependencies() { local __installer_utils_run_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")" @@ -236,8 +235,7 @@ function installer_utils_run_dependencies() { echo -e "\n\n$FormatCenterLiterals" format_center_literals "[ ${CSRed}CANNOT CONTINUE${CClr} ]" - echo -e "$FormatCenterLiterals" - sleep 5 + echo -e "$FormatCenterLiterals"; sleep 3 return 3 fi @@ -254,21 +252,25 @@ function installer_utils_run_dependencies() { done if [ ! "$PackageManagerCLT" ]; then - format_center_literals "${CRed}[ ~ No Suitable Package Manager Found ~ ]$CClr" - echo + format_center_literals "${CRed}[ ~ No Suitable Package Manager Found ~ ]$CClr";echo sleep 3 return 2 fi + check_package_manager prep_package_manager 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/*:/} + + k=${#__installer_utils_run_dependencies__packages[@]};i=1 + for __installer_utils_run_dependencies__package in ${__installer_utils_run_dependencies__packages//|/ }; do - clear - if $PackageManagerCLT $PackageManagerCLTInstallOptions $__installer_utils_run_dependencies__package; then break - fi + clear + if $PackageManagerCLT $PackageManagerCLTInstallOptions $__installer_utils_run_dependencies__package; then break; fi + if [ $k -eq $i ];then clear; echo -e "[\033[31m!\033[0m] Can't install all dependencies, quitting..."; sleep 2; fluxion_shutdown; fi + i=$(echo $(($i+1))) done done diff --git a/lib/installer/managers/apt.sh b/lib/installer/managers/apt.sh index 5128f81..4b6a456 100755 --- a/lib/installer/managers/apt.sh +++ b/lib/installer/managers/apt.sh @@ -13,6 +13,10 @@ if [ -f "/etc/debian_version" ]; then 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 } + check_package_manager() { + echo "Nothing to check." >$PackageManagerOutputDevice + } + prep_package_manager() { if [ ! "$(cat /etc/apt/sources.list | egrep 'deb http://http.kali.org/kali ((kali-rolling|main|contrib|non-free) )*')" ]; then echo "Adding missing sources to package manager, please wait." diff --git a/lib/installer/managers/emerge.sh b/lib/installer/managers/emerge.sh index 9ca53f2..1c2aa54 100755 --- a/lib/installer/managers/emerge.sh +++ b/lib/installer/managers/emerge.sh @@ -13,6 +13,10 @@ if [ -f "/etc/gentoo-release" ]; then echo "Nothing to unprepare." >$PackageManagerOutputDevice } + check_package_manager() { + echo "Nothing to check." >$PackageManagerOutputDevice + } + prep_package_manager() { echo "Nothing to prepare." >$PackageManagerOutputDevice } diff --git a/lib/installer/managers/pacman.sh b/lib/installer/managers/pacman.sh index 76f5de2..d79510a 100755 --- a/lib/installer/managers/pacman.sh +++ b/lib/installer/managers/pacman.sh @@ -21,6 +21,10 @@ if [ -f "/etc/arch-release" ]; then echo "Nothing to unprepare." >$PackageManagerOutputDevice } + check_package_manager() { + if [ -f "/var/lib/pacman/db.lck" ];then echo -e "[\033[31m!\033[0m] Pacman is locked, can't install dependencies. Exit."; exit 4; fi + } + prep_package_manager() { echo "Nothing to prepare." >$PackageManagerOutputDevice } diff --git a/lib/installer/managers/yum.sh b/lib/installer/managers/yum.sh index 3d21f3c..ad15f3a 100755 --- a/lib/installer/managers/yum.sh +++ b/lib/installer/managers/yum.sh @@ -13,6 +13,10 @@ if [ -f "/etc/redhat-release" ]; then echo "Nothing to unprepare." >$PackageManagerOutputDevice } + check_package_manager () { + echo "Nothing to check." >$PackageManagerOutputDevice + } + prep_package_manager() { echo "Nothing to prepare." >$PackageManagerOutputDevice } diff --git a/lib/installer/managers/zypp.sh b/lib/installer/managers/zypp.sh index c3b8810..071a07a 100755 --- a/lib/installer/managers/zypp.sh +++ b/lib/installer/managers/zypp.sh @@ -13,6 +13,10 @@ if [ -f "/etc/SuSE-release" ]; then echo "Nothing to unprepare." >$PackageManagerOutputDevice } + check_package_manager() { + echo "Nothing to check." >$PackageManagerOutputDevice + } + prep_package_manager() { echo "Nothing to prepare." >$PackageManagerOutputDevice }