From 3c84ab923141958d88dba4610b93ca1360adbb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 11:11:35 +0200 Subject: [PATCH] 0.6 dev --- lib/compressor.sh | 2 +- lib/installer.sh | 48 +++++++++++++++++++++---------------------- lib/installers/apt.sh | 35 +++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 lib/installers/apt.sh diff --git a/lib/compressor.sh b/lib/compressor.sh index ee5750d..49d9cef 100644 --- a/lib/compressor.sh +++ b/lib/compressor.sh @@ -37,4 +37,4 @@ function compressor() esac echo -e "\nDone" -} +} \ No newline at end of file diff --git a/lib/installer.sh b/lib/installer.sh index b374563..7db8e7d 100644 --- a/lib/installer.sh +++ b/lib/installer.sh @@ -26,36 +26,34 @@ function rarInstall(){ function install() { - echo -e "Install dependencies\n" - if [ "$UID" != "0" ]; then echo " Only root can execute this script, sorry." echo " Try 'sudo lch $@'" exit 0 fi - - if [ -e "$(command -v rar)" ] - then - echo "rar installed." + + if [ $# -eq 1 ]; then + # Poner aviso "Vamos a instalarlo todo y mucho" + read -p "Do you want to install non-free software? (rar, unrar) [y/N]: " PRIVSOFT + case ${PRIVSOFT} in + y | Y | yes) + PRIVSOFT=true + echo -e "\nInstall all dependencies (with non-free)\n";; + *) + PRIVSOFT=false + echo -e "\nOnly will install free software.\n";; + esac else - read -p "Do you want to install non-free software? (rar, unrar) [Y/N]: " PRIVSOFT - case ${PRIVSOFT} in - y|Y) - rarInstall;; - n|N) - echo -e "\nOnly will install free software.\n";; - *) - echo -e "Options: 'Y' or 'N': ";; - esac + PRIVSOFT=false fi - + if [ -x "$(command -v apt)" ] then - echo -e "APT system detected\n" - apt install -y tar bzip2 gzip zip unzip p7zip-full p7zip-rar 1> /dev/null + if [[ -e ./lib/installers/apt.sh ]]; then . ./lib/installers/apt.sh; else . /usr/lib/lch/installers/apt.sh; fi + # Hasta aqui he modificado elif [ -n "$(grep "centos" /etc/*-release)" ] then - echo -e "CentOS system detected\n" + echo -e "CentOS system detected" yum install -y -q epel-release 1> /dev/null rpm -U --quiet http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm 1> /dev/null rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 1> /dev/null @@ -63,23 +61,23 @@ function install() yum install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null elif [ -x "$(command -v dnf)" ] then - echo -e "DNF system detected\n" + echo -e "DNF system detected" dnf install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null elif [ -x "$(command -v yum)" ] then - echo -e "Yum system detected\n" + echo -e "Yum system detected" yum install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null elif [ -x "$(command -v pacman)" ] then - echo -e "Pacman system detected\n" + echo -e "Pacman system detected" pacman -Sqy --noconfirm tar bzip2 gzip zip unzip p7zip 1> /dev/null elif [ -x "$(command -v zypper)" ] then - echo -e "Zypper system detected\n" + echo -e "Zypper system detected" zypper install -y tar bzip2 gzip zip unzip p7zip-full 1> /dev/null else - echo -e "System installer not detected\n" + echo -e "System installer not detected" fi - echo -e "\nDependencies installation finished\n" + echo -e "Dependencies installation finished\n" } \ No newline at end of file diff --git a/lib/installers/apt.sh b/lib/installers/apt.sh new file mode 100644 index 0000000..6bdacbe --- /dev/null +++ b/lib/installers/apt.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Function + +function install(){ + echo "$@:" + # Busca la manera de capturar el error. Y mostrar mensaje en rojo. + apt-get install -y $@ 1> /dev/null + echo "e[32mInstalled\e[0m" +} + +# Run + +echo -e "APT system detected" +echo $@ +echo $1 +echo $0 +echo $PRIVSOFT +echo "----------" + +install $2 + +if [ $# -eq 1 ]; then + install tar + install bzip2 + install gzip + install zip + install unzip + install p7zip-full p7zip-rar +else + #Tropa + +fi + +# apt-get install -y tar bzip2 gzip zip unzip p7zip-full p7zip-rar 1> /dev/null \ No newline at end of file