[IMPROVED] Instalación de Mozilla SOPS
This commit is contained in:
		
							parent
							
								
									b86ad06bb9
								
							
						
					
					
						commit
						9c7192ed0d
					
				
					 5 changed files with 122 additions and 23 deletions
				
			
		|  | @ -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 | ||||
|  | @ -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 ] | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 <https://www.gnu.org/licenses/>. | ||||
| 
 | ||||
| 
 | ||||
| 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 $? | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -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" | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue