Completed implementation & integration of installer.

The installer has been defined as a utility & is incorporated into fluxion.
The installer is now responsible for checking & installing updates.
The installer is now responsible for checking & installing dependencies.

Package managers can now be defined within fluxion/lib/installer/managers.
Dependencies are now flexible, and will attempt alternative installs.
This commit is contained in:
Matias Barcenas 2017-08-21 22:56:41 -05:00
parent a5d1c4129d
commit afe1e76690
8 changed files with 80 additions and 59 deletions

View File

@ -50,6 +50,8 @@ InstallerUtilsWorkspacePath="$FLUXIONWorkspacePath"
InstallerUtilsOutputDevice="$FLUXIONOutputDevice"
InstallerUtilsNoticeMark="$FLUXIONVLine"
PackageManagerLog="$InstallerUtilsWorkspacePath/package_manager.log"
IOUtilsHeader="fluxion_header"
IOUtilsQueryMark="$FLUXIONVLine"
IOUtilsPrompt="$FLUXIONPrompt"
@ -244,10 +246,13 @@ if [ ! $FLUXIONDebug ]; then
then installer_utils_run_update "https://github.com/FluxionNetwork/fluxion/archive/master.zip" "FLUXION-V$FLUXIONVersion.$FLUXIONRevision" "`dirname "$FLUXIONPath"`"
fi
FLUXIONCLIToolsRequired=("aircrack-ng" "awk" "curl" "dhcpd" "hostapd" "lighttpd" "iwconfig" "macchanger" "mdk3" "nmap" "openssl" "php-cgi" "pyrit" "xterm" "rfkill" "unzip" "net-tools" "fuser")
FLUXIONCLIToolsMissing=("software-properties-common" "")
while ! installer_utils_check_dependencies FLUXIONCLIToolsRequired[@] FLUXIONCLIToolsMissing[@]
do installer_utils_run_dependencies FLUXIONCLIToolsMissing[@]
echo
FLUXIONCLIToolsRequired=("aircrack-ng" "awk:awk|gawk|mawk" "curl" "dhcpd:isc-dhcp-server" "hostapd" "lighttpd" "iwconfig:wireless-tools" "macchanger" "mdk3" "nmap" "openssl" "php-cgi" "pyrit" "xterm" "rfkill" "unzip" "route:net-tools" "fuser:psmisc" "killall:psmisc")
FLUXIONCLIToolsMissing=()
while ! installer_utils_check_dependencies FLUXIONCLIToolsRequired[@]
do installer_utils_run_dependencies InstallerUtilsCheckDependencies[@]
done
fi

View File

@ -9,6 +9,8 @@ InstallerUtilsOutputDevice="/dev/stdout"
InstallerUtilsNoticeMark="*"
PackageManagerLog="$InstallerUtilsWorkspacePath/package_manager.log"
function installer_utils_run_spinner() {
local pid=$1
local delay=0.15
@ -68,15 +70,17 @@ function installer_utils_check_update() {
if [ -f "$InstallerUtilsWorkspacePath/latest_version" -a \
-s "$InstallerUtilsWorkspacePath/latest_version" ]; then
mapfile __installer_utils_check_update__vInfo < "$InstallerUtilsWorkspacePath/latest_version"
local __installer_utils_check_update__vInfo
mapfile -tn 2 __installer_utils_check_update__vInfo < "$InstallerUtilsWorkspacePath/latest_version"
sandbox_remove_workfile "$InstallerUtilsWorkspacePath/latest_version"
__installer_utils_check_update__version=${__installer_utils_check_update__vInfo[0]}
__installer_utils_check_update__revision=${__installer_utils_check_update__vInfo[1]}
fi
echo -e "$CClr [$__installer_utils_check_update__version.$__installer_utils_check_update__revision$CClr]"
echo
if [ "$__installer_utils_check_update__version" != "?" -a "$__installer_utils_check_update__revision" != "?" ]; then
if [ "$__installer_utils_check_update__version" -gt "$__installer_utils_check_update__localVersion" -o \
"$__installer_utils_check_update__version" -eq "$__installer_utils_check_update__localRevision" -a \
@ -159,36 +163,35 @@ function installer_utils_run_update() {
# Parameters: $1 - CLI Tools required array $2 - CLI Tools missing array (will be populated)
function installer_utils_check_dependencies() {
if [ ${#@} -ne 2 ]; then return 1; fi
if [ ! "$1" ]; then return 1; fi
local __installer_utils_run_dependencies__CLITools=("${!1}")
local __installer_utils_run_dependencies__CLIToolsMissing=("${!2}")
local __installer_utils_run_dependencies__CLIToolsInfo=("${!1}")
InstallerUtilsCheckDependencies=()
local __installer_utils_run_dependencies__CLITool
for __installer_utils_run_dependencies__CLITool in "${__installer_utils_run_dependencies__CLITools[@]}"; do
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"
if ! hash "$__installer_utils_run_dependencies__CLITool" 2>/dev/null; then
__installer_utils_run_dependencies__state="$CRed Missing!$CClr"
__installer_utils_run_dependencies__CLIToolsMissing+=("$__installer_utils_run_dependencies__CLITool")
InstallerUtilsCheckDependencies+=("$__installer_utils_run_dependencies__CLIToolInfo")
fi
format_center_literals "$InstallerUtilsNoticeMark ${__installer_utils_run_dependencies__identifier// /.}$__installer_utils_run_dependencies__state"
echo -e "$FormatCenterLiterals"
done
if [ ${#__installer_utils_run_dependencies__CLIToolsMissing[@]} -gt 0 ]; then return 2; fi
if [ ${#InstallerUtilsCheckDependencies[@]} -gt 0 ]; then return 2; fi
}
# Parameters: $1 - CLI Tools missing array (will be installed) $2 - substitutes array
function installer_utils_run_dependencies() {
if [ "${#@}" -ne 2 ]; then return 1; fi
if [ ! "$1" ]; then return 1; fi
# The array below holds all the packages that will be installed.
local __installer_utils_run_dependencies__packages=("${!1}")
# The array below holds packages and their substitution.
local __installer_utils_run_dependencies__substitutes=("${!2}")
local __installer_utils_run_dependencies__dependenciesInfo=("${!1}")
local __installer_utils_run_dependencies__managers=(lib/installer/managers/*)
@ -206,13 +209,15 @@ function installer_utils_run_dependencies() {
prep_package_manager
for __installer_utils_run_dependencies__package in "${__installer_utils_run_dependencies__packages[@]}"; do
clear
local __installer_utils_run_dependencies__target=$__installer_utils_run_dependencies__package
if [ "${__installer_utils_run_dependencies__substitutes[$__installer_utils_run_dependencies__package]}"
then __installer_utils_run_dependencies__target=${__installer_utils_run_dependencies__substitutes[$__installer_utils_run_dependencies__package]}
fi
$PackageManagerCLT $PackageManagerCLTInstallOptions $__installer_utils_run_dependencies__target
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/*:/}
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
done
done
unprep_package_manager

View File

@ -1,30 +0,0 @@
#!/bin/bash
if [ -f "/etc/debian_version" ]
PackageManagerCLT="apt-get"
PackageManagerCLTInstallOptions="install -y"
PackageManagerCLTRemoveOptions="remove -y"
PackageManagerOutputDevice="/dev/stdout"
function unprep_package_manager() {
echo "$(cat /etc/apt/sources.list | grep -v 'deb http://http.kali.org/kali kali-rolling main contrib non-free # Installed By FLUXION')" > /etc/apt/sources.list
}
function prep_package_manager() {
if [ ! "`(cat /etc/apt/sources.list | grep 'deb http://http.kali.org/kali kali-rolling main contrib non-free'`" ]; then
gpg --keyserver hkp://keys.gnupg.net --recv-key 7D8D0BF6
apt-key adv --keyserver pgp.mit.edu --recv-keys ED444FF07D8D0BF6
echo "deb http://http.kali.org/kali kali-rolling main contrib non-free # Installed By FLUXION" >> /etc/apt/sources.list
fi
# Cleanup package manager
sudo apt-get install -f -y | tee -a $PackageManagerOutputDevice
sudo apt-get autoremove -y | tee -a $PackageManagerOutputDevice
sudo apt-get autoclean -y | tee -a $PackageManagerOutputDevice
sudo apt-get clean -y | tee -a $PackageManagerOutputDevice
sudo apt-get update | tee -a $PackageManagerOutputDevice
}
fi
# FLUXSCRIPT END

View File

@ -0,0 +1,33 @@
#!/bin/bash
if [ -f "/etc/debian_version" ]; then
PackageManagerCLT="apt"
PackageManagerCLTInstallOptions="install -y"
PackageManagerCLTRemoveOptions="remove -y"
PackageManagerOutputDevice="/dev/stdout"
PackageManagerLog="/tmp/lib_package_manager.log"
function 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
}
function prep_package_manager() {
if [ ! "`cat /etc/apt/sources.list | egrep 'deb http://http.kali.org/kali ((kali-rolling|main|contrib|non-free) )*'`" ]; then
echo "Doesn't have kali..."
gpg --keyserver hkp://keys.gnupg.net --recv-key 7D8D0BF6
apt-key adv --keyserver pgp.mit.edu --recv-keys ED444FF07D8D0BF6
echo "deb http://http.kali.org/kali kali-rolling main non-free contrib # Installed By FLUXION" >> /etc/apt/sources.list
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
}
fi
# FLUXSCRIPT END

View File

@ -1,12 +1,14 @@
#!/bin/bash
if [ -f "/etc/gentoo-release" ]
if [ -f "/etc/gentoo-release" ]; then
PackageManagerCLT="emerge"
PackageManagerCLTInstallOptions="-s"
PackageManagerCLTRemoveOptions=""
PackageManagerOutputDevice="/dev/stdout"
PackageManagerLog="/tmp/lib_package_manager.log"
function unprep_package_manager() {
echo "Nothing to unprepare." > $PackageManagerOutputDevice
}

View File

@ -1,12 +1,14 @@
#!/bin/bash
if [ -f "/etc/arch-release" ]
if [ -f "/etc/arch-release" ]; then
PackageManagerCLT="pacman"
PackageManagerCLTInstallOptions="-S -y"
PackageManagerCLTRemoveOptions="-Rs"
PackageManagerOutputDevice="/dev/stdout"
PackageManagerLog="/tmp/lib_package_manager.log"
function unprep_package_manager() {
echo "Nothing to unprepare." > $PackageManagerOutputDevice
}

View File

@ -1,12 +1,14 @@
#!/bin/bash
if [ -f "/etc/redhat-release" ]
if [ -f "/etc/redhat-release" ]; then
PackageManagerCLT="yum"
PackageManagerCLTInstallOptions="-y install"
PackageManagerCLTRemoveOptions="remove"
PackageManagerOutputDevice="/dev/stdout"
PackageManagerLog="/tmp/lib_package_manager.log"
function unprep_package_manager() {
echo "Nothing to unprepare." > $PackageManagerOutputDevice
}

View File

@ -1,12 +1,14 @@
#!/bin/bash
if [ -f "/etc/SuSE-release" ]
if [ -f "/etc/SuSE-release" ]; then
PackageManagerCLT="zypp"
PackageManagerCLTInstallOptions="install"
PackageManagerCLTRemoveOptions="remove"
PackageManagerOutputDevice="/dev/stdout"
PackageManagerLog="/tmp/lib_package_manager.log"
function unprep_package_manager() {
echo "Nothing to unprepare." > $PackageManagerOutputDevice
}