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 01/14] 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 From 832718e3913277d189f38e76c1a035dd84c4a884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 11:14:00 +0200 Subject: [PATCH 02/14] 0.6 dev --- lch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lch b/lch index a311d9c..2476e3b 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.5r10 +VERSION=0.6r0 DEST=$1 shift 1 ORIG=$@ From c394876fcb9177851176ceea11b3279df88b5fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 11:42:11 +0200 Subject: [PATCH 03/14] 0.6r0 --- lib/installer.sh | 12 +++++------ lib/installers/apt.sh | 46 +++++++++++++++++++++++++++---------------- lib/resources.sh | 4 ++++ 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/lib/installer.sh b/lib/installer.sh index 7db8e7d..27409aa 100644 --- a/lib/installer.sh +++ b/lib/installer.sh @@ -11,13 +11,13 @@ function rarInstall(){ RAR_URL="https://www.rarlab.com/rar/rarlinux-5.9.1.tar.gz" RAR_FILE="rarlinux-5.9.1.tar.gz" fi - wget $RAR_URL - tar -zxvf $RAR_FILE + wget -q $RAR_URL > /dev/null + tar -zxvf $RAR_FILE > /dev/null cd rar - cp -v rar unrar /usr/local/bin/ + cp -v rar unrar /usr/local/bin/ > /dev/null cd .. - rm -r rar $RAR_FILE - echo "rar/unrar installed." + rm -r rar $RAR_FILE > /dev/null + complete_install "rar" else echo -e "\n\e[91m[Error]\e[0m - wget is not installed, so rar could not be installed.\nPlease install wget.\n" read -p "Press [ENTER] to continue installing or [CTRL+C] to exit." @@ -79,5 +79,5 @@ function install() echo -e "System installer not detected" fi - echo -e "Dependencies installation finished\n" + echo -e "\nDependencies installation finished\n" } \ No newline at end of file diff --git a/lib/installers/apt.sh b/lib/installers/apt.sh index 6bdacbe..83be413 100644 --- a/lib/installers/apt.sh +++ b/lib/installers/apt.sh @@ -2,34 +2,46 @@ # Function -function install(){ - echo "$@:" +function get_dep(){ # Busca la manera de capturar el error. Y mostrar mensaje en rojo. apt-get install -y $@ 1> /dev/null - echo "e[32mInstalled\e[0m" + complete_install $@ } # Run echo -e "APT system detected" -echo $@ -echo $1 -echo $0 -echo $PRIVSOFT -echo "----------" +echo "---------------------" -install $2 if [ $# -eq 1 ]; then - install tar - install bzip2 - install gzip - install zip - install unzip - install p7zip-full p7zip-rar + if $PRIVSOFT; then + rarInstall + fi + get_dep tar + get_dep bzip2 + get_dep gzip + get_dep zip + get_dep unzip + get_dep p7zip-full else - #Tropa - + for i in $@ + do + if [ $i != "-i" ] + then + case $i in + "rar" | "unrar") + rarInstall + ;; + "7z" | "7zip" | "p7zip") + get_dep p7zip-full + ;; + *) + get_dep $i + ;; + esac + fi + done fi # apt-get install -y tar bzip2 gzip zip unzip p7zip-full p7zip-rar 1> /dev/null \ No newline at end of file diff --git a/lib/resources.sh b/lib/resources.sh index ee8790d..2a27df8 100644 --- a/lib/resources.sh +++ b/lib/resources.sh @@ -70,4 +70,8 @@ function executer() else error_not_install $1 fi +} + +complete_install(){ + echo -e "$@:\t\t\t\e[32mComplete\e[0m" } \ No newline at end of file From 91cae2b6752394533a69a8762e07e807896c85d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 11:59:47 +0200 Subject: [PATCH 04/14] 0.6r1 --- lch | 5 +---- lib/installers/apt.sh | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lch b/lch index 2476e3b..3f4dacc 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r0 +VERSION=0.6r1 DEST=$1 shift 1 ORIG=$@ @@ -9,9 +9,6 @@ if [[ -e ./lib/compressor.sh ]]; then . ./lib/compressor.sh; else . /usr/lib/lc if [[ -e ./lib/decompressor.sh ]]; then . ./lib/decompressor.sh; else . /usr/lib/lch/decompressor.sh; fi if [[ -e ./lib/installer.sh ]]; then . ./lib/installer.sh; else . /usr/lib/lch/installer.sh; fi - -# executer tar -cvf $DEST $ORIG - if [ "$DEST" = "--version" ] || [ "$DEST" = "-v" ] then echo "Linux Compression Humanized $VERSION" diff --git a/lib/installers/apt.sh b/lib/installers/apt.sh index 83be413..250654f 100644 --- a/lib/installers/apt.sh +++ b/lib/installers/apt.sh @@ -5,7 +5,7 @@ function get_dep(){ # Busca la manera de capturar el error. Y mostrar mensaje en rojo. apt-get install -y $@ 1> /dev/null - complete_install $@ + if [[ $@ == "p7zip-full" ]]; then complete_install 7z; else complete_install $@; fi } # Run @@ -13,7 +13,6 @@ function get_dep(){ echo -e "APT system detected" echo "---------------------" - if [ $# -eq 1 ]; then if $PRIVSOFT; then rarInstall @@ -42,6 +41,4 @@ else esac fi done -fi - -# apt-get install -y tar bzip2 gzip zip unzip p7zip-full p7zip-rar 1> /dev/null \ No newline at end of file +fi \ No newline at end of file From 54194e3b89949fee15f10083970e04f1bf177fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 12:15:05 +0200 Subject: [PATCH 05/14] 0.6r2 --- lch | 2 +- lib/installer.sh | 21 ++-------- lib/installers/{apt.sh => deb.sh} | 2 +- lib/installers/rpm.sh | 65 +++++++++++++++++++++++++++++++ lib/resources.sh | 2 +- 5 files changed, 72 insertions(+), 20 deletions(-) rename lib/installers/{apt.sh => deb.sh} (96%) create mode 100644 lib/installers/rpm.sh diff --git a/lch b/lch index 3f4dacc..034326e 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r1 +VERSION=0.6r2 DEST=$1 shift 1 ORIG=$@ diff --git a/lib/installer.sh b/lib/installer.sh index 27409aa..c9bebce 100644 --- a/lib/installer.sh +++ b/lib/installer.sh @@ -49,24 +49,11 @@ function install() if [ -x "$(command -v apt)" ] then - 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" - 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 - yum repolist 1> /dev/null - yum install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null - elif [ -x "$(command -v dnf)" ] + if [[ -e ./lib/installers/deb.sh ]]; then . ./lib/installers/deb.sh; else . /usr/lib/lch/installers/deb.sh; fi + elif [ -x "$(command -v dnf)" ] || [ -x "$(command -v yum)" ] then - 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" - yum install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null + 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" diff --git a/lib/installers/apt.sh b/lib/installers/deb.sh similarity index 96% rename from lib/installers/apt.sh rename to lib/installers/deb.sh index 250654f..c2ce27e 100644 --- a/lib/installers/apt.sh +++ b/lib/installers/deb.sh @@ -26,7 +26,7 @@ if [ $# -eq 1 ]; then else for i in $@ do - if [ $i != "-i" ] + if [ $i -ne "-i" ] then case $i in "rar" | "unrar") diff --git a/lib/installers/rpm.sh b/lib/installers/rpm.sh new file mode 100644 index 0000000..c97ee1f --- /dev/null +++ b/lib/installers/rpm.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Function + +function get_dep(){ + # Busca la manera de capturar el error. Y mostrar mensaje en rojo. + yum install -y -q $@ 1> /dev/null + if [[ $@ -ne "p7zip-plugins" ]]; then complete_install $@; fi +} + +# Run + +echo -e "APT system detected" +echo "---------------------" + +if [ $# -eq 1 ]; then + if $PRIVSOFT; then + rarInstall + fi + get_dep tar + get_dep bzip2 + get_dep gzip + get_dep zip + get_dep unzip + get_dep p7zip + get_dep p7zip-plugins +else + for i in $@ + do + if [ $i -ne "-i" ] + then + case $i in + "rar" | "unrar") + rarInstall + ;; + "7z" | "7zip" | "p7zip") + get_dep p7zip + get_dep p7zip-plugins + ;; + *) + get_dep $i + ;; + esac + fi + done +fi + + +# [ -n "$(grep "centos" /etc/*-release)" ] + + +# 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 +# yum repolist 1> /dev/null +# yum install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null +# elif +# then +# echo -e "DNF system detected" +# dnf install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null +# elif +# then +# echo -e "Yum system detected" +# yum install -y -q tar bzip2 gzip zip unzip p7zip p7zip-plugins 1> /dev/null \ No newline at end of file diff --git a/lib/resources.sh b/lib/resources.sh index 2a27df8..c4b6e2e 100644 --- a/lib/resources.sh +++ b/lib/resources.sh @@ -72,6 +72,6 @@ function executer() fi } -complete_install(){ +function complete_install(){ echo -e "$@:\t\t\t\e[32mComplete\e[0m" } \ No newline at end of file From 2b48268c304b0b711c66a21b0121f6f8a7bbed91 Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 3 Oct 2020 12:42:16 +0200 Subject: [PATCH 06/14] 0.6r3 --- lch | 2 +- lib/installers/deb.sh | 20 +++++++++++--------- lib/resources.sh | 4 ++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lch b/lch index 034326e..ae93a2f 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r2 +VERSION=0.6r3 DEST=$1 shift 1 ORIG=$@ diff --git a/lib/installers/deb.sh b/lib/installers/deb.sh index c2ce27e..447c9e3 100644 --- a/lib/installers/deb.sh +++ b/lib/installers/deb.sh @@ -3,9 +3,12 @@ # Function function get_dep(){ - # Busca la manera de capturar el error. Y mostrar mensaje en rojo. - apt-get install -y $@ 1> /dev/null - if [[ $@ == "p7zip-full" ]]; then complete_install 7z; else complete_install $@; fi + apt-get 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 @@ -13,16 +16,15 @@ function get_dep(){ echo -e "APT system detected" echo "---------------------" +apt-get update 1> /dev/null + if [ $# -eq 1 ]; then if $PRIVSOFT; then rarInstall fi - get_dep tar - get_dep bzip2 - get_dep gzip - get_dep zip - get_dep unzip - get_dep p7zip-full + for installer in "tar" "bzip2" "gzip" "zip" "unzip" "p7zip-full" + do get_dep $installer + done else for i in $@ do diff --git a/lib/resources.sh b/lib/resources.sh index c4b6e2e..7dc0093 100644 --- a/lib/resources.sh +++ b/lib/resources.sh @@ -74,4 +74,8 @@ function executer() function complete_install(){ echo -e "$@:\t\t\t\e[32mComplete\e[0m" +} + +function failed_install(){ + echo -e "$@:\t\t\t\e[91mFailed\e[0m" } \ No newline at end of file From 9e02361f3164ce46531abe69718cb72be83da475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 12:43:40 +0200 Subject: [PATCH 07/14] 0.6r4 - rpm init --- lib/installers/rpm.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/installers/rpm.sh b/lib/installers/rpm.sh index c97ee1f..343a0ed 100644 --- a/lib/installers/rpm.sh +++ b/lib/installers/rpm.sh @@ -8,12 +8,25 @@ function get_dep(){ if [[ $@ -ne "p7zip-plugins" ]]; then complete_install $@; fi } +function install_centos(){ + if [ -n "$(grep "centos" /etc/*-release)" ]; then + 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 + yum repolist 1> /dev/null + fi +} + + + # Run echo -e "APT system detected" echo "---------------------" + if [ $# -eq 1 ]; then + install_centos if $PRIVSOFT; then rarInstall fi @@ -34,6 +47,7 @@ else rarInstall ;; "7z" | "7zip" | "p7zip") + install_centos get_dep p7zip get_dep p7zip-plugins ;; From 1e1be717d7a05886f30f41529c3d4dc50856ac6c Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 3 Oct 2020 13:10:10 +0200 Subject: [PATCH 08/14] 0.6r4 --- lch | 2 +- lib/installers/deb.sh | 2 +- lib/installers/rpm.sh | 39 ++++++++++++++++++++------------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/lch b/lch index ae93a2f..b1e61bd 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r3 +VERSION=0.6r4 DEST=$1 shift 1 ORIG=$@ diff --git a/lib/installers/deb.sh b/lib/installers/deb.sh index 447c9e3..a3adba1 100644 --- a/lib/installers/deb.sh +++ b/lib/installers/deb.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Function +# Functions function get_dep(){ apt-get install -y $@ &> /dev/null diff --git a/lib/installers/rpm.sh b/lib/installers/rpm.sh index 343a0ed..78ffc2b 100644 --- a/lib/installers/rpm.sh +++ b/lib/installers/rpm.sh @@ -1,42 +1,43 @@ #!/usr/bin/env bash -# Function +# Functions function get_dep(){ - # Busca la manera de capturar el error. Y mostrar mensaje en rojo. - yum install -y -q $@ 1> /dev/null - if [[ $@ -ne "p7zip-plugins" ]]; then complete_install $@; fi + if [[ $@ -ne "p7zip-plugins" ]]; then + yum install -y -q $@ 1> /dev/null + else + yum install -y -q $@ 1> /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 + fi } function install_centos(){ - if [ -n "$(grep "centos" /etc/*-release)" ]; then - 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 - yum repolist 1> /dev/null + if [ -n "$(grep "centos" /etc/*-release)" ]; then + yum install -y -q epel-release &> /dev/null + rpm --quiet --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 &> /dev/null + rpm -U --quiet http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm &> /dev/null fi } - - # Run -echo -e "APT system detected" +echo -e "YUM system detected" echo "---------------------" +yum -y -q update &> /dev/null if [ $# -eq 1 ]; then install_centos if $PRIVSOFT; then rarInstall fi - get_dep tar - get_dep bzip2 - get_dep gzip - get_dep zip - get_dep unzip - get_dep p7zip - get_dep p7zip-plugins + for installer in "tar" "bzip2" "gzip" "zip" "unzip" "p7zip" "p7zip-plugins" + do get_dep $installer + done else for i in $@ do From 909c8186cab982dee2da39e38f1550a88c45b5d2 Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 3 Oct 2020 13:33:19 +0200 Subject: [PATCH 09/14] 0.6r5 --- lch | 2 +- lib/installer.sh | 11 ++++++++--- lib/installers/rpm.sh | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lch b/lch index b1e61bd..99a3f03 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r4 +VERSION=0.6r5 DEST=$1 shift 1 ORIG=$@ diff --git a/lib/installer.sh b/lib/installer.sh index c9bebce..002aedc 100644 --- a/lib/installer.sh +++ b/lib/installer.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash function rarInstall(){ - if [ -e "$(command -v wget)" ] + if [ -e "$(command -v wget)" ] || [ -e "$(command -v curl)" ] then if [[ "$(uname -m)" == "x86_64" ]] then @@ -11,7 +11,12 @@ function rarInstall(){ RAR_URL="https://www.rarlab.com/rar/rarlinux-5.9.1.tar.gz" RAR_FILE="rarlinux-5.9.1.tar.gz" fi - wget -q $RAR_URL > /dev/null + if [ -e "$(command -v wget)" ] + then + wget -q $RAR_URL > /dev/null + else + curl -s -o $RAR_FILE $RAR_URL > /dev/null + fi tar -zxvf $RAR_FILE > /dev/null cd rar cp -v rar unrar /usr/local/bin/ > /dev/null @@ -19,7 +24,7 @@ function rarInstall(){ rm -r rar $RAR_FILE > /dev/null complete_install "rar" else - echo -e "\n\e[91m[Error]\e[0m - wget is not installed, so rar could not be installed.\nPlease install wget.\n" + echo -e "\n\e[91m[Error]\e[0m - wget or curl is not installed, so rar could not be installed.\nPlease install wget.\n" read -p "Press [ENTER] to continue installing or [CTRL+C] to exit." fi } diff --git a/lib/installers/rpm.sh b/lib/installers/rpm.sh index 78ffc2b..6cdd9cd 100644 --- a/lib/installers/rpm.sh +++ b/lib/installers/rpm.sh @@ -3,7 +3,7 @@ # Functions function get_dep(){ - if [[ $@ -ne "p7zip-plugins" ]]; then + if [[ $@ == "p7zip-plugins" ]]; then yum install -y -q $@ 1> /dev/null else yum install -y -q $@ 1> /dev/null 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 10/14] 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 From d9278518de94c4aa4f596062403b851d53cb44f9 Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 3 Oct 2020 14:21:23 +0200 Subject: [PATCH 11/14] 0.6r6 --- lch | 2 +- lib/installers/deb.sh | 4 ++++ lib/installers/pacman.sh | 6 +++++- lib/installers/rpm.sh | 4 ++++ lib/installers/zypper.sh | 6 +++++- lib/resources.sh | 9 +++++++++ 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lch b/lch index 99a3f03..09d3ede 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r5 +VERSION=0.6r6 DEST=$1 shift 1 ORIG=$@ diff --git a/lib/installers/deb.sh b/lib/installers/deb.sh index a3adba1..959ad3a 100644 --- a/lib/installers/deb.sh +++ b/lib/installers/deb.sh @@ -3,12 +3,16 @@ # Functions function get_dep(){ + wheel true & + WPID=$! apt-get 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 + disown $WPID + kill $WPID &> /dev/null } # Run diff --git a/lib/installers/pacman.sh b/lib/installers/pacman.sh index 9188ef4..869ee70 100644 --- a/lib/installers/pacman.sh +++ b/lib/installers/pacman.sh @@ -3,19 +3,23 @@ # Function function get_dep(){ + wheel true & + WPID=$! 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 + disown $WPID + kill $WPID &> /dev/null } # Run echo -e "Pacman system detected" echo "---------------------" -apt-get update 1> /dev/null +pacman -F -y 1> /dev/null if [ $# -eq 1 ]; then if $PRIVSOFT; then diff --git a/lib/installers/rpm.sh b/lib/installers/rpm.sh index 6cdd9cd..8bc152e 100644 --- a/lib/installers/rpm.sh +++ b/lib/installers/rpm.sh @@ -3,6 +3,8 @@ # Functions function get_dep(){ + wheel true & + WPID=$! if [[ $@ == "p7zip-plugins" ]]; then yum install -y -q $@ 1> /dev/null else @@ -13,6 +15,8 @@ function get_dep(){ if [[ $@ == "p7zip" ]]; then complete_install 7z; else complete_install $@; fi fi fi + disown $WPID + kill $WPID &> /dev/null } function install_centos(){ diff --git a/lib/installers/zypper.sh b/lib/installers/zypper.sh index 5647bde..9fc9d84 100644 --- a/lib/installers/zypper.sh +++ b/lib/installers/zypper.sh @@ -4,19 +4,23 @@ # Function function get_dep(){ + wheel true & + WPID=$! 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 + disown $WPID + kill $WPID &> /dev/null } # Run echo -e "Zypper system detected" echo "---------------------" -apt-get update 1> /dev/null +zypper -q up -y 1> /dev/null if [ $# -eq 1 ]; then if $PRIVSOFT; then diff --git a/lib/resources.sh b/lib/resources.sh index 7dc0093..8c5dacd 100644 --- a/lib/resources.sh +++ b/lib/resources.sh @@ -78,4 +78,13 @@ function complete_install(){ function failed_install(){ echo -e "$@:\t\t\t\e[91mFailed\e[0m" +} + +function wheel() { + sp='/-\|' + while $1; do + printf '%.1s\b' "$sp" + sp=${sp#?}${sp%???} + sleep 0.1s + done } \ No newline at end of file From 667e00baea2c1e5ebc8e78309dba8665abf0ded4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 14:30:06 +0200 Subject: [PATCH 12/14] 0.6r7 - Stable --- lch | 2 +- lib/installer.sh | 2 +- lib/installers/deb.sh | 5 +++++ lib/installers/pacman.sh | 4 ++++ lib/installers/rpm.sh | 4 ++++ lib/installers/zypper.sh | 4 ++++ lib/resources.sh | 4 ++++ 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lch b/lch index 09d3ede..ce955ee 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r6 +VERSION=0.6r7 DEST=$1 shift 1 ORIG=$@ diff --git a/lib/installer.sh b/lib/installer.sh index cfd64a7..ef24acc 100644 --- a/lib/installer.sh +++ b/lib/installer.sh @@ -55,7 +55,7 @@ function install() if [ -x "$(command -v apt)" ] then if [[ -e ./lib/installers/deb.sh ]]; then . ./lib/installers/deb.sh; else . /usr/lib/lch/installers/deb.sh; fi - elif [ -x "$(command -v dnf)" ] || [ -x "$(command -v yum)" ] + elif [ -x "$(command -v yum)" ] then if [[ -e ./lib/installers/rpm.sh ]]; then . ./lib/installers/rpm.sh; else . /usr/lib/lch/installers/rpm.sh; fi elif [ -x "$(command -v pacman)" ] diff --git a/lib/installers/deb.sh b/lib/installers/deb.sh index 959ad3a..3e9b16c 100644 --- a/lib/installers/deb.sh +++ b/lib/installers/deb.sh @@ -20,7 +20,12 @@ function get_dep(){ echo -e "APT system detected" echo "---------------------" +wheel true & +WPID=$! apt-get update 1> /dev/null +disown $WPID +kill $WPID &> /dev/null + if [ $# -eq 1 ]; then if $PRIVSOFT; then diff --git a/lib/installers/pacman.sh b/lib/installers/pacman.sh index 869ee70..8154713 100644 --- a/lib/installers/pacman.sh +++ b/lib/installers/pacman.sh @@ -19,7 +19,11 @@ function get_dep(){ echo -e "Pacman system detected" echo "---------------------" +wheel true & +WPID=$! pacman -F -y 1> /dev/null +disown $WPID +kill $WPID &> /dev/null if [ $# -eq 1 ]; then if $PRIVSOFT; then diff --git a/lib/installers/rpm.sh b/lib/installers/rpm.sh index 8bc152e..2eb2fbc 100644 --- a/lib/installers/rpm.sh +++ b/lib/installers/rpm.sh @@ -32,7 +32,11 @@ function install_centos(){ echo -e "YUM system detected" echo "---------------------" +wheel true & +WPID=$! yum -y -q update &> /dev/null +disown $WPID +kill $WPID &> /dev/null if [ $# -eq 1 ]; then install_centos diff --git a/lib/installers/zypper.sh b/lib/installers/zypper.sh index 9fc9d84..e3dcfae 100644 --- a/lib/installers/zypper.sh +++ b/lib/installers/zypper.sh @@ -20,7 +20,11 @@ function get_dep(){ echo -e "Zypper system detected" echo "---------------------" +wheel true & +WPID=$! zypper -q up -y 1> /dev/null +disown $WPID +kill $WPID &> /dev/null if [ $# -eq 1 ]; then if $PRIVSOFT; then diff --git a/lib/resources.sh b/lib/resources.sh index 8c5dacd..0310795 100644 --- a/lib/resources.sh +++ b/lib/resources.sh @@ -34,6 +34,8 @@ function check() echo "----------------------------------" for i in "7z" "bzip2" "gzip" "rar" "tar" "unrar" "unzip" "zip" do + wheel true & + WPID=$! if ! [ -x "$(command -v $i)" ] then echo -e "$i\t\t\t\e[91mNot Installed\e[0m" @@ -41,6 +43,8 @@ function check() else echo -e "$i\t\t\t\e[32mInstalled\e[0m" fi + disown $WPID + kill $WPID &> /dev/null done if $a From 0bfa956345ff42881e21981f59d882e8c80ba3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mesa=20Rold=C3=A1n?= Date: Sat, 3 Oct 2020 14:37:32 +0200 Subject: [PATCH 13/14] 0.6r7 - Stable --- lib/resources.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/resources.sh b/lib/resources.sh index 0310795..78fe1df 100644 --- a/lib/resources.sh +++ b/lib/resources.sh @@ -68,12 +68,16 @@ function error_not_install() function executer() { + wheel true & + WPID=$! if [ -x "$(command -v $1)" ] then "$@" else error_not_install $1 fi + disown $WPID + kill $WPID &> /dev/null } function complete_install(){ From f30aed7d2b0a471802888369dff2a95f7f188b00 Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 3 Oct 2020 14:47:56 +0200 Subject: [PATCH 14/14] 0.6r8 --- lch | 2 +- lib/compressor.sh | 2 +- lib/decompressor.sh | 2 +- lib/resources.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lch b/lch index ce955ee..0067165 100755 --- a/lch +++ b/lch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION=0.6r7 +VERSION=0.6r8 DEST=$1 shift 1 ORIG=$@ diff --git a/lib/compressor.sh b/lib/compressor.sh index 49d9cef..96e433b 100644 --- a/lib/compressor.sh +++ b/lib/compressor.sh @@ -36,5 +36,5 @@ function compressor() ;; esac - echo -e "\nDone" + echo -e "\nFile $DEST compressed." } \ No newline at end of file diff --git a/lib/decompressor.sh b/lib/decompressor.sh index b1258b1..6302289 100644 --- a/lib/decompressor.sh +++ b/lib/decompressor.sh @@ -36,5 +36,5 @@ function decompressor() ;; esac - echo -e "\nDone" + echo -e "\nFile $DEST decompressed." } \ No newline at end of file diff --git a/lib/resources.sh b/lib/resources.sh index 78fe1df..73e296c 100644 --- a/lib/resources.sh +++ b/lib/resources.sh @@ -72,7 +72,7 @@ function executer() WPID=$! if [ -x "$(command -v $1)" ] then - "$@" + "$@" 1> /dev/null else error_not_install $1 fi