ProxMenux/scripts/menus/main_menu.sh

72 lines
2.2 KiB
Bash
Raw Normal View History

2025-01-29 15:11:44 +01:00
#!/bin/bash
2025-01-29 20:09:22 +01:00
# ==========================================================
# ProxMenu - A menu-driven script for Proxmox VE management
# ==========================================================
# Author : MacRimi
# Copyright : (c) 2024 MacRimi
# License : MIT (https://raw.githubusercontent.com/MacRimi/ProxMenux/main/LICENSE)
# Version : 1.0
# Last Updated: 28/01/2025
# ==========================================================
# Configuration
2025-01-29 20:52:28 +01:00
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
2025-01-29 20:09:22 +01:00
UTILS_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/utils.sh"
BASE_DIR="/usr/local/share/proxmenux"
CACHE_FILE="$BASE_DIR/cache.json"
VENV_PATH="/opt/googletrans-env"
LANGUAGE=$(jq -r '.language // "en"' "$BASE_DIR/config.json" 2>/dev/null)
# Try to load utils.sh from GitHub
if ! source <(curl -sSf "$UTILS_URL"); then
echo "$(translate 'Error: Could not load utils.sh from') $UTILS_URL"
exit 1
fi
2025-01-29 22:17:21 +01:00
# Initialize cache
initialize_cache() {
if [ ! -f "$CACHE_FILE" ]; then
echo "{}" > "$CACHE_FILE"
return
fi
}
2025-01-29 22:45:30 +01:00
# Load language from JSON file
2025-01-29 22:43:49 +01:00
load_language() {
if [ -f "$CONFIG_FILE" ]; then
LANGUAGE=$(jq -r '.language' "$CONFIG_FILE")
fi
}
2025-01-29 22:17:21 +01:00
show_menu() {
2025-01-29 20:09:22 +01:00
while true; do
OPTION=$(whiptail --title "$(translate "Main Menu")" --menu "$(translate "Select an option:")" 15 60 5 \
"1" "$(translate "GPUs and Coral-TPU")" \
"2" "$(translate "Hard Drives, Disk Images, and Storage")" \
"3" "$(translate "Network")" \
"4" "$(translate "Settings")" \
"5" "$(translate "Exit")" 3>&1 1>&2 2>&3)
2025-01-29 15:11:44 +01:00
case $OPTION in
2025-01-29 23:25:35 +01:00
1) exec bash <(curl -s "$REPO_URL/scripts/igpu_tpu.sh") ;;
2025-01-29 21:45:21 +01:00
2) exec bash <(curl -s "$REPO_URL/scripts/menus/storage_menu.sh") ;;
3) exec bash <(curl -s "$REPO_URL/scripts/menus/network_menu") ;;
4) exec bash <(curl -s "$REPO_URL/scripts/menus/config_menu.sh") ;;
2025-01-29 20:13:28 +01:00
5) clear; msg_ok "$(translate "Thank you for using ProxMenu. Goodbye!")"; exit 0 ;;
2025-01-29 15:11:44 +01:00
*) msg_error "Opción inválida"; sleep 2 ;;
esac
2025-01-29 21:04:30 +01:00
2025-01-29 15:11:44 +01:00
done
2025-01-29 22:17:21 +01:00
}
# Main flow
initialize_cache
2025-01-29 22:43:49 +01:00
load_language
2025-01-29 22:17:21 +01:00
show_menu