From 9c7192ed0d0fa284182d5d66453da89d6e7476ac Mon Sep 17 00:00:00 2001 From: Mauro Rosero P Date: Sun, 8 Dec 2024 16:03:25 -0500 Subject: [PATCH] =?UTF-8?q?[IMPROVED]=20Instalaci=C3=B3n=20de=20Mozilla=20?= =?UTF-8?q?SOPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++ bin/bootstrap.sh | 8 +++ bin/lib/base.lib | 4 ++ bin/lib/bootstrap.lib | 119 ++++++++++++++++++++++++++++++++++-------- bin/msg/bootstrap.es | 6 +++ 5 files changed, 122 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index af5a581..bc92a57 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,11 @@ A partir de este momento, la carpeta $HOME/devs será nuestra área de desarroll $ cd $HOME/devs $ bin/bootstrap.sh + +### GESTIÓN DE DNS LOCAL PARA DESARROLLADORES (DNSMASQ) + +#### Habilitar permiso local para puerto 53 (DNS) + +Antes de poder levantar el contenedor dnsmasq, se requiere dar permisos para poder habilitar el puerto 53: + + $ dns/setport53.sh \ No newline at end of file diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index 1e25751..559c88f 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -54,6 +54,7 @@ install() { local CURL_PACKAGE=curl local WGET_PACKAGE=wget local DIALOG_PACKAGE=dialog + local SOPS_PACKAGE=sops # Load base bash library source $BIN_PATH/$LIBRARY/base.lib @@ -99,6 +100,13 @@ install() { python3_install fi + # Install mozilla sops from OS Packages + command_installed $SOPS_PACKAGE + if [ $? -ne 0 ] + then + sops_install + fi + # Check for container management installed and install podman container_mode if [ $? -eq 255 ] diff --git a/bin/lib/base.lib b/bin/lib/base.lib index f27ce36..2066b77 100644 --- a/bin/lib/base.lib +++ b/bin/lib/base.lib @@ -285,6 +285,7 @@ function get_osname() { } +# Build container with docker function docker_build() { local CONTAINER=$1 @@ -295,6 +296,7 @@ function docker_build() { } +# Build container with podman function podman_build() { local CONTAINER=$1 @@ -313,6 +315,7 @@ function podman_build() { } +# Build container with podman or docker function build_container() { local CONTAINER=$1 @@ -335,3 +338,4 @@ function build_container() { return 1 } + diff --git a/bin/lib/bootstrap.lib b/bin/lib/bootstrap.lib index 1305100..5c574e7 100755 --- a/bin/lib/bootstrap.lib +++ b/bin/lib/bootstrap.lib @@ -17,32 +17,85 @@ # Debería haber recibido una copia de la Licencia Pública Affero General # junto con este programa. Si no la recibió, consulte . + +SOPS_VERSION=v3.9.2 + # 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 python-pip - 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 python3-pip - elif [ -f /etc/redhat-release ]; then - # En sistemas Red Hat, instalamos o actualizamos Python a través de yum - dnf install -y python3 python3-pip - 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 python3-pip - else - echo "${os_nofound}" - exit 1 - fi - echo "${pymsg_003}" + 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 python-pip + 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 python3-pip + elif [ -f /etc/redhat-release ]; then + # En sistemas Red Hat, instalamos o actualizamos Python a través de yum + dnf install -y python3 python3-pip + 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 python3-pip + else + echo "${os_nofound}" + exit 1 + fi + echo "${pymsg_003}" + +} + +# 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-$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 + # Make the binary executable + chmod +x /usr/local/bin/sops + else + return 1 + fi + ;; + arm*) + # Download the binary + curl -LO https://github.com/getsops/sops/releases/download/v$SOPS_VERSION/sops-$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 + # Make the binary executable + chmod +x /usr/local/bin/sops + else + return 1 + fi + ;; + *) + echo "$bomsg_005 $arch" + return 2 + ;; + esac + + echo "${bomsg_007}" + return 0 } @@ -76,3 +129,23 @@ function podman_install() { echo "${pdmsg_003}" } + + +# 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 $? + +} diff --git a/bin/msg/bootstrap.es b/bin/msg/bootstrap.es index 2b85f16..0417a94 100644 --- a/bin/msg/bootstrap.es +++ b/bin/msg/bootstrap.es @@ -12,6 +12,12 @@ #============================================================================== bomsg_000="BOOTSTRAP" +bomsg_002="PERMITIR PUERTO 53" +bomsg_003="Puerto 53 no se ha liberado!" +bomsg_004="Puerto 53 (dns) ha sido liberado para uso no-root" +bomsg_005="Arquitectura desconocida:" +bomsg_006="Instalando Mozilla SOPS..." +bomsg_007="Instalación de Mozilla SOPS completada..." pymsg_001="Instalando python3" pymsg_002="Instalando dialog"