- Añadida función para instalar Glow (renderizador de Markdown) - Integrado en bootstrap.sh para instalación automática - Actualizado README.md para reflejar nueva herramienta - Usa repositorios oficiales de Charm cuando están disponibles - Alternativa con instalación de binarios para sistemas sin repo oficial 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
586 lines
17 KiB
Bash
Executable file
586 lines
17 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Library: bootstrap.lib
|
|
# Description: Bootstrap Developers Library
|
|
# Modified: 2024/11/30 15:27:00
|
|
# Derechos de Autor (C) [2024] [Mauro Rosero P. <mauro@roser.one>]
|
|
#
|
|
# 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
|
|
# lo publica la Free Software Foundation, ya sea la versión 3 de la licencia,
|
|
# o (a su elección) cualquier versión posterior.
|
|
#
|
|
# Este programa se distribuye con la esperanza de que sea útil,
|
|
# pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de
|
|
# COMERCIABILIDAD o IDONEIDAD PARA UN PROPÓSITO PARTICULAR. Consulte la
|
|
# Licencia Pública Affero General de GNU para obtener más detalles.
|
|
#
|
|
# Debería haber recibido una copia de la Licencia Pública Affero General
|
|
# junto con este programa. Si no la recibió, consulte <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
SOPS_VERSION=3.9.2
|
|
PRITUNL_SIGN=7568D9BB55FF9E5287D586017AE645C0CF8E292A
|
|
PRITUNL_UPDT=1.3.4099.99
|
|
UBUNTU_LIST=("jammy" "noble" "oracular")
|
|
UBUNTU_UPDT_LIST=("noble" "oracular")
|
|
|
|
# Install pritunl vpn package
|
|
function install_pritunl() {
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos o actualizamos Python a través de Homebrew
|
|
brew install git go node
|
|
bash <(curl -s https://raw.githubusercontent.com/pritunl/pritunl-client-electron/master/tools/install_macos.sh)
|
|
return $?
|
|
fi
|
|
|
|
OS_INFO=$(lsb_release -a 2>/dev/null)
|
|
if [ $? -eq 0 ]; then
|
|
OS_VERSION=$(echo "$OS_INFO" | grep "Codename" | awk '{print $2}' | tr -d ' ')
|
|
else
|
|
OS_INFO=$(cat /etc/os-release 2>/dev/null)
|
|
OS_VERSION=$(echo "$OS_INFO" | grep "VERSION_CODENAME" | awk -F ': +' '{print $2}')
|
|
fi
|
|
|
|
if echo "$OS_INFO" | grep -q "Ubuntu"; then
|
|
if printf "%s\n" "${UBUNTU_LIST[@]}" | grep -q "^${OS_VERSION}$"
|
|
then
|
|
if [ ! -f /etc/apt/sources.list.d/pritunl.list ]; then
|
|
echo "deb https://repo.pritunl.com/stable/apt $OS_VERSION main" > /etc/apt/sources.list.d/pritunl.list
|
|
fi
|
|
if [ ! -f /etc/apt/trusted.gpg.d/pritunl.asc ]; then
|
|
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys $PRITUNL_SIGN
|
|
gpg --armor --export $PRITUNL_SIGN | tee /etc/apt/trusted.gpg.d/pritunl.asc
|
|
fi
|
|
apt update
|
|
apt install pritunl-client-electron -y
|
|
local rc=$?
|
|
if [ $rc -eq 0 ]; then
|
|
systemctl daemon-reload
|
|
rc=$?
|
|
fi
|
|
return $rc
|
|
fi
|
|
fi
|
|
|
|
return 10
|
|
|
|
}
|
|
|
|
# Update pritunl vpn package
|
|
function update_pritunl() {
|
|
|
|
OS_INFO=$(lsb_release -a 2>/dev/null)
|
|
if [ $? -eq 0 ]; then
|
|
OS_VERSION=$(echo "$OS_INFO" | grep "Codename" | awk '{print $2}' | tr -d ' ')
|
|
else
|
|
OS_INFO=$(cat /etc/os-release 2>/dev/null)
|
|
OS_VERSION=$(echo "$OS_INFO" | grep "VERSION_CODENAME" | awk -F ': +' '{print $2}')
|
|
fi
|
|
|
|
if echo "$OS_INFO" | grep -q "Ubuntu"; then
|
|
if printf "%s\n" "${UBUNTU_UPDT_LIST[@]}" | grep -q "^${OS_VERSION}$"
|
|
then
|
|
cd /tmp
|
|
wget https://github.com/pritunl/pritunl-client-electron/releases/download/$PRITUNL_UPDT/pritunl-client-electron_$PRITUNL_UPDT-0ubuntu1.${OS_VERSION}_amd64.deb
|
|
dpkg -i pritunl-client-electron_$PRITUNL_UPDT-0ubuntu1.${OS_VERSION}_amd64.deb
|
|
return $?
|
|
fi
|
|
fi
|
|
|
|
return 10
|
|
|
|
}
|
|
|
|
# Install python3 package
|
|
function python3_install() {
|
|
|
|
echo "${pymsg_001}"
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos o actualizamos Python a través de Homebrew
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
brew install python
|
|
elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then
|
|
# En sistemas Debian y derivados, instalamos o actualizamos Python a través de apt
|
|
apt update
|
|
apt install -y python3-full
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# En sistemas Red Hat, instalamos o actualizamos Python a través de yum
|
|
dnf install -y python3
|
|
elif [ -f /etc/arch-release ]; then
|
|
# En Arch Linux, instalamos o actualizamos Python a través de pacman
|
|
pacman -Sy --noconfirm python
|
|
elif [ -f /etc/rc.conf ]; then
|
|
# En BSD, instalamos o actualizamos Python a través de pkg
|
|
pkg install -y python3
|
|
else
|
|
echo "${os_nofound}"
|
|
exit 1
|
|
fi
|
|
echo "${pymsg_003}"
|
|
|
|
}
|
|
|
|
# Update python3 package
|
|
function python3_update() {
|
|
|
|
echo "Actualizando Python..."
|
|
|
|
# Verificar si Python está instalado
|
|
command_installed python3
|
|
if [ $? -ne 0 ]; then
|
|
# Si Python no está instalado, llamamos a la función de instalación
|
|
python3_install
|
|
return $?
|
|
fi
|
|
|
|
# Actualizar Python según el sistema operativo
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, actualizamos Python a través de Homebrew
|
|
brew upgrade python
|
|
elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then
|
|
# En sistemas Debian y derivados
|
|
apt update
|
|
apt install --only-upgrade -y python3-full
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# En sistemas Red Hat
|
|
dnf upgrade -y python3
|
|
elif [ -f /etc/arch-release ]; then
|
|
# En Arch Linux
|
|
pacman -Syu --noconfirm python
|
|
elif [ -f /etc/rc.conf ]; then
|
|
# En BSD
|
|
pkg upgrade -y python3
|
|
else
|
|
echo "${os_nofound}"
|
|
return 1
|
|
fi
|
|
|
|
echo "Python actualizado correctamente."
|
|
return 0
|
|
|
|
}
|
|
|
|
# Install pip package
|
|
function pip_install() {
|
|
|
|
echo "Instalando pip..."
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos o actualizamos pip a través de Homebrew
|
|
brew install python-pip
|
|
elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then
|
|
# En sistemas Debian y derivados, instalamos o actualizamos pip a través de apt
|
|
apt update
|
|
apt install -y python3-pip
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# En sistemas Red Hat, instalamos o actualizamos pip a través de yum
|
|
dnf install -y python3-pip
|
|
elif [ -f /etc/arch-release ]; then
|
|
# En Arch Linux, instalamos o actualizamos pip a través de pacman
|
|
pacman -Sy --noconfirm python-pip
|
|
elif [ -f /etc/rc.conf ]; then
|
|
# En BSD, instalamos o actualizamos pip a través de pkg
|
|
pkg install -y python3-pip
|
|
else
|
|
echo "${os_nofound}"
|
|
exit 1
|
|
fi
|
|
echo "Pip instalado correctamente."
|
|
|
|
}
|
|
|
|
# Install pipx package
|
|
function pipx_install() {
|
|
echo "Instalando pipx..."
|
|
|
|
# Verificar si pip está instalado
|
|
command_installed pip3
|
|
if [ $? -ne 0 ]; then
|
|
# Si pip no está instalado, llamamos a la función de instalación
|
|
pip_install
|
|
fi
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos pipx a través de Homebrew
|
|
brew install pipx
|
|
pipx ensurepath
|
|
else
|
|
# En otros sistemas, instalamos pipx a través de pip
|
|
python3 -m pip install --user pipx
|
|
python3 -m pipx ensurepath
|
|
fi
|
|
|
|
echo "pipx instalado correctamente."
|
|
}
|
|
|
|
# Update pip package
|
|
function pip_update() {
|
|
|
|
echo "Actualizando pip..."
|
|
|
|
# Verificar si pip está instalado
|
|
command_installed pip3
|
|
if [ $? -ne 0 ]; then
|
|
# Si pip no está instalado, llamamos a la función de instalación
|
|
pip_install
|
|
return $?
|
|
fi
|
|
|
|
# Actualizar pip usando el método adecuado según el sistema operativo
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, actualizamos pip a través de Homebrew
|
|
brew upgrade python-pip
|
|
elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then
|
|
# En sistemas Debian y derivados
|
|
apt update
|
|
apt install --only-upgrade -y python3-pip
|
|
# También actualizar usando el propio pip
|
|
python3 -m pip install --upgrade pip
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# En sistemas Red Hat
|
|
dnf upgrade -y python3-pip
|
|
# También actualizar usando el propio pip
|
|
python3 -m pip install --upgrade pip
|
|
elif [ -f /etc/arch-release ]; then
|
|
# En Arch Linux
|
|
pacman -Syu --noconfirm python-pip
|
|
elif [ -f /etc/rc.conf ]; then
|
|
# En BSD
|
|
pkg upgrade -y python3-pip
|
|
# También actualizar usando el propio pip
|
|
python3 -m pip install --upgrade pip
|
|
else
|
|
echo "${os_nofound}"
|
|
return 1
|
|
fi
|
|
|
|
echo "Pip actualizado correctamente."
|
|
return 0
|
|
|
|
}
|
|
|
|
# Update pipx package
|
|
function pipx_update() {
|
|
echo "Actualizando pipx..."
|
|
|
|
# Verificar si pipx está instalado
|
|
command_installed pipx
|
|
if [ $? -ne 0 ]; then
|
|
# Si pipx no está instalado, llamamos a la función de instalación
|
|
pipx_install
|
|
return $?
|
|
fi
|
|
|
|
# Actualizar pipx según el sistema operativo
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, actualizamos pipx a través de Homebrew
|
|
brew upgrade pipx
|
|
else
|
|
# En otros sistemas, actualizamos pipx a través de pip
|
|
python3 -m pip install --user --upgrade pipx
|
|
fi
|
|
|
|
echo "pipx actualizado correctamente."
|
|
return 0
|
|
}
|
|
|
|
# Install mozilla sops package on os system supported
|
|
function sops_install() {
|
|
|
|
echo "${bomsg_006}"
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos o actualizamos Python a través de Homebrew
|
|
brew install sops
|
|
return $?
|
|
fi
|
|
|
|
# Get architecture info
|
|
cd /tmp
|
|
local arch=$(uname -m)
|
|
|
|
case $arch in
|
|
x86_64)
|
|
# Download the binary
|
|
curl -LO https://github.com/getsops/sops/releases/download/v$SOPS_VERSION/sops-v$SOPS_VERSION.linux.amd64
|
|
if [ $? -eq 0 ]; then
|
|
# Move the binary in to your PATH
|
|
mv sops-v$SOPS_VERSION.linux.amd64 /usr/local/bin/sops
|
|
if [ $? -eq 0 ]; then
|
|
# Make the binary executable
|
|
chmod a+x /usr/local/bin/sops
|
|
else
|
|
return 1
|
|
fi
|
|
else
|
|
return 1
|
|
fi
|
|
;;
|
|
arm*)
|
|
# Download the binary
|
|
curl -LO https://github.com/getsops/sops/releases/download/v$SOPS_VERSION/sops-v$SOPS_VERSION.linux.arm64
|
|
if [ $? -eq 0 ]; then
|
|
# Move the binary in to your PATH
|
|
mv sops-v$SOPS_VERSION.linux.arm64 /usr/local/bin/sops
|
|
if [ $? -eq 0 ]; then
|
|
# Make the binary executable
|
|
chmod a+x /usr/local/bin/sops
|
|
else
|
|
return 1
|
|
fi
|
|
else
|
|
return 1
|
|
fi
|
|
;;
|
|
*)
|
|
echo "$bomsg_005 $arch"
|
|
return 2
|
|
;;
|
|
esac
|
|
|
|
echo "${bomsg_007}"
|
|
return 0
|
|
|
|
}
|
|
|
|
# Install podman package
|
|
function podman_install() {
|
|
|
|
echo "${pdmsg_001}"
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos o actualizamos Python a través de Homebrew
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
brew tap containers/podman
|
|
brew install podman
|
|
elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then
|
|
# En sistemas Debian y derivados, instalamos o actualizamos Python a través de apt
|
|
apt update
|
|
apt install -y podman podman-compose
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# En sistemas Red Hat, instalamos o actualizamos Python a través de dnf
|
|
dnf install -y epel-release
|
|
dnf install -y podman podman-compose
|
|
elif [ -f /etc/arch-release ]; then
|
|
# En Arch Linux, instalamos o actualizamos Python a través de pacman
|
|
pacman -Sy --noconfirm podman podman-compose fuse-overlayfs
|
|
elif [ -f /etc/rc.conf ]; then
|
|
# En BSD, instalamos o actualizamos Python a través de pkg
|
|
pkg install -y podman-suite
|
|
else
|
|
echo "${os_nofound}"
|
|
exit 1
|
|
fi
|
|
echo "${pdmsg_003}"
|
|
|
|
}
|
|
|
|
function ansible_install() {
|
|
|
|
echo "${anmsg_001}"
|
|
python3 -m pip install --upgrade pip
|
|
python3 -m pip install --user ansible
|
|
if [ $? -eq 0 ]
|
|
then
|
|
echo "${anmsg_003}"
|
|
return 0
|
|
fi
|
|
echo "${anmsg_002}"
|
|
exit 1
|
|
|
|
}
|
|
|
|
# Set how unprivileged port 53 (dns)
|
|
function unprivileged_port53() {
|
|
|
|
local sysctlfile=/etc/sysctl.conf
|
|
local line="net.ipv4.ip_unprivileged_port_start=53"
|
|
|
|
if [[ ! -f $sysctlfile ]]; then
|
|
return 1
|
|
fi
|
|
|
|
if ! grep -q "$line" "$sysctlfile"; then
|
|
echo "$line" >> $sysctlfile
|
|
fi
|
|
|
|
sysctl -p
|
|
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
|
|
}
|
|
|
|
# Install gum package (TUI toolkit)
|
|
function gum_install() {
|
|
echo "Instalando gum (toolkit para interfaces TUI)..."
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos a través de Homebrew
|
|
brew install gum
|
|
elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then
|
|
# En sistemas Debian y derivados
|
|
mkdir -p /etc/apt/keyrings
|
|
curl -fsSL https://repo.charm.sh/apt/gpg.key | gpg --dearmor -o /etc/apt/keyrings/charm.gpg
|
|
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" > /etc/apt/sources.list.d/charm.list
|
|
apt update
|
|
apt install -y gum
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# En sistemas Red Hat
|
|
echo '[charm]
|
|
name=Charm
|
|
baseurl=https://repo.charm.sh/yum/
|
|
enabled=1
|
|
gpgcheck=1
|
|
gpgkey=https://repo.charm.sh/yum/gpg.key' | tee /etc/yum.repos.d/charm.repo
|
|
dnf install -y gum
|
|
elif [ -f /etc/arch-release ]; then
|
|
# En Arch Linux, instalamos desde AUR
|
|
command_installed "yay"
|
|
if [ $? -ne 0 ]; then
|
|
echo "Instalando yay para acceder a AUR..."
|
|
pacman -Sy --noconfirm git base-devel
|
|
git clone https://aur.archlinux.org/yay.git /tmp/yay
|
|
cd /tmp/yay
|
|
makepkg -si --noconfirm
|
|
cd - > /dev/null
|
|
rm -rf /tmp/yay
|
|
fi
|
|
yay -S --noconfirm gum
|
|
elif [ -f /etc/rc.conf ]; then
|
|
# En FreeBSD
|
|
pkg install -y gum
|
|
else
|
|
echo "${os_nofound}"
|
|
return 1
|
|
fi
|
|
|
|
echo "gum instalado correctamente."
|
|
return 0
|
|
}
|
|
|
|
# Install glow package (Markdown renderer)
|
|
function glow_install() {
|
|
echo "Instalando glow (renderizador de Markdown para terminal)..."
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
# En macOS, instalamos a través de Homebrew
|
|
brew install glow
|
|
elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then
|
|
# En sistemas Debian y derivados
|
|
mkdir -p /etc/apt/keyrings
|
|
curl -fsSL https://repo.charm.sh/apt/gpg.key | gpg --dearmor -o /etc/apt/keyrings/charm.gpg
|
|
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" > /etc/apt/sources.list.d/charm.list
|
|
apt update
|
|
apt install -y glow
|
|
elif [ -f /etc/redhat-release ]; then
|
|
# En sistemas Red Hat
|
|
echo '[charm]
|
|
name=Charm
|
|
baseurl=https://repo.charm.sh/yum/
|
|
enabled=1
|
|
gpgcheck=1
|
|
gpgkey=https://repo.charm.sh/yum/gpg.key' | tee /etc/yum.repos.d/charm.repo
|
|
dnf install -y glow
|
|
elif [ -f /etc/arch-release ]; then
|
|
# En Arch Linux, instalamos desde AUR
|
|
command_installed "yay"
|
|
if [ $? -ne 0 ]; then
|
|
echo "Instalando yay para acceder a AUR..."
|
|
pacman -Sy --noconfirm git base-devel
|
|
git clone https://aur.archlinux.org/yay.git /tmp/yay
|
|
cd /tmp/yay
|
|
makepkg -si --noconfirm
|
|
cd - > /dev/null
|
|
rm -rf /tmp/yay
|
|
fi
|
|
yay -S --noconfirm glow
|
|
elif [ -f /etc/rc.conf ]; then
|
|
# En FreeBSD
|
|
pkg install -y glow
|
|
else
|
|
# Para otros sistemas, descargamos el binario precompilado
|
|
local arch=$(uname -m)
|
|
local os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
local latest_version=$(curl -s https://api.github.com/repos/charmbracelet/glow/releases/latest | grep -oP '"tag_name": "\K[^"]+')
|
|
|
|
# Convertir arquitectura para compatibilidad con las versiones de GitHub
|
|
case $arch in
|
|
x86_64) arch="amd64" ;;
|
|
aarch64|arm64) arch="arm64" ;;
|
|
armv7*) arch="armv7" ;;
|
|
esac
|
|
|
|
# Descargar el binario adecuado
|
|
local download_url="https://github.com/charmbracelet/glow/releases/download/${latest_version}/glow_${latest_version#v}_${os}_${arch}.tar.gz"
|
|
cd /tmp
|
|
curl -Lo glow.tar.gz "$download_url"
|
|
tar xzf glow.tar.gz
|
|
mv glow /usr/local/bin/
|
|
chmod +x /usr/local/bin/glow
|
|
rm -f glow.tar.gz
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error al instalar glow."
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
echo "glow instalado correctamente."
|
|
return 0
|
|
}
|