[FIXED] - Instalación pritunl

- Se agrega argumento --update a vpn_install.sh para actualización de cliente
- Otras correcciones menores
This commit is contained in:
Mauro Rosero P. 2024-12-09 00:45:07 -05:00
parent 1cd318b7f6
commit 821ce472a4
Signed by: mrosero
GPG key ID: 83BD2A5F674B7E26
3 changed files with 102 additions and 9 deletions

View file

@ -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
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() {

View file

@ -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"

View file

@ -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)
if $UPDATE; then
update_pritunl
rc=$?
else
install_pritunl
case $? in
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"