From 8a22e4c66c8b48bf13a020dc0b8e6ab4766e2fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 13:34:48 +0200 Subject: [PATCH] 0.5*-- --- lib/installer.sh | 7 ++---- lib/installers/pacman.sh | 45 +++++++++++++++++++++++++++++++++++++++ lib/installers/zypper.sh | 46 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 lib/installers/pacman.sh create mode 100644 lib/installers/zypper.sh diff --git a/lib/installer.sh b/lib/installer.sh index c9bebce..ffcd440 100644 --- a/lib/installer.sh +++ b/lib/installer.sh @@ -53,15 +53,12 @@ function install() elif [ -x "$(command -v dnf)" ] || [ -x "$(command -v yum)" ] then if [[ -e ./lib/installers/rpm.sh ]]; then . ./lib/installers/rpm.sh; else . /usr/lib/lch/installers/rpm.sh; fi - # Hasta aqui he modificado elif [ -x "$(command -v pacman)" ] then - echo -e "Pacman system detected" - pacman -Sqy --noconfirm tar bzip2 gzip zip unzip p7zip 1> /dev/null + if [[ -e ./lib/installers/pacman.sh ]]; then . ./lib/installers/pacman.sh; else . /usr/lib/lch/installers/pacman.sh; fi elif [ -x "$(command -v zypper)" ] then - echo -e "Zypper system detected" - zypper install -y tar bzip2 gzip zip unzip p7zip-full 1> /dev/null + if [[ -e ./lib/installers/zypper.sh ]]; then . ./lib/installers/zypper.sh; else . /usr/lib/lch/installers/zypper.sh; fi else echo -e "System installer not detected" fi diff --git a/lib/installers/pacman.sh b/lib/installers/pacman.sh new file mode 100644 index 0000000..9188ef4 --- /dev/null +++ b/lib/installers/pacman.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Function + +function get_dep(){ + pacman -Sqy --noconfirm $@ &> /dev/null + if [[ $? -ne 0 ]]; then + if [[ $@ == "p7zip" ]]; then failed_install 7z; else failed_install $@; fi + else + if [[ $@ == "p7zip" ]]; then complete_install 7z; else complete_install $@; fi + fi +} + +# Run +echo -e "Pacman system detected" +echo "---------------------" + +apt-get update 1> /dev/null + +if [ $# -eq 1 ]; then + if $PRIVSOFT; then + rarInstall + fi + for installer in "tar" "bzip2" "gzip" "zip" "unzip" "p7zip" + do get_dep $installer + done +else + for i in $@ + do + if [ $i -ne "-i" ] + then + case $i in + "rar" | "unrar") + rarInstall + ;; + "7z" | "7zip" | "p7zip") + get_dep p7zip + ;; + *) + get_dep $i + ;; + esac + fi + done +fi \ No newline at end of file diff --git a/lib/installers/zypper.sh b/lib/installers/zypper.sh new file mode 100644 index 0000000..5647bde --- /dev/null +++ b/lib/installers/zypper.sh @@ -0,0 +1,46 @@ + +#!/usr/bin/env bash + +# Function + +function get_dep(){ + zypper install -y $@ &> /dev/null + if [[ $? -ne 0 ]]; then + if [[ $@ == "p7zip-full" ]]; then failed_install 7z; else failed_install $@; fi + else + if [[ $@ == "p7zip-full" ]]; then complete_install 7z; else complete_install $@; fi + fi +} + +# Run +echo -e "Zypper system detected" +echo "---------------------" + +apt-get update 1> /dev/null + +if [ $# -eq 1 ]; then + if $PRIVSOFT; then + rarInstall + fi + for installer in "tar" "bzip2" "gzip" "zip" "unzip" "p7zip-full" + do get_dep $installer + done +else + for i in $@ + do + if [ $i -ne "-i" ] + then + case $i in + "rar" | "unrar") + rarInstall + ;; + "7z" | "7zip" | "p7zip") + get_dep p7zip-full + ;; + *) + get_dep $i + ;; + esac + fi + done +fi \ No newline at end of file