mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-28 04:06:54 +00:00
Update menu.sh
This commit is contained in:
parent
4980c7b101
commit
0baa3ea30c
57
menu.sh
57
menu.sh
@ -6,6 +6,13 @@ SCRIPT_VERSION="1.0.0" # Versión actual del menú
|
|||||||
VERSION_FILE="/tmp/proxmenux_version"
|
VERSION_FILE="/tmp/proxmenux_version"
|
||||||
LANGUAGE_FILE="/root/.proxmenux_language"
|
LANGUAGE_FILE="/root/.proxmenux_language"
|
||||||
DEFAULT_LANGUAGE="es"
|
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
|
# Verificar idioma seleccionado o configurarlo
|
||||||
if [ ! -f "$LANGUAGE_FILE" ]; then
|
if [ ! -f "$LANGUAGE_FILE" ]; then
|
||||||
@ -17,7 +24,6 @@ LANGUAGE=$(cat "$LANGUAGE_FILE")
|
|||||||
LANG_PATH="$REPO_URL/lang/$LANGUAGE.lang"
|
LANG_PATH="$REPO_URL/lang/$LANGUAGE.lang"
|
||||||
|
|
||||||
# Descargar archivo de idioma
|
# Descargar archivo de idioma
|
||||||
TEMP_LANG_FILE="/tmp/proxmenux_lang"
|
|
||||||
wget -qO "$TEMP_LANG_FILE" "$LANG_PATH"
|
wget -qO "$TEMP_LANG_FILE" "$LANG_PATH"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error al cargar el archivo de idioma. Asegúrate de que tienes conexión a Internet." >&2
|
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"
|
source "$TEMP_LANG_FILE"
|
||||||
|
|
||||||
# Verificar si hay una nueva versión del menú
|
# Verificar si hay una nueva versión del menú
|
||||||
echo "Comprobando actualizaciones..."
|
msg_info "Comprobando actualizaciones..."
|
||||||
wget -qO "$VERSION_FILE" "$REPO_URL/version.txt"
|
wget -qO "$VERSION_FILE" "$REPO_URL/version.txt"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
REMOTE_VERSION=$(cat "$VERSION_FILE")
|
REMOTE_VERSION=$(cat "$VERSION_FILE")
|
||||||
if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
|
if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
|
||||||
echo "$UPDATE_AVAILABLE"
|
whiptail --title "$UPDATE_TITLE" --yesno "$UPDATE_PROMPT" 10 60 && {
|
||||||
if whiptail --title "$UPDATE_TITLE" --yesno "$UPDATE_PROMPT" 10 60; then
|
|
||||||
wget -qO /usr/local/bin/menu.sh "$REPO_URL/menu.sh"
|
wget -qO /usr/local/bin/menu.sh "$REPO_URL/menu.sh"
|
||||||
chmod +x /usr/local/bin/menu.sh
|
chmod +x /usr/local/bin/menu.sh
|
||||||
whiptail --title "$UPDATE_COMPLETE" --msgbox "$UPDATE_MESSAGE" 10 60
|
whiptail --title "$UPDATE_COMPLETE" --msgbox "$UPDATE_MESSAGE" 10 60
|
||||||
exec /usr/local/bin/menu.sh
|
exec /usr/local/bin/menu.sh
|
||||||
fi
|
}
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
|
|
||||||
# Menú principal
|
# Función para verificar dependencias
|
||||||
while true; do
|
check_dependencies() {
|
||||||
OPTION=$(whiptail --title "$TITLE_MENU" --menu "$SELECT_OPTION" 15 60 9 \
|
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" \
|
"1" "$OPTION_1" \
|
||||||
"2" "$OPTION_2" \
|
"2" "$OPTION_2" \
|
||||||
"3" "$OPTION_3" \
|
"3" "$EXIT" 3>&1 1>&2 2>&3)
|
||||||
"4" "$CHANGE_LANGUAGE" \
|
|
||||||
"5" "$EXIT" 3>&1 1>&2 2>&3)
|
|
||||||
|
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
1)
|
1)
|
||||||
# Ejecutar script desde GitHub
|
msg_info "Ejecutando script para HW iGPU..."
|
||||||
wget -qO- "$REPO_URL/scripts/add_hw_acceleration_lxc.sh" | bash
|
wget -qO- "$REPO_URL/scripts/add_hw_acceleration_lxc.sh" | bash
|
||||||
;;
|
;;
|
||||||
2)
|
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)
|
3)
|
||||||
wget -qO- "$REPO_URL/scripts/backup_proxmox.sh" | bash
|
|
||||||
;;
|
|
||||||
4)
|
|
||||||
# Cambiar idioma
|
# Cambiar idioma
|
||||||
NEW_LANGUAGE=$(whiptail --title "$CHANGE_LANGUAGE_TITLE" --menu "$CHOOSE_LANGUAGE" 15 60 2 \
|
NEW_LANGUAGE=$(whiptail --title "$CHANGE_LANGUAGE_TITLE" --menu "$CHOOSE_LANGUAGE" 15 60 2 \
|
||||||
"en" "English" \
|
"en" "English" \
|
||||||
@ -76,11 +88,18 @@ while true; do
|
|||||||
source "$TEMP_LANG_FILE"
|
source "$TEMP_LANG_FILE"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
5)
|
4)
|
||||||
|
msg_ok "$BYE_MESSAGE"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
whiptail --title "$ERROR" --msgbox "$INVALID_OPTION" 8 40
|
msg_error "$INVALID_OPTION"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dependencias y bucle del menú
|
||||||
|
check_dependencies
|
||||||
|
while true; do
|
||||||
|
show_menu
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user