Update install Proxmenux

This commit is contained in:
MacRimi 2025-07-04 22:37:16 +02:00
parent 5a91810e9a
commit 230847dace
3 changed files with 33 additions and 456 deletions

View File

@ -45,21 +45,16 @@ LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
MENU_SCRIPT="menu" MENU_SCRIPT="menu"
VENV_PATH="/opt/googletrans-env" VENV_PATH="/opt/googletrans-env"
if ! source <(curl -sSf "$UTILS_URL"); then if ! source <(curl -sSf "$UTILS_URL"); then
echo "Error: Could not load utils.sh from $UTILS_URL" echo "Error: Could not load utils.sh from $UTILS_URL"
exit 1 exit 1
fi fi
cleanup_corrupted_files() { cleanup_corrupted_files() {
if [ -f "$CONFIG_FILE" ] && ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then if [ -f "$CONFIG_FILE" ] && ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then
echo "Cleaning up corrupted configuration file..." echo "Cleaning up corrupted configuration file..."
rm -f "$CONFIG_FILE" rm -f "$CONFIG_FILE"
fi fi
if [ -f "$CACHE_FILE" ] && ! jq empty "$CACHE_FILE" >/dev/null 2>&1; then if [ -f "$CACHE_FILE" ] && ! jq empty "$CACHE_FILE" >/dev/null 2>&1; then
echo "Cleaning up corrupted cache file..." echo "Cleaning up corrupted cache file..."
rm -f "$CACHE_FILE" rm -f "$CACHE_FILE"
@ -67,26 +62,21 @@ cleanup_corrupted_files() {
} }
# ========================================================== # ==========================================================
check_existing_installation() { check_existing_installation() {
local has_venv=false local has_venv=false
local has_config=false local has_config=false
local has_language=false local has_language=false
local has_menu=false local has_menu=false
if [ -f "$INSTALL_DIR/$MENU_SCRIPT" ]; then if [ -f "$INSTALL_DIR/$MENU_SCRIPT" ]; then
has_menu=true has_menu=true
fi fi
if [ -d "$VENV_PATH" ] && [ -f "$VENV_PATH/bin/activate" ]; then if [ -d "$VENV_PATH" ] && [ -f "$VENV_PATH/bin/activate" ]; then
has_venv=true has_venv=true
fi fi
if [ -f "$CONFIG_FILE" ]; then if [ -f "$CONFIG_FILE" ]; then
if jq empty "$CONFIG_FILE" >/dev/null 2>&1; then if jq empty "$CONFIG_FILE" >/dev/null 2>&1; then
has_config=true has_config=true
local current_language=$(jq -r '.language // empty' "$CONFIG_FILE" 2>/dev/null) local current_language=$(jq -r '.language // empty' "$CONFIG_FILE" 2>/dev/null)
@ -94,13 +84,11 @@ check_existing_installation() {
has_language=true has_language=true
fi fi
else else
echo "Warning: Corrupted config file detected, removing..." echo "Warning: Corrupted config file detected, removing..."
rm -f "$CONFIG_FILE" rm -f "$CONFIG_FILE"
fi fi
fi fi
if [ "$has_venv" = true ] && [ "$has_language" = true ]; then if [ "$has_venv" = true ] && [ "$has_language" = true ]; then
echo "translation" echo "translation"
elif [ "$has_menu" = true ] && [ "$has_venv" = false ]; then elif [ "$has_menu" = true ] && [ "$has_venv" = false ]; then
@ -112,7 +100,6 @@ check_existing_installation() {
fi fi
} }
uninstall_proxmenu() { uninstall_proxmenu() {
local install_type="$1" local install_type="$1"
local force_clean="$2" local force_clean="$2"
@ -125,7 +112,6 @@ uninstall_proxmenu() {
echo "Uninstalling ProxMenu..." echo "Uninstalling ProxMenu..."
if [ -f "$VENV_PATH/bin/activate" ]; then if [ -f "$VENV_PATH/bin/activate" ]; then
echo "Removing googletrans and virtual environment..." echo "Removing googletrans and virtual environment..."
source "$VENV_PATH/bin/activate" source "$VENV_PATH/bin/activate"
@ -134,7 +120,6 @@ uninstall_proxmenu() {
rm -rf "$VENV_PATH" rm -rf "$VENV_PATH"
fi fi
if [ "$install_type" = "translation" ] && [ "$force_clean" != "force" ]; then if [ "$install_type" = "translation" ] && [ "$force_clean" != "force" ]; then
DEPS_TO_REMOVE=$(whiptail --title "Remove Translation Dependencies" --checklist \ DEPS_TO_REMOVE=$(whiptail --title "Remove Translation Dependencies" --checklist \
"Select translation-specific dependencies to remove:" 15 60 3 \ "Select translation-specific dependencies to remove:" 15 60 3 \
@ -155,11 +140,9 @@ uninstall_proxmenu() {
fi fi
fi fi
rm -f "$INSTALL_DIR/$MENU_SCRIPT" rm -f "$INSTALL_DIR/$MENU_SCRIPT"
rm -rf "$BASE_DIR" rm -rf "$BASE_DIR"
[ -f /root/.bashrc.bak ] && mv /root/.bashrc.bak /root/.bashrc [ -f /root/.bashrc.bak ] && mv /root/.bashrc.bak /root/.bashrc
if [ -f /etc/motd.bak ]; then if [ -f /etc/motd.bak ]; then
mv /etc/motd.bak /etc/motd mv /etc/motd.bak /etc/motd
@ -171,7 +154,6 @@ uninstall_proxmenu() {
return 0 return 0
} }
handle_installation_change() { handle_installation_change() {
local current_type="$1" local current_type="$1"
local new_type="$2" local new_type="$2"
@ -210,31 +192,25 @@ update_config() {
local status="$2" local status="$2"
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
local tracked_components=("dialog" "curl" "jq" "python3" "python3-venv" "python3-pip" "virtual_environment" "pip" "googletrans") local tracked_components=("dialog" "curl" "jq" "python3" "python3-venv" "python3-pip" "virtual_environment" "pip" "googletrans")
if [[ " ${tracked_components[@]} " =~ " ${component} " ]]; then if [[ " ${tracked_components[@]} " =~ " ${component} " ]]; then
mkdir -p "$(dirname "$CONFIG_FILE")" mkdir -p "$(dirname "$CONFIG_FILE")"
if [ ! -f "$CONFIG_FILE" ] || ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then if [ ! -f "$CONFIG_FILE" ] || ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then
echo '{}' > "$CONFIG_FILE" echo '{}' > "$CONFIG_FILE"
fi fi
local tmp_file=$(mktemp) local tmp_file=$(mktemp)
if jq --arg comp "$component" --arg stat "$status" --arg time "$timestamp" \ if jq --arg comp "$component" --arg stat "$status" --arg time "$timestamp" \
'.[$comp] = {status: $stat, timestamp: $time}' "$CONFIG_FILE" > "$tmp_file" 2>/dev/null; then '.[$comp] = {status: $stat, timestamp: $time}' "$CONFIG_FILE" > "$tmp_file" 2>/dev/null; then
mv "$tmp_file" "$CONFIG_FILE" mv "$tmp_file" "$CONFIG_FILE"
else else
echo '{}' > "$CONFIG_FILE" echo '{}' > "$CONFIG_FILE"
jq --arg comp "$component" --arg stat "$status" --arg time "$timestamp" \ jq --arg comp "$component" --arg stat "$status" --arg time "$timestamp" \
'.[$comp] = {status: $stat, timestamp: $time}' "$CONFIG_FILE" > "$tmp_file" && mv "$tmp_file" "$CONFIG_FILE" '.[$comp] = {status: $stat, timestamp: $time}' "$CONFIG_FILE" > "$tmp_file" && mv "$tmp_file" "$CONFIG_FILE"
fi fi
[ -f "$tmp_file" ] && rm -f "$tmp_file" [ -f "$tmp_file" ] && rm -f "$tmp_file"
fi fi
} }
@ -249,9 +225,7 @@ show_progress() {
msg_info2 "$message" msg_info2 "$message"
} }
select_language() { select_language() {
if [ -f "$CONFIG_FILE" ] && jq empty "$CONFIG_FILE" >/dev/null 2>&1; then if [ -f "$CONFIG_FILE" ] && jq empty "$CONFIG_FILE" >/dev/null 2>&1; then
local existing_language=$(jq -r '.language // empty' "$CONFIG_FILE" 2>/dev/null) local existing_language=$(jq -r '.language // empty' "$CONFIG_FILE" 2>/dev/null)
if [[ -n "$existing_language" && "$existing_language" != "null" && "$existing_language" != "empty" ]]; then if [[ -n "$existing_language" && "$existing_language" != "null" && "$existing_language" != "empty" ]]; then
@ -261,7 +235,6 @@ select_language() {
fi fi
fi fi
LANGUAGE=$(whiptail --title "Select Language" --menu "Choose a language for the menu:" 20 60 12 \ LANGUAGE=$(whiptail --title "Select Language" --menu "Choose a language for the menu:" 20 60 12 \
"en" "English (Recommended)" \ "en" "English (Recommended)" \
"es" "Spanish" \ "es" "Spanish" \
@ -275,40 +248,55 @@ select_language() {
exit 1 exit 1
fi fi
mkdir -p "$(dirname "$CONFIG_FILE")" mkdir -p "$(dirname "$CONFIG_FILE")"
if [ ! -f "$CONFIG_FILE" ] || ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then if [ ! -f "$CONFIG_FILE" ] || ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then
echo '{}' > "$CONFIG_FILE" echo '{}' > "$CONFIG_FILE"
fi fi
local tmp_file=$(mktemp) local tmp_file=$(mktemp)
if jq --arg lang "$LANGUAGE" '. + {language: $lang}' "$CONFIG_FILE" > "$tmp_file" 2>/dev/null; then if jq --arg lang "$LANGUAGE" '. + {language: $lang}' "$CONFIG_FILE" > "$tmp_file" 2>/dev/null; then
mv "$tmp_file" "$CONFIG_FILE" mv "$tmp_file" "$CONFIG_FILE"
else else
echo "{\"language\": \"$LANGUAGE\"}" > "$CONFIG_FILE" echo "{\"language\": \"$LANGUAGE\"}" > "$CONFIG_FILE"
fi fi
[ -f "$tmp_file" ] && rm -f "$tmp_file" [ -f "$tmp_file" ] && rm -f "$tmp_file"
msg_ok "Language set to: $LANGUAGE" msg_ok "Language set to: $LANGUAGE"
} }
#################################################### # Show installation confirmation for new installations
show_installation_confirmation() {
local install_type="$1"
case "$install_type" in
"1")
if whiptail --title "ProxMenux - Normal Version Installation" \
--yesno "ProxMenux Normal Version will install:\n\n• dialog (interactive menus) - Official Debian package\n• curl (file downloads) - Official Debian package\n• jq (JSON processing) - Official Debian package\n• ProxMenux core files (/usr/local/share/proxmenux)\n\nThis is a lightweight installation with minimal dependencies.\n\nProceed with installation?" 18 70; then
return 0
else
return 1
fi
;;
"2")
if whiptail --title "ProxMenux - Translation Version Installation" \
--yesno "ProxMenux Translation Version will install:\n\n• dialog (interactive menus)\n• curl (file downloads)\n• jq (JSON processing)\n• python3 + python3-venv + python3-pip\n• Google Translate library (googletrans)\n• Virtual environment (/opt/googletrans-env)\n• Translation cache system\n• ProxMenux core files\n\nThis version requires more dependencies for translation support.\n\nProceed with installation?" 18 70; then
return 0
else
return 1
fi
;;
esac
}
####################################################
install_normal_version() { install_normal_version() {
local total_steps=3 local total_steps=3
local current_step=1 local current_step=1
show_progress $current_step $total_steps "Installing basic dependencies" show_progress $current_step $total_steps "Installing basic dependencies"
if ! dpkg -l | grep -qw "jq"; then if ! dpkg -l | grep -qw "jq"; then
msg_info "Installing jq..." msg_info "Installing jq..."
apt-get update > /dev/null 2>&1 apt-get update > /dev/null 2>&1
@ -325,7 +313,6 @@ install_normal_version() {
update_config "jq" "already_installed" update_config "jq" "already_installed"
fi fi
BASIC_DEPS=("dialog" "curl") BASIC_DEPS=("dialog" "curl")
for pkg in "${BASIC_DEPS[@]}"; do for pkg in "${BASIC_DEPS[@]}"; do
if ! dpkg -l | grep -qw "$pkg"; then if ! dpkg -l | grep -qw "$pkg"; then
@ -346,13 +333,11 @@ install_normal_version() {
((current_step++)) ((current_step++))
show_progress $current_step $total_steps "Creating directories and configuration" show_progress $current_step $total_steps "Creating directories and configuration"
mkdir -p "$BASE_DIR" mkdir -p "$BASE_DIR"
mkdir -p "$INSTALL_DIR" mkdir -p "$INSTALL_DIR"
if [ ! -f "$CONFIG_FILE" ]; then if [ ! -f "$CONFIG_FILE" ]; then
echo '{}' > "$CONFIG_FILE" echo '{}' > "$CONFIG_FILE"
fi fi
@ -360,7 +345,6 @@ install_normal_version() {
msg_ok "Directories and configuration created." msg_ok "Directories and configuration created."
((current_step++)) ((current_step++))
show_progress $current_step $total_steps "Downloading necessary files" show_progress $current_step $total_steps "Downloading necessary files"
FILES=( FILES=(
@ -382,22 +366,17 @@ install_normal_version() {
done done
chmod +x "$INSTALL_DIR/$MENU_SCRIPT" chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
} }
#################################################### ####################################################
install_translation_version() { install_translation_version() {
local total_steps=4 local total_steps=4
local current_step=1 local current_step=1
show_progress $current_step $total_steps "Language selection" show_progress $current_step $total_steps "Language selection"
select_language select_language
((current_step++)) ((current_step++))
show_progress $current_step $total_steps "Installing system dependencies" show_progress $current_step $total_steps "Installing system dependencies"
if ! dpkg -l | grep -qw "jq"; then if ! dpkg -l | grep -qw "jq"; then
@ -436,7 +415,6 @@ install_translation_version() {
((current_step++)) ((current_step++))
show_progress $current_step $total_steps "Setting up translation environment" show_progress $current_step $total_steps "Setting up translation environment"
if [ ! -d "$VENV_PATH" ] || [ ! -f "$VENV_PATH/bin/activate" ]; then if [ ! -d "$VENV_PATH" ] || [ ! -f "$VENV_PATH/bin/activate" ]; then
@ -481,7 +459,6 @@ install_translation_version() {
deactivate deactivate
((current_step++)) ((current_step++))
show_progress $current_step $total_steps "Downloading necessary files" show_progress $current_step $total_steps "Downloading necessary files"
mkdir -p "$BASE_DIR" mkdir -p "$BASE_DIR"
@ -500,7 +477,6 @@ install_translation_version() {
sleep 2 sleep 2
if wget -qO "$dest" "$url"; then if wget -qO "$dest" "$url"; then
msg_ok "${dest##*/} downloaded successfully." msg_ok "${dest##*/} downloaded successfully."
if [[ "$dest" == "$CACHE_FILE" ]]; then if [[ "$dest" == "$CACHE_FILE" ]]; then
msg_ok "Cache file updated with latest translations." msg_ok "Cache file updated with latest translations."
fi fi
@ -511,12 +487,9 @@ install_translation_version() {
done done
chmod +x "$INSTALL_DIR/$MENU_SCRIPT" chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
} }
#################################################### ####################################################
show_installation_options() { show_installation_options() {
local current_install_type local current_install_type
current_install_type=$(check_existing_installation) current_install_type=$(check_existing_installation)
@ -524,7 +497,6 @@ show_installation_options() {
local menu_title="ProxMenux Installation" local menu_title="ProxMenux Installation"
local menu_text="Choose installation type:" local menu_text="Choose installation type:"
if [ "$current_install_type" != "none" ]; then if [ "$current_install_type" != "none" ]; then
case "$current_install_type" in case "$current_install_type" in
"translation") "translation")
@ -548,6 +520,13 @@ show_installation_options() {
exit 1 exit 1
fi fi
# For new installations, show confirmation with details
if [ "$current_install_type" = "none" ]; then
if ! show_installation_confirmation "$INSTALL_TYPE"; then
msg_warn "Installation cancelled."
exit 1
fi
fi
if ! handle_installation_change "$current_install_type" "$INSTALL_TYPE"; then if ! handle_installation_change "$current_install_type" "$INSTALL_TYPE"; then
msg_warn "Installation cancelled." msg_warn "Installation cancelled."
@ -555,7 +534,6 @@ show_installation_options() {
fi fi
} }
install_proxmenu() { install_proxmenu() {
show_installation_options show_installation_options
@ -576,7 +554,6 @@ install_proxmenu() {
;; ;;
esac esac
msg_title "ProxMenux has been installed successfully" msg_title "ProxMenux has been installed successfully"
echo -ne "${GN}" echo -ne "${GN}"
type_text "To run ProxMenux, simply execute this command in the console or terminal:" type_text "To run ProxMenux, simply execute this command in the console or terminal:"
@ -584,13 +561,10 @@ install_proxmenu() {
echo echo
} }
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
msg_error "This script must be run as root." msg_error "This script must be run as root."
exit 1 exit 1
fi fi
cleanup_corrupted_files cleanup_corrupted_files
install_proxmenu install_proxmenu

View File

@ -1,261 +0,0 @@
#!/bin/bash
# ==========================================================
# 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.2
# Last Updated: 04/04/2025
# ==========================================================
# Description:
# This script installs and configures ProxMenux, a menu-driven
# tool for managing Proxmox VE.
#
# - Ensures the script is run with root privileges.
# - Displays an installation confirmation prompt.
# - Installs required dependencies:
# - whiptail (for interactive terminal menus)
# - curl (for downloading remote files)
# - jq (for handling JSON data)
# - Python 3 and virtual environment (for translations)
# - Configures the Python virtual environment and installs googletrans.
# - Creates necessary directories for storing ProxMenux data.
# - Downloads required files from GitHub, including:
# - Cache file (`cache.json`) for translation caching.
# - Utility script (`utils.sh`) for core functions.
# - Main script (`menu.sh`) to launch ProxMenux.
# - Sets correct permissions for execution.
# - Displays final instructions on how to start ProxMenux.
#
# This installer ensures a smooth setup process and prepares
# the system for running ProxMenux efficiently.
# ==========================================================
# Configuration ============================================
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
UTILS_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/utils.sh"
INSTALL_DIR="/usr/local/bin"
BASE_DIR="/usr/local/share/proxmenux"
CONFIG_FILE="$BASE_DIR/config.json"
CACHE_FILE="$BASE_DIR/cache.json"
UTILS_FILE="$BASE_DIR/utils.sh"
LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
MENU_SCRIPT="menu"
VENV_PATH="/opt/googletrans-env"
# Source utils.sh for common functions and styles
if ! source <(curl -sSf "$UTILS_URL"); then
echo "Error: Could not load utils.sh from $UTILS_URL"
exit 1
fi
# ==========================================================
update_config() {
local component="$1"
local status="$2"
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# List of components we want to track
local tracked_components=("whiptail" "dialog" "curl" "jq" "python3" "python3-venv" "python3-pip" "virtual_environment" "pip" "googletrans")
# Check if the component is in the list of tracked components
if [[ " ${tracked_components[@]} " =~ " ${component} " ]]; then
mkdir -p "$(dirname "$CONFIG_FILE")"
if [ ! -f "$CONFIG_FILE" ]; then
echo '{}' > "$CONFIG_FILE"
fi
tmp=$(mktemp)
jq --arg comp "$component" --arg stat "$status" --arg time "$timestamp" \
'.[$comp] = {status: $stat, timestamp: $time}' "$CONFIG_FILE" > "$tmp" && mv "$tmp" "$CONFIG_FILE"
fi
}
show_progress() {
local step="$1"
local total="$2"
local message="$3"
echo -e "\n${BOLD}${BL}${TAB}Installing ProxMenu: Step $step of $total${CL}"
echo
msg_info2 "$message"
}
# # Main installation function =============================
install_proxmenu() {
local total_steps=4
local current_step=1
# Step 1: Check and install system dependencies
show_progress $current_step $total_steps "Checking system dependencies"
if ! dpkg -l | grep -qw "jq"; then
msg_info "Installing jq..."
apt-get update > /dev/null 2>&1
if apt-get install -y jq > /dev/null 2>&1; then
msg_ok "jq installed successfully."
update_config "jq" "installed"
else
msg_error "Failed to install jq. Please install it manually."
update_config "jq" "failed"
return 1
fi
else
msg_ok "jq is already installed."
update_config "jq" "already_installed"
fi
DEPS=("whiptail" "dialog" "curl" "python3" "python3-venv" "python3-pip")
for pkg in "${DEPS[@]}"; do
if ! dpkg -l | grep -qw "$pkg"; then
msg_info "Installing $pkg..."
if apt-get install -y "$pkg" > /dev/null 2>&1; then
msg_ok "$pkg installed successfully."
update_config "$pkg" "installed"
else
msg_error "Failed to install $pkg. Please install it manually."
update_config "$pkg" "failed"
return 1
fi
else
msg_ok "$pkg is already installed."
update_config "$pkg" "already_installed"
fi
done
((current_step++))
# Step 2: Set up virtual environment
show_progress $current_step $total_steps "Setting up virtual environment for translate"
if [ ! -d "$VENV_PATH" ] || [ ! -f "$VENV_PATH/bin/activate" ]; then
msg_info "Creating the virtual environment..."
python3 -m venv --system-site-packages "$VENV_PATH" > /dev/null 2>&1
if [ ! -f "$VENV_PATH/bin/activate" ]; then
msg_error "Failed to create virtual environment. Please check your Python installation."
update_config "virtual_environment" "failed"
return 1
else
msg_ok "Virtual environment created successfully."
update_config "virtual_environment" "created"
fi
else
msg_ok "Virtual environment already exists."
update_config "virtual_environment" "already_exists"
fi
source "$VENV_PATH/bin/activate"
((current_step++))
# Step 3: Install and upgrade pip and googletrans
show_progress $current_step $total_steps "Installing and upgrading pip and googletrans"
msg_info "Upgrading pip..."
if pip install --upgrade pip > /dev/null 2>&1; then
msg_ok "Pip upgraded successfully."
update_config "pip" "upgraded"
else
msg_error "Failed to upgrade pip."
update_config "pip" "upgrade_failed"
return 1
fi
msg_info "Installing googletrans..."
if pip install --break-system-packages --no-cache-dir googletrans==4.0.0-rc1 > /dev/null 2>&1; then
msg_ok "Googletrans installed successfully."
update_config "googletrans" "installed"
else
msg_error "Failed to install googletrans. Please check your internet connection."
update_config "googletrans" "failed"
deactivate
return 1
fi
deactivate
((current_step++))
# Step 4: Download necessary files
show_progress $current_step $total_steps "Downloading necessary files"
mkdir -p "$BASE_DIR"
mkdir -p "$INSTALL_DIR"
FILES=(
"$CACHE_FILE $REPO_URL/json/cache.json"
"$UTILS_FILE $REPO_URL/scripts/utils.sh"
"$INSTALL_DIR/$MENU_SCRIPT $REPO_URL/$MENU_SCRIPT"
"$LOCAL_VERSION_FILE $REPO_URL/version.txt"
)
for file in "${FILES[@]}"; do
IFS=" " read -r dest url <<< "$file"
msg_info "Downloading ${dest##*/}..."
sleep 2
if wget -qO "$dest" "$url"; then
msg_ok "${dest##*/} downloaded successfully."
else
msg_error "Failed to download ${dest##*/}. Check your Internet connection."
return 1
fi
done
((current_step++))
# Final setup
chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
# Installation complete ====================================
echo
#echo -e "${YW}╭─────────────────────────────────────────────────────╮${CL}"
#echo -e "${YW}│${CL} ${GN}🌟 ProxMenux has been installed successfull 🌟 ${CL} ${YW}│${CL}"
#echo -e "${YW}╰─────────────────────────────────────────────────────╯${CL}"
msg_title "ProxMenux has been installed successfull"
echo
echo -ne "${GN}"
type_text "To run ProxMenux, simply execute this command in the console or terminal:"
echo -e "${YWB} menu${CL}"
echo
}
# Main execution ==========================================
if [ "$(id -u)" -ne 0 ]; then
msg_error "This script must be run as root."
exit 1
fi
clear
show_proxmenux_logo
echo
echo -e "${BOLD}${YW}To function correctly, ProxMenux needs to install the following components:${CL}"
echo -e "${TAB}- whiptail (if not already installed)"
echo -e "${TAB}- curl (if not already installed)"
echo -e "${TAB}- jq (if not already installed)"
echo -e "${TAB}- Python 3 (if not already installed)"
echo -e "${TAB}- Virtual environment for Google Translate"
echo -e "${TAB}- ProxMenux scripts and configuration files"
echo
read -p "Do you want to proceed with the installation? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
install_proxmenu
else
msg_warn "Installation cancelled."
exit 1
fi

136
menu_
View File

@ -1,136 +0,0 @@
#!/bin/bash
# ==========================================================
# 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
# ==========================================================
# Description:
# This script serves as the main entry point for ProxMenux,
# a menu-driven tool designed for Proxmox VE management.
#
# - Displays the ProxMenu logo on startup.
# - Loads necessary configurations and language settings.
# - Checks for available updates and installs them if confirmed.
# - Downloads and executes the latest main menu script.
#
# Key Features:
# - Ensures ProxMenu is always up-to-date by fetching the latest version.
# - Uses whiptail for interactive menus and language selection.
# - Loads utility functions and translation support.
# - Maintains a cache system to improve performance.
# - Executes the ProxMenux main menu dynamically from the repository.
#
# This script ensures a streamlined and automated experience
# for managing Proxmox VE using ProxMenux.
# ==========================================================
# Configuration ============================================
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
BASE_DIR="/usr/local/share/proxmenux"
CONFIG_FILE="$BASE_DIR/config.json"
CACHE_FILE="$BASE_DIR/cache.json"
UTILS_FILE="$BASE_DIR/utils.sh"
LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
VENV_PATH="/opt/googletrans-env"
if [[ -f "$UTILS_FILE" ]]; then
source "$UTILS_FILE"
fi
# ==========================================================
#show_proxmenux_logo
# Initialize language configuration
initialize_config() {
# Check if config file exists and has language field
if [ ! -f "$CONFIG_FILE" ] || [ -z "$(jq -r '.language // empty' "$CONFIG_FILE")" ]; then
show_proxmenux_logo
sleep 2
LANGUAGE=$(whiptail --title "$(translate "Select Language")" --menu "$(translate "Choose a language for the menu:")" 20 60 12 \
"en" "$(translate "English (Recommended)")" \
"es" "$(translate "Spanish")" \
"fr" "$(translate "French")" \
"de" "$(translate "German")" \
"it" "$(translate "Italian")" \
"pt" "$(translate "Portuguese")" 3>&1 1>&2 2>&3)
if [ -z "$LANGUAGE" ]; then
msg_error "$(translate "No language selected. Exiting.")"
exit 1
fi
if [ -f "$CONFIG_FILE" ]; then
# Update existing config file with new language
tmp=$(mktemp)
jq --arg lang "$LANGUAGE" '. + {language: $lang}' "$CONFIG_FILE" > "$tmp" && mv "$tmp" "$CONFIG_FILE"
else
# Create new config file if it doesn't exist
echo "{\"language\": \"$LANGUAGE\"}" > "$CONFIG_FILE"
fi
msg_ok "$(translate "Initial language set to:") $LANGUAGE"
fi
}
check_updates() {
local INSTALL_SCRIPT="$BASE_DIR/install_proxmenux.sh"
# Fetch the remote version
local REMOTE_VERSION
REMOTE_VERSION=$(curl -fsSL "$REPO_URL/version.txt" | head -n 1)
# Exit silently if unable to fetch the remote version
if [ -z "$REMOTE_VERSION" ]; then
return 0
fi
# Read the local version
local LOCAL_VERSION
LOCAL_VERSION=$(head -n 1 "$LOCAL_VERSION_FILE")
# If the local version matches the remote version, no update is needed
[ "$LOCAL_VERSION" = "$REMOTE_VERSION" ] && return 0
# Prompt the user for update confirmation
if whiptail --title "$(translate "Update Available")" \
--yesno "$(translate "New version available") ($REMOTE_VERSION)\n\n$(translate "Do you want to update now?")" \
10 60 --defaultno; then
msg_warn "$(translate "Starting ProxMenu update...")"
# Download the installation script
if wget -qO "$INSTALL_SCRIPT" "$REPO_URL/install_proxmenux.sh"; then
chmod +x "$INSTALL_SCRIPT"
# Execute the script directly in the current environment
source "$INSTALL_SCRIPT"
fi
else
msg_warn "$(translate "Update postponed. You can update later from the menu.")"
fi
}
main_menu() {
exec bash <(curl -fsSL "$REPO_URL/scripts/menus/main_menu.sh")
}
# Main flow
initialize_config
load_language
initialize_cache
check_updates
main_menu