[IMPROVED] Añadir instalación independiente de oathtool y zbar en bootstrap.sh
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
28c95aab40
commit
7e262bb94a
2 changed files with 117 additions and 12 deletions
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# bootstrap.sh
|
# bootstrap.sh
|
||||||
# Modified: 2024/12/01 15:27:00
|
# Modified: 2025/03/15 16:30:00
|
||||||
# Derechos de Autor (C) [2024] [Mauro Rosero P. <mauro@roser.one>]
|
# Derechos de Autor (C) [2025] [Mauro Rosero P. <mauro@roser.one>]
|
||||||
#
|
#
|
||||||
# Este programa es software libre: usted puede redistribuirlo y/o modificarlo
|
# 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
|
# bajo los términos de la Licencia Pública Affero General de GNU tal como
|
||||||
|
@ -48,6 +48,7 @@ install() {
|
||||||
local LIBRARY=$2
|
local LIBRARY=$2
|
||||||
local MESSAGES=$3
|
local MESSAGES=$3
|
||||||
local INSTALL_LANG=$4
|
local INSTALL_LANG=$4
|
||||||
|
local PACKAGE_ONLY=$5 # Paquete específico a instalar (opcional)
|
||||||
|
|
||||||
local PYTHON_PACKAGE=python3
|
local PYTHON_PACKAGE=python3
|
||||||
local GIT_PACKAGE=git
|
local GIT_PACKAGE=git
|
||||||
|
@ -61,6 +62,8 @@ install() {
|
||||||
local SQLITE_PACKAGE="$SQLITE_COMMAND libsqlite3-dev"
|
local SQLITE_PACKAGE="$SQLITE_COMMAND libsqlite3-dev"
|
||||||
local ANSIBLE_COMMAND=ansible
|
local ANSIBLE_COMMAND=ansible
|
||||||
local ANSIBLE_PACKAGE="$ANSIBLE_COMMAND"
|
local ANSIBLE_PACKAGE="$ANSIBLE_COMMAND"
|
||||||
|
local OATHTOOL_PACKAGE=oathtool
|
||||||
|
local ZBAR_PACKAGE=zbar
|
||||||
|
|
||||||
# Load base bash library
|
# Load base bash library
|
||||||
BIN_HOME=$BIN_PATH
|
BIN_HOME=$BIN_PATH
|
||||||
|
@ -72,6 +75,32 @@ install() {
|
||||||
# Load bootstrap messages
|
# Load bootstrap messages
|
||||||
load_bootstrap_msg $BIN_PATH $MESSAGES $INSTALL_LANG
|
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
|
# Install wget from OS Packages
|
||||||
command_installed $WGET_PACKAGE
|
command_installed $WGET_PACKAGE
|
||||||
if [ $? -ne 0 ]
|
if [ $? -ne 0 ]
|
||||||
|
@ -165,11 +194,29 @@ install() {
|
||||||
# Load messages
|
# Load messages
|
||||||
load_bootstrap_msg $BIN_HOME $BIN_MESG $BIN_LANG
|
load_bootstrap_msg $BIN_HOME $BIN_MESG $BIN_LANG
|
||||||
|
|
||||||
# Display Headers
|
# Procesar argumentos
|
||||||
display_devstools_header "- $bomsg_000"
|
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
|
# 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=$?
|
result=$?
|
||||||
|
|
||||||
# Run install ansible with regular user
|
# Run install ansible with regular user
|
||||||
|
|
|
@ -358,3 +358,61 @@ function unprivileged_port53() {
|
||||||
return $?
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue