215 lines
5.2 KiB
Bash
Executable file
215 lines
5.2 KiB
Bash
Executable file
#!/bin/bash
|
|
#Script : bootstrap.sh
|
|
#Apps : MRDEVS TOOLS
|
|
#Description : Inicialización de Ambiente de Desarrollo
|
|
#Author : Mauro Rosero Pérez
|
|
#Company Email : mauro@rosero.one
|
|
#Personal Email : mauro.rosero@gmail.com
|
|
#Created : 2025/03/19 11:57:08
|
|
#Modified : 2025/03/15 16:30:00
|
|
#Version : 1.2.0
|
|
#Use Notes :
|
|
#==============================================================================
|
|
# Derechos de Autor [2025] [Mauro Rosero P. <mauro@rosero.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/>.
|
|
|
|
# Configuración inicial
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# Leer DEVSPATH desde el archivo de configuración o usar "devs" por defecto
|
|
if [ -f "$SCRIPT_DIR/config/devspath.dat" ]; then
|
|
DEVSPATH=$(cat "$SCRIPT_DIR/config/devspath.dat")
|
|
else
|
|
DEVSPATH="devs"
|
|
fi
|
|
|
|
BIN_HOME="$HOME/$DEVSPATH"
|
|
BIN_BASE="bin"
|
|
BIN_LIBS="lib"
|
|
BIN_MESG="msg"
|
|
BIN_CFGS="config"
|
|
VERSION=$(cat "$BIN_HOME/$BIN_BASE/$BIN_CFGS/version")
|
|
|
|
# CHECK SHELL LANGUAGE
|
|
BIN_LANG=${LANG:0:2}
|
|
|
|
# Importar bibliotecas necesarias
|
|
source "${BIN_HOME}/${BIN_BASE}/${BIN_LIBS}/base.lib"
|
|
|
|
# Cargar mensajes en el idioma del sistema o español por defecto
|
|
load_messages "${BIN_HOME}/${BIN_BASE}" "${BIN_MESG}" "${BIN_LANG}" "head"
|
|
|
|
# Variables globales
|
|
title="${head_000} ${head_002}"
|
|
|
|
load_bootstrap_msg() {
|
|
|
|
local BIN_PATH=$1
|
|
local MSG_PATH=$2
|
|
local LANGUAGE=$3
|
|
|
|
# Load head messages
|
|
load_messages $BIN_PATH $MSG_PATH $LANGUAGE "head"
|
|
|
|
# Load bootstrap messages
|
|
load_messages $BIN_PATH $MSG_PATH $LANGUAGE "bootstrap"
|
|
|
|
}
|
|
|
|
install() {
|
|
local BIN_PATH=$1
|
|
local LIBRARY=$2
|
|
local MESSAGES=$3
|
|
local INSTALL_LANG=$4
|
|
|
|
local PYTHON_PACKAGE=python3
|
|
local GIT_PACKAGE=git
|
|
local CURL_PACKAGE=curl
|
|
local WGET_PACKAGE=wget
|
|
local DIALOG_PACKAGE=dialog
|
|
local SOPS_PACKAGE=sops
|
|
local GNUPG_PACKAGE=gnupg
|
|
local ZIP_PACKAGE=zip
|
|
local SQLITE_COMMAND=sqlite3
|
|
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
|
|
source $BIN_PATH/$LIBRARY/base.lib
|
|
|
|
# Load bootstrap bash library
|
|
source $BIN_PATH/$LIBRARY/bootstrap.lib
|
|
|
|
# Load bootstrap messages
|
|
load_bootstrap_msg $BIN_PATH $MESSAGES $INSTALL_LANG
|
|
|
|
# Install wget from OS Packages
|
|
command_installed $WGET_PACKAGE
|
|
if [ $? -ne 0 ]
|
|
then
|
|
os_pkgs_install $WGET_PACKAGE
|
|
fi
|
|
|
|
# Install curl from OS Packages
|
|
command_installed $CURL_PACKAGE
|
|
if [ $? -ne 0 ]
|
|
then
|
|
os_pkgs_install $CURL_PACKAGE
|
|
fi
|
|
|
|
# Install git from OS Packages
|
|
command_installed $GIT_PACKAGE
|
|
if [ $? -ne 0 ]
|
|
then
|
|
os_pkgs_install $GIT_PACKAGE
|
|
fi
|
|
|
|
# Install gnupg from OS Packages
|
|
command_installed $GNUPG_PACKAGE
|
|
if [ $? -ne 0 ]
|
|
then
|
|
os_pkgs_install $GNUGP_PACKAGE
|
|
fi
|
|
|
|
# Install dialog from OS Packages
|
|
command_installed $DIALOG_PACKAGE
|
|
if [ $? -ne 0 ]
|
|
then
|
|
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 sqlite3 from OS Packages
|
|
command_installed $SQLITE_COMMAND
|
|
if [ $? -ne 0 ]
|
|
then
|
|
os_pkgs_install $SQLITE_PACKAGE
|
|
fi
|
|
|
|
# Install python from OS Packages
|
|
command_installed $PYTHON_PACKAGE
|
|
if [ $? -ne 0 ]
|
|
then
|
|
python3_install
|
|
fi
|
|
|
|
# Verificar si pip está instalado, instalarlo si es necesario
|
|
command_installed pip3
|
|
if [ $? -ne 0 ]
|
|
then
|
|
pip_install
|
|
fi
|
|
|
|
# Install mozilla sops from OS Packages
|
|
command_installed $SOPS_PACKAGE
|
|
if [ $? -ne 0 ]
|
|
then
|
|
sops_install
|
|
fi
|
|
|
|
# Install ansible from OS Packages
|
|
command_installed $ANSIBLE_COMMAND
|
|
if [ $? -ne 0 ]
|
|
then
|
|
os_pkgs_install $ANSIBLE_PACKAGE
|
|
fi
|
|
|
|
# Check for container management installed and install podman
|
|
container_mode
|
|
if [ $? -eq 255 ]
|
|
then
|
|
# Install podman
|
|
podman_install
|
|
elif [ $? -eq 1 ]
|
|
then
|
|
echo "$domsg_005"
|
|
fi
|
|
|
|
# Install oathtool if not already installed
|
|
command_installed oathtool
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "Instalando oathtool..."
|
|
oathtool_install
|
|
fi
|
|
|
|
# Install zbar if not already installed
|
|
command_installed zbar-tools
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "Instalando zbar..."
|
|
zbar_install
|
|
fi
|
|
|
|
}
|
|
|
|
# Load messages
|
|
load_bootstrap_msg $BIN_HOME $BIN_MESG $BIN_LANG
|
|
|
|
# Display Headers
|
|
display_devstools_header "- $bomsg_000"
|
|
|
|
# Run install with sudo (sin parámetros específicos)
|
|
sudo bash -c "$(declare -f load_bootstrap_msg; declare -f install); install $BIN_HOME $BIN_LIBS $BIN_MESG $BIN_LANG"
|