From 56c55fcc42a7f1499203bebb6294024411667f32 Mon Sep 17 00:00:00 2001 From: Maksymilian Potok Date: Mon, 25 Jan 2021 17:31:12 +0100 Subject: [PATCH 1/4] test --- scripts/sharedFuncs.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/sharedFuncs.sh b/scripts/sharedFuncs.sh index ddf4e2d..e9fc472 100755 --- a/scripts/sharedFuncs.sh +++ b/scripts/sharedFuncs.sh @@ -10,15 +10,31 @@ function package_installed() { else echo "false" fi - else + else if [ "$pkginstalled" -eq 0 ];then show_message "package\033[1;36m $1\e[0m is installed..." else - warning "package\033[1;33m $1\e[0m is not installed.\nplease make sure it's already installed" - ask_question "would you continue?" "N" + warning "package\033[1;33m $1\e[0m is not installed." + ask_question "would you like to install it now?" "Y" if [ "$question_result" == "no" ];then echo "exit..." exit 5 + else + declare -A osInfo; + osInfo[/etc/redhat-release]=yum + osInfo[/etc/arch-release]=pacman + osInfo[/etc/SuSE-release]=zypper + osInfo[/etc/debian_version]=apt + + for f in ${!osInfo[@]} + do + if [[ -f $f ]];then + sudo ${osInfo[$f]} update + sudo ${osInfo[$f]} install $1 + echo "done" + exit 0 + fi + done fi fi fi From 1dc0d180e45d79b17459d5d13901284a3da2a05d Mon Sep 17 00:00:00 2001 From: Maksymilian Potok Date: Mon, 25 Jan 2021 17:50:34 +0100 Subject: [PATCH 2/4] fixed package managers --- scripts/sharedFuncs.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/sharedFuncs.sh b/scripts/sharedFuncs.sh index ddf4e2d..a51d357 100755 --- a/scripts/sharedFuncs.sh +++ b/scripts/sharedFuncs.sh @@ -14,11 +14,24 @@ function package_installed() { if [ "$pkginstalled" -eq 0 ];then show_message "package\033[1;36m $1\e[0m is installed..." else - warning "package\033[1;33m $1\e[0m is not installed.\nplease make sure it's already installed" - ask_question "would you continue?" "N" + warning "package\033[1;33m $1\e[0m is not installed." + ask_question "would you like to install it now?" "N" if [ "$question_result" == "no" ];then echo "exit..." exit 5 + else + declare -A osInfo; + osInfo[/etc/redhat-release]=yum upgrade && yum install + osInfo[/etc/arch-release]=pacman -Syu && pacman -S + osInfo[/etc/SuSE-release]=zypper update && zypper install + osInfo[/etc/debian_version]=apt-get update && apt-get install + + for f in ${!osInfo[@]} + do + if [[ -f $f ]];then + sudo ${osInfo[$f]} $1 + fi + done fi fi fi From 4059521039aa934b3fbf2fa8d4d47e7270ebe2d2 Mon Sep 17 00:00:00 2001 From: Maksymilian Potok Date: Thu, 28 Jan 2021 12:39:20 +0100 Subject: [PATCH 3/4] modified osInfo --- scripts/sharedFuncs.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/sharedFuncs.sh b/scripts/sharedFuncs.sh index 6f5d356..d53ff03 100755 --- a/scripts/sharedFuncs.sh +++ b/scripts/sharedFuncs.sh @@ -21,15 +21,18 @@ function package_installed() { exit 5 else declare -A osInfo; - osInfo[/etc/redhat-release]=yum upgrade && yum install - osInfo[/etc/arch-release]=pacman -Syu && pacman -S - osInfo[/etc/SuSE-release]=zypper update && zypper install - osInfo[/etc/debian_version]=apt-get update && apt-get install + osInfo[/etc/redhat-release]=yum + osInfo[/etc/SuSE-release]=zypper + osInfo[/etc/debian_version]=apt-get for f in ${!osInfo[@]} do if [[ -f $f ]];then - sudo ${osInfo[$f]} $1 + sudo ${osInfo[$f]} update + sudo ${osInfo[$f]} install $1 + else + sudo pacman -Syu + sudo pacman -S $1 fi done fi From 4491703c9ee442c70e6a870d021a51df6b732a61 Mon Sep 17 00:00:00 2001 From: Maksymilian Potok Date: Fri, 29 Jan 2021 15:46:36 +0100 Subject: [PATCH 4/4] added arch-based os support --- scripts/sharedFuncs.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/sharedFuncs.sh b/scripts/sharedFuncs.sh index d53ff03..9339049 100755 --- a/scripts/sharedFuncs.sh +++ b/scripts/sharedFuncs.sh @@ -30,12 +30,14 @@ function package_installed() { if [[ -f $f ]];then sudo ${osInfo[$f]} update sudo ${osInfo[$f]} install $1 - else - sudo pacman -Syu - sudo pacman -S $1 + return fi done - fi + # setup for arch-based systems + sudo pacman -Syu + sudo pacman -S coreutils + sudo pacman -S $1 + fi fi fi }