2024-12-08 05:11:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Library: $HOME/devs/bin/lib/bootstrap.lib
|
|
|
|
# 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/>.
|
|
|
|
|
2024-12-08 21:03:25 +00:00
|
|
|
|
|
|
|
SOPS_VERSION=v3.9.2
|
|
|
|
|
2024-12-08 05:11:04 +00:00
|
|
|
# Install python3 package
|
|
|
|
function python3_install() {
|
|
|
|
|
2024-12-08 21:03:25 +00:00
|
|
|
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
|
2024-12-08 05:11:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# 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}"
|
|
|
|
|
|
|
|
}
|
2024-12-08 21:03:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 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 $?
|
|
|
|
|
|
|
|
}
|