From 7e262bb94ae04a228c551e91c1223290a3afdad5 Mon Sep 17 00:00:00 2001 From: "Mauro Rosero P." Date: Sat, 15 Mar 2025 19:00:48 -0500 Subject: [PATCH] =?UTF-8?q?[IMPROVED]=20A=C3=B1adir=20instalaci=C3=B3n=20i?= =?UTF-8?q?ndependiente=20de=20oathtool=20y=20zbar=20en=20bootstrap.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implementar funciones oathtool_install() y zbar_install() en bootstrap.lib - Modificar bootstrap.sh para aceptar parámetros --oathtool y --zbar - Permitir instalar paquetes específicos sin instalar todo el conjunto - Adaptar la función install() para manejar instalaciones específicas - Mantener compatibilidad con el modo de instalación completa 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- bin/bootstrap.sh | 71 +++++++++++++++++++++++++++++++++++-------- bin/lib/bootstrap.lib | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 12 deletions(-) diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index e633c23..1ae253a 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -1,8 +1,8 @@ #!/bin/bash # # bootstrap.sh -# Modified: 2024/12/01 15:27:00 -# Derechos de Autor (C) [2024] [Mauro Rosero P. ] +# Modified: 2025/03/15 16:30:00 +# Derechos de Autor (C) [2025] [Mauro Rosero P. ] # # Este programa es software libre: usted puede redistribuirlo y/o modificarlo # bajo los términos de la Licencia Pública Affero General de GNU tal como @@ -48,6 +48,7 @@ install() { local LIBRARY=$2 local MESSAGES=$3 local INSTALL_LANG=$4 + local PACKAGE_ONLY=$5 # Paquete específico a instalar (opcional) local PYTHON_PACKAGE=python3 local GIT_PACKAGE=git @@ -61,9 +62,11 @@ install() { local SQLITE_PACKAGE="$SQLITE_COMMAND libsqlite3-dev" local ANSIBLE_COMMAND=ansible local ANSIBLE_PACKAGE="$ANSIBLE_COMMAND" + local OATHTOOL_PACKAGE=oathtool + local ZBAR_PACKAGE=zbar # Load base bash library - BIN_HOME=$BIN_PATH + BIN_HOME=$BIN_PATH source $BIN_PATH/$LIBRARY/base.lib # Load bootstrap bash library @@ -72,6 +75,32 @@ install() { # Load bootstrap messages load_bootstrap_msg $BIN_PATH $MESSAGES $INSTALL_LANG + # Si se especificó un paquete específico, instalar solo ese + if [ -n "$PACKAGE_ONLY" ]; then + case "$PACKAGE_ONLY" in + "oathtool") + # Instalar oathtool + command_installed $OATHTOOL_PACKAGE + if [ $? -ne 0 ]; then + oathtool_install + fi + return 0 + ;; + "zbar") + # Instalar zbar + command_installed $ZBAR_PACKAGE + if [ $? -ne 0 ]; then + zbar_install + fi + return 0 + ;; + *) + echo "Paquete '$PACKAGE_ONLY' no reconocido o no soportado." + return 1 + ;; + esac + fi + # Install wget from OS Packages command_installed $WGET_PACKAGE if [ $? -ne 0 ] @@ -107,12 +136,12 @@ install() { os_pkgs_install $DIALOG_PACKAGE fi - # Install zip from OS Packages - command_installed $ZIP_PACKAGE - if [ $? -ne 0 ] - then - os_pkgs_install $ZIP_PACKAGE - fi + # Install zip from OS Packages + command_installed $ZIP_PACKAGE + if [ $? -ne 0 ] + then + os_pkgs_install $ZIP_PACKAGE + fi # Install sqlite3 from OS Packages command_installed $SQLITE_COMMAND @@ -165,11 +194,29 @@ install() { # Load messages load_bootstrap_msg $BIN_HOME $BIN_MESG $BIN_LANG -# Display Headers -display_devstools_header "- $bomsg_000" +# Procesar argumentos +PACKAGE_TO_INSTALL="" + +if [ $# -ge 1 ]; then + case "$1" in + "--oathtool") + PACKAGE_TO_INSTALL="oathtool" + display_devstools_header "- Instalación de oathtool" + ;; + "--zbar") + PACKAGE_TO_INSTALL="zbar" + display_devstools_header "- Instalación de zbar" + ;; + *) + display_devstools_header "- $bomsg_000" + ;; + esac +else + display_devstools_header "- $bomsg_000" +fi # Run install with sudo -sudo bash -c "$(declare -f load_bootstrap_msg; declare -f install); install $BIN_HOME $BIN_LIBS $BIN_MESG $BIN_LANG" +sudo bash -c "$(declare -f load_bootstrap_msg; declare -f install); install $BIN_HOME $BIN_LIBS $BIN_MESG $BIN_LANG '$PACKAGE_TO_INSTALL'" result=$? # Run install ansible with regular user diff --git a/bin/lib/bootstrap.lib b/bin/lib/bootstrap.lib index 9f4dd0e..e1287c9 100755 --- a/bin/lib/bootstrap.lib +++ b/bin/lib/bootstrap.lib @@ -358,3 +358,61 @@ function unprivileged_port53() { return $? } + +# Install oathtool package +function oathtool_install() { + echo "Instalando oathtool (herramienta para TOTP/HOTP)..." + + if [ "$(uname)" == "Darwin" ]; then + # En macOS, instalamos a través de Homebrew + brew install oath-toolkit + elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then + # En sistemas Debian y derivados + apt update + apt install -y oathtool + elif [ -f /etc/redhat-release ]; then + # En sistemas Red Hat + dnf install -y oath-toolkit + elif [ -f /etc/arch-release ]; then + # En Arch Linux + pacman -Sy --noconfirm oath-toolkit + elif [ -f /etc/rc.conf ]; then + # En BSD + pkg install -y oath-toolkit + else + echo "${os_nofound}" + return 1 + fi + + echo "oathtool instalado correctamente." + return 0 +} + +# Install zbar package +function zbar_install() { + echo "Instalando zbar (herramienta para lectura de códigos QR)..." + + if [ "$(uname)" == "Darwin" ]; then + # En macOS, instalamos a través de Homebrew + brew install zbar + elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then + # En sistemas Debian y derivados + apt update + apt install -y zbar-tools + elif [ -f /etc/redhat-release ]; then + # En sistemas Red Hat + dnf install -y zbar + elif [ -f /etc/arch-release ]; then + # En Arch Linux + pacman -Sy --noconfirm zbar + elif [ -f /etc/rc.conf ]; then + # En BSD + pkg install -y zbar + else + echo "${os_nofound}" + return 1 + fi + + echo "zbar instalado correctamente." + return 0 +}