Update menu.sh

This commit is contained in:
MacRimi 2024-12-20 20:26:52 +01:00 committed by GitHub
parent 4980c7b101
commit 0baa3ea30c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

57
menu.sh
View File

@ -6,6 +6,13 @@ SCRIPT_VERSION="1.0.0" # Versión actual del menú
VERSION_FILE="/tmp/proxmenux_version"
LANGUAGE_FILE="/root/.proxmenux_language"
DEFAULT_LANGUAGE="es"
TEMP_LANG_FILE="/tmp/proxmenux_lang"
# Colores para salida
YW="\033[33m"; GN="\033[1;92m"; RD="\033[01;31m"; CL="\033[m"
msg_info() { echo -ne " ${YW}[INFO] $1...${CL}"; }
msg_ok() { echo -e " ${GN}[OK] $1${CL}"; }
msg_error() { echo -e " ${RD}[ERROR] $1${CL}"; }
# Verificar idioma seleccionado o configurarlo
if [ ! -f "$LANGUAGE_FILE" ]; then
@ -17,7 +24,6 @@ LANGUAGE=$(cat "$LANGUAGE_FILE")
LANG_PATH="$REPO_URL/lang/$LANGUAGE.lang"
# Descargar archivo de idioma
TEMP_LANG_FILE="/tmp/proxmenux_lang"
wget -qO "$TEMP_LANG_FILE" "$LANG_PATH"
if [ $? -ne 0 ]; then
echo "Error al cargar el archivo de idioma. Asegúrate de que tienes conexión a Internet." >&2
@ -26,44 +32,50 @@ fi
source "$TEMP_LANG_FILE"
# Verificar si hay una nueva versión del menú
echo "Comprobando actualizaciones..."
msg_info "Comprobando actualizaciones..."
wget -qO "$VERSION_FILE" "$REPO_URL/version.txt"
if [ $? -eq 0 ]; then
REMOTE_VERSION=$(cat "$VERSION_FILE")
if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
echo "$UPDATE_AVAILABLE"
if whiptail --title "$UPDATE_TITLE" --yesno "$UPDATE_PROMPT" 10 60; then
whiptail --title "$UPDATE_TITLE" --yesno "$UPDATE_PROMPT" 10 60 && {
wget -qO /usr/local/bin/menu.sh "$REPO_URL/menu.sh"
chmod +x /usr/local/bin/menu.sh
whiptail --title "$UPDATE_COMPLETE" --msgbox "$UPDATE_MESSAGE" 10 60
exec /usr/local/bin/menu.sh
fi
}
fi
else
echo "No se pudo comprobar la versión. Continuando sin actualizar..."
msg_error "No se pudo comprobar la versión. Continuando sin actualizar..."
fi
# Menú principal
while true; do
OPTION=$(whiptail --title "$TITLE_MENU" --menu "$SELECT_OPTION" 15 60 9 \
# Función para verificar dependencias
check_dependencies() {
if ! command -v whiptail &> /dev/null; then
msg_info "Instalando dependencias necesarias..."
apt-get update
apt-get install -y whiptail
msg_ok "Dependencias instaladas."
fi
}
# Mostrar menú principal
show_menu() {
OPTION=$(whiptail --title "$MENU_TITLE" --menu "$SELECT_OPTION" 15 60 4 \
"1" "$OPTION_1" \
"2" "$OPTION_2" \
"3" "$OPTION_3" \
"4" "$CHANGE_LANGUAGE" \
"5" "$EXIT" 3>&1 1>&2 2>&3)
"3" "$EXIT" 3>&1 1>&2 2>&3)
case $OPTION in
1)
# Ejecutar script desde GitHub
msg_info "Ejecutando script para HW iGPU..."
wget -qO- "$REPO_URL/scripts/add_hw_acceleration_lxc.sh" | bash
;;
2)
wget -qO- "$REPO_URL/scripts/add_nvidia_vm.sh" | bash
msg_info "Ejecutando script para Coral TPU + HW iGPU..."
wget -qO- "$REPO_URL/scripts/add_coral_tpu_lxc.sh" | bash
wget -qO- "$REPO_URL/scripts/add_hw_acceleration_lxc.sh" | bash
;;
3)
wget -qO- "$REPO_URL/scripts/backup_proxmox.sh" | bash
;;
4)
# Cambiar idioma
NEW_LANGUAGE=$(whiptail --title "$CHANGE_LANGUAGE_TITLE" --menu "$CHOOSE_LANGUAGE" 15 60 2 \
"en" "English" \
@ -76,11 +88,18 @@ while true; do
source "$TEMP_LANG_FILE"
fi
;;
5)
4)
msg_ok "$BYE_MESSAGE"
exit 0
;;
*)
whiptail --title "$ERROR" --msgbox "$INVALID_OPTION" 8 40
msg_error "$INVALID_OPTION"
;;
esac
}
# Dependencias y bucle del menú
check_dependencies
while true; do
show_menu
done