diff --git a/bin/lib/bootstrap.lib b/bin/lib/bootstrap.lib index 473d8bf..bf463be 100755 --- a/bin/lib/bootstrap.lib +++ b/bin/lib/bootstrap.lib @@ -20,7 +20,9 @@ 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() { @@ -43,9 +45,13 @@ function install_pritunl() { if echo "$OS_INFO" | grep -q "Ubuntu"; then if printf "%s\n" "${UBUNTU_LIST[@]}" | grep -q "^${OS_VERSION}$" then - echo "deb https://repo.pritunl.com/stable/apt $OS_VERSION main" > /etc/apt/sources.list.d/pritunl.list - gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys $PRITUNL_SIGN - gpg --armor --export $PRITUNL_SIGN | tee /etc/apt/trusted.gpg.d/pritunl.asc + 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=$? @@ -61,6 +67,31 @@ function install_pritunl() { } +# 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() { diff --git a/bin/msg/bootstrap.es b/bin/msg/bootstrap.es index 2e2fb39..914ddc3 100644 --- a/bin/msg/bootstrap.es +++ b/bin/msg/bootstrap.es @@ -26,6 +26,7 @@ bomsg_011="Instalando cliente VPN (pritunl)" bomsg_012="No se completo la instalación del cliente VPN (pritunl)" bomsg_013="Cliente VPN (pritunl) instalado satisfactoriamente!" bomsg_014="Sistema Operativo no soportado por pritunl" +bomsg_015="ACTUALIZAR VPN" pymsg_001="Instalando python3" pymsg_002="Instalando dialog" @@ -37,3 +38,11 @@ pdmsg_001="Instalando Podman..." pdmsg_003="Podman fue instalado satisfactoriamente" domsg_005="----> Docker previamente instalado, desinstale para poder instalar PODMAN o utilice DOCKER" + +bomsg_101_1="Uso:" +bomsg_101_2="[--help] [--version] [--update]" +bomsg_102="Descripción: Este bash script se usa para instalar el cliente vpn (pritunl)" +bomsg_103="Opciones:" +bomsg_104=" --help Muestra este mensaje de ayuda." +bomsg_105=" --version Muestra la versión del script." +bomsg_106=" --update Hace una actualización (upgrade) del cliente cuando no disponible en el repo" diff --git a/bin/vpn_install.sh b/bin/vpn_install.sh index c8b89b6..216384a 100755 --- a/bin/vpn_install.sh +++ b/bin/vpn_install.sh @@ -21,6 +21,7 @@ DEVSPATH=devs BIN_HOME=$HOME/$DEVSPATH BIN_MESG=bin/msg BIN_LIBS=bin/lib +VERSION=1.0.1 # CHECK SHELL LANGUAGE BIN_LANG=${LANG:0:2} @@ -29,7 +30,7 @@ BIN_LANG=${LANG:0:2} source $BIN_HOME/$BIN_LIBS/base.lib #baselib_test -load_bootstrap_msg() { +function load_bootstrap_msg() { local BIN_PATH=$1 local MSG_PATH=$2 @@ -43,11 +44,22 @@ load_bootstrap_msg() { } -install() { +# Function to display help message +function help() { + echo "$bomsg_101_1 $0 $bomsg_101_2" + echo "$bomsg_102" + echo "$bomsg_103" + echo "$bomsg_104" + echo "$bomsg_105" + echo "$bomsg_106" +} + +function install() { local BIN_PATH=$1 local LIBRARY=$2 local MESSAGES=$3 local INSTALL_LANG=$4 + local UPDATE=$5 # Load base bash library source $BIN_PATH/$LIBRARY/base.lib @@ -59,8 +71,14 @@ install() { load_bootstrap_msg $BIN_PATH $MESSAGES $INSTALL_LANG # Install pritunl vpn client (gui) - install_pritunl - case $? in + if $UPDATE; then + update_pritunl + rc=$? + else + install_pritunl + rc=$? + fi + case $rc in 0) echo "$bomsg_013" ;; @@ -76,8 +94,43 @@ install() { # Load messages load_bootstrap_msg $BIN_HOME $BIN_MESG $BIN_LANG +# Check for arguments option +help=false +version=false +update=false +title=$bomsg_010 +while [[ $# -gt 0 ]]; do + case $1 in + --help) + help=true + shift + ;; + --version) + version=true + shift + ;; + --update) + title="$bomsg_015" + update=true + shift + ;; + esac +done + +# Check to show help +if $help; then + help + exit 0 +fi + +# Check to show command version +if $version; then + echo "$head_version $VERSION" + exit 0 +fi + # Display Headers -display_devstools_header "- $bomsg_010" +display_devstools_header "- $title" # Run install with sudo -sudo bash -c "$(declare -f load_bootstrap_msg; declare -f install); install $BIN_HOME $BIN_LIBS $BIN_MESG $BIN_LANG" +sudo bash -c "$(declare -f load_bootstrap_msg; declare -f install); install $BIN_HOME $BIN_LIBS $BIN_MESG $BIN_LANG $update"