2024-12-20 18:54:00 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2025-02-02 19:21:58 +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)
|
2025-05-04 23:49:44 +02:00
|
|
|
# Version : 1.2
|
|
|
|
# Last Updated: 04/04/2025
|
2025-02-02 19:21:58 +01:00
|
|
|
# ==========================================================
|
|
|
|
# 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.
|
|
|
|
# ==========================================================
|
|
|
|
|
2025-02-02 19:41:11 +01:00
|
|
|
|
2025-02-02 19:21:58 +01:00
|
|
|
# Configuration ============================================
|
2024-12-20 18:54:00 +01:00
|
|
|
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
|
2025-02-02 19:21:58 +01:00
|
|
|
UTILS_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/utils.sh"
|
2024-12-20 21:44:20 +01:00
|
|
|
INSTALL_DIR="/usr/local/bin"
|
2024-12-20 21:41:34 +01:00
|
|
|
BASE_DIR="/usr/local/share/proxmenux"
|
2025-02-06 17:20:32 +01:00
|
|
|
CONFIG_FILE="$BASE_DIR/config.json"
|
2025-02-02 19:21:58 +01:00
|
|
|
CACHE_FILE="$BASE_DIR/cache.json"
|
2025-02-25 00:04:46 +01:00
|
|
|
UTILS_FILE="$BASE_DIR/utils.sh"
|
2024-12-20 21:41:34 +01:00
|
|
|
LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
|
2025-02-25 17:44:17 +01:00
|
|
|
MENU_SCRIPT="menu"
|
2025-02-06 17:20:32 +01:00
|
|
|
VENV_PATH="/opt/googletrans-env"
|
2024-12-20 21:41:34 +01:00
|
|
|
|
2025-02-25 00:11:48 +01:00
|
|
|
# Source utils.sh for common functions and styles
|
2025-02-25 00:04:46 +01:00
|
|
|
if ! source <(curl -sSf "$UTILS_URL"); then
|
|
|
|
echo "Error: Could not load utils.sh from $UTILS_URL"
|
|
|
|
exit 1
|
|
|
|
fi
|
2025-02-02 19:41:11 +01:00
|
|
|
|
2025-02-02 19:21:58 +01:00
|
|
|
# ==========================================================
|
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
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
|
2025-05-05 11:27:51 +02:00
|
|
|
local tracked_components=("whiptail" "dialog" "curl" "jq" "python3" "python3-venv" "python3-pip" "virtual_environment" "pip" "googletrans")
|
2025-02-06 17:20:32 +01:00
|
|
|
|
|
|
|
# Check if the component is in the list of tracked components
|
|
|
|
if [[ " ${tracked_components[@]} " =~ " ${component} " ]]; then
|
|
|
|
mkdir -p "$(dirname "$CONFIG_FILE")"
|
2024-12-20 18:54:00 +01:00
|
|
|
|
2025-02-03 23:08:37 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
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
|
|
|
|
}
|
2025-02-02 19:21:58 +01:00
|
|
|
|
2025-01-09 21:37:09 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
show_progress() {
|
|
|
|
local step="$1"
|
|
|
|
local total="$2"
|
|
|
|
local message="$3"
|
|
|
|
|
2025-02-06 20:26:20 +01:00
|
|
|
echo -e "\n${BOLD}${BL}${TAB}Installing ProxMenu: Step $step of $total${CL}"
|
2025-02-25 00:19:37 +01:00
|
|
|
echo
|
2025-02-25 00:55:42 +01:00
|
|
|
msg_info2 "$message"
|
2025-02-06 17:20:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# # 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
|
|
|
|
|
|
|
|
|
2025-05-04 23:49:44 +02:00
|
|
|
DEPS=("whiptail" "dialog" "curl" "python3" "python3-venv" "python3-pip")
|
2025-02-06 17:20:32 +01:00
|
|
|
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++))
|
|
|
|
|
2025-05-07 19:14:26 +02:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
# 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
|
2025-02-03 23:08:37 +01:00
|
|
|
else
|
2025-02-06 17:20:32 +01:00
|
|
|
msg_ok "Virtual environment created successfully."
|
|
|
|
update_config "virtual_environment" "created"
|
2025-02-03 23:08:37 +01:00
|
|
|
fi
|
2025-02-02 19:21:58 +01:00
|
|
|
else
|
2025-02-06 17:20:32 +01:00
|
|
|
msg_ok "Virtual environment already exists."
|
|
|
|
update_config "virtual_environment" "already_exists"
|
2025-02-02 19:21:58 +01:00
|
|
|
fi
|
2025-02-06 17:20:32 +01:00
|
|
|
source "$VENV_PATH/bin/activate"
|
|
|
|
((current_step++))
|
2025-02-02 19:21:58 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
# Step 3: Install and upgrade pip and googletrans
|
2025-01-12 17:08:33 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
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
|
2025-02-02 19:21:58 +01:00
|
|
|
fi
|
2025-02-03 23:31:15 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
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"
|
2025-02-03 23:20:42 +01:00
|
|
|
deactivate
|
2025-02-06 17:20:32 +01:00
|
|
|
return 1
|
2025-02-03 23:20:42 +01:00
|
|
|
fi
|
|
|
|
deactivate
|
2025-02-06 17:20:32 +01:00
|
|
|
((current_step++))
|
|
|
|
|
|
|
|
# Step 4: Download necessary files
|
|
|
|
|
|
|
|
show_progress $current_step $total_steps "Downloading necessary files"
|
|
|
|
mkdir -p "$BASE_DIR"
|
2025-05-09 12:18:14 +02:00
|
|
|
mkdir -p "$INSTALL_DIR"
|
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
FILES=(
|
2025-02-06 17:25:40 +01:00
|
|
|
"$CACHE_FILE $REPO_URL/json/cache.json"
|
2025-02-06 17:20:32 +01:00
|
|
|
"$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##*/}..."
|
2025-05-07 19:14:26 +02:00
|
|
|
sleep 2
|
2025-02-06 17:20:32 +01:00
|
|
|
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++))
|
2025-02-02 19:21:58 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
# Final setup
|
2025-02-02 19:21:58 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
|
2024-12-20 18:54:00 +01:00
|
|
|
|
2024-12-20 21:41:34 +01:00
|
|
|
|
2025-02-02 19:21:58 +01:00
|
|
|
|
2025-02-03 23:08:37 +01:00
|
|
|
# Installation complete ====================================
|
2025-02-02 19:21:58 +01:00
|
|
|
echo
|
2025-02-25 19:20:20 +01:00
|
|
|
#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"
|
2025-02-02 19:21:58 +01:00
|
|
|
echo
|
|
|
|
echo -ne "${GN}"
|
2025-05-12 17:17:45 +02:00
|
|
|
type_text "To run ProxMenux, simply execute this command in the console or terminal:"
|
2025-02-25 17:44:17 +01:00
|
|
|
echo -e "${YWB} menu${CL}"
|
2025-02-02 19:21:58 +01:00
|
|
|
echo
|
|
|
|
|
2024-12-20 18:54:00 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
}
|
2025-02-03 23:08:37 +01:00
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
# Main execution ==========================================
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
|
|
msg_error "This script must be run as root."
|
|
|
|
exit 1
|
2025-02-03 23:08:37 +01:00
|
|
|
fi
|
|
|
|
|
2025-02-06 17:20:32 +01:00
|
|
|
clear
|
2025-02-25 01:46:55 +01:00
|
|
|
show_proxmenux_logo
|
2025-02-06 17:20:32 +01:00
|
|
|
|
2025-02-25 01:52:56 +01:00
|
|
|
echo
|
2025-05-12 17:17:45 +02:00
|
|
|
echo -e "${BOLD}${YW}To function correctly, ProxMenux needs to install the following components:${CL}"
|
2025-02-06 17:20:32 +01:00
|
|
|
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"
|
2025-05-12 17:17:45 +02:00
|
|
|
echo -e "${TAB}- ProxMenux scripts and configuration files"
|
2025-02-06 17:20:32 +01:00
|
|
|
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
|