From 2f645486113a0047b92660a202b896d5f0405ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Tue, 28 Dec 2021 22:18:00 -0500 Subject: [update.sh]: refactory 2/2 --- hyperterm/core/update.sh | 118 +++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'hyperterm/core/update.sh') diff --git a/hyperterm/core/update.sh b/hyperterm/core/update.sh index 03e3608..b68e6c1 100644 --- a/hyperterm/core/update.sh +++ b/hyperterm/core/update.sh @@ -80,37 +80,38 @@ function updbashrc() { "Get your HyperTerm copy on: https://hgit.conocimientoslibres.ga/software/hyperterm.git" printf '%b\n' "$RESET" else - if [[ $(_url_exists "$URL") -eq 0 ]]; then - # clone '--depth=1' not support cgit - (git clone $URL /tmp/hyperterm/ --depth=1 &> /dev/null) - printf '%s\r' "##### (33%)" - sleep 1 - # core - for i in autocomplete.sh colors.sh git.sh languages.sh status.sh update.sh; do - install -m644 /tmp/hyperterm/hyperterm/core/$i "$HOME/.hyperterm/core/$i" - done - # themes - for i in default.sh joy.sh light_theme.sh minterm.sh pure.sh simple.sh special.sh; do - install -m644 /tmp/hyperterm/hyperterm/themes/$i "$HOME/.hyperterm/themes/$i" - done - # tools - (cp -f /tmp/hyperterm/hyperterm/tools/* "$HOME/.hyperterm/tools/" &> /dev/null) - - for i in hyperterm.sh hyperterm.sha512; do - install -m644 /tmp/hyperterm/hyperterm/$i "$HOME/.hyperterm/$i" - done - (cp -f /tmp/hyperterm/.bash_profile "$HOME/" &> /dev/null) - printf '%s\r' "############# (66%)" - (ifexists_custom git &> /dev/null) - sleep 1 - (rm -fr /tmp/hyperterm/) - printf '%s\n' "####################### (100%) done!" - source "$HOME/.bashrc" - else - msg_err "El repo esta deshabilitado o no hay conexión a Internet" \ - "The repo is disabled or connection failed" - return 1 - fi + case $(_url_exists "$URL") in + 200) + # clone '--depth=1' not support cgit + (git clone $URL /tmp/hyperterm/ --depth=1 &> /dev/null) + printf '%s\r' "##### (33%)" + sleep 1 + # core + for i in autocomplete.sh colors.sh git.sh languages.sh status.sh update.sh; do + install -m644 /tmp/hyperterm/hyperterm/core/$i "$HOME/.hyperterm/core/$i" + done + # themes + for i in default.sh joy.sh light_theme.sh minterm.sh pure.sh simple.sh special.sh; do + install -m644 /tmp/hyperterm/hyperterm/themes/$i "$HOME/.hyperterm/themes/$i" + done + # tools + (cp -f /tmp/hyperterm/hyperterm/tools/* "$HOME/.hyperterm/tools/" &> /dev/null) + + for i in hyperterm.sh hyperterm.sha512; do + install -m644 /tmp/hyperterm/hyperterm/$i "$HOME/.hyperterm/$i" + done + (cp -f /tmp/hyperterm/.bash_profile "$HOME/" &> /dev/null) + printf '%s\r' "############# (66%)" + (ifexists_custom git &> /dev/null) + sleep 1 + (rm -fr /tmp/hyperterm/) + printf '%s\n' "####################### (100%) done!" + source "$HOME/.bashrc" ;; + *) + msg_err "El repo esta deshabilitado o no hay conexión a Internet" \ + "The repo is disabled or connection failed" + return 1 ;; + esac fi else msg_err "No hay curl y git. Por favor, instale los programas para actualizar HyperTerm" \ @@ -120,33 +121,32 @@ function updbashrc() { } function updbashrc_custom() { - _urls "$@" - - if [[ $(_url_exists "$URL") -eq 0 ]]; then - while true - do - function _copy_c() { - if _which wget; then - wget "$RAW/hyperterm/_custom.sh" -O "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc" - elif _which curl; then - curl "$RAW/hyperterm/_custom.sh" -o "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc" - fi - } - - question=$(msg "¿Estás seguro de sobre-escribir _custom.sh? [s/N]: " \ - "Are you sure to overwrite _custom.sh? [y/N]: ") - read -r -p "$question" input - case $input in - [sS]|[yY]) _copy_c "$@"; break ;; - [nN]|"") break ;; - *) msg "Por favor responde sí o no" \ - "Please answer yes or no.";; - esac - done - else - msg_err "El repo esta deshabilitado o no hay conexión a Internet" \ - "The repo is disabled or connection failed" - return 1 - fi + case $(_url_exists "$URL") in + 200) + while true + do + function _copy_c() { + if _which wget; then + wget "$RAW/hyperterm/_custom.sh" -O "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc" + elif _which curl; then + curl "$RAW/hyperterm/_custom.sh" -o "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc" + fi + } + question=$(msg "¿Estás seguro de sobre-escribir _custom.sh? [s/N]: " \ + "Are you sure to overwrite _custom.sh? [y/N]: ") + read -r -p "$question" input + case $input in + [sS]|[yY]) _copy_c "$@"; break ;; + [nN]|"") break ;; + *) msg "Por favor responde sí o no" \ + "Please answer yes or no.";; + esac + done ;; + *) + msg_err "El repo esta deshabilitado o no hay conexión a Internet" \ + "The repo is disabled or connection failed" + return 1 + ;; + esac } -- cgit v1.2.3