246 lines
7.4 KiB
Bash
Executable file
246 lines
7.4 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 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-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 $?
|
|
|
|
}
|