ProxMenux/install_proxmenux.sh

216 lines
6.9 KiB
Bash
Raw Normal View History

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)
# Version : 1.0
# Last Updated: 28/01/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.
# ==========================================================
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-02 19:21:58 +01:00
CACHE_FILE="$BASE_DIR/cache.json"
UTILS_FILE="$BASE_DIR/utils.sh"
2024-12-20 21:41:34 +01:00
LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
2024-12-20 21:44:20 +01:00
MENU_SCRIPT="menu.sh"
2024-12-20 21:41:34 +01:00
2025-01-09 21:37:09 +01:00
2025-02-02 19:21:58 +01:00
# 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-02-02 19:41:11 +01:00
2025-02-02 19:21:58 +01:00
# ==========================================================
# Verify that it's run as root
2024-12-20 21:44:20 +01:00
if [ "$(id -u)" -ne 0 ]; then
2025-02-02 19:21:58 +01:00
msg_error "This script must be run as root."
exit 1
fi
2025-02-02 19:41:11 +01:00
2025-02-02 19:21:58 +01:00
show_proxmenu_logo
2025-02-02 19:41:11 +01:00
2025-02-02 19:52:10 +01:00
# Display installation confirmation
echo -e "${YW}To function correctly, ProxMenu needs to install the following components:${CL}"
2025-02-02 19:21:58 +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"
echo -e "${TAB}- ProxMenu scripts and configuration files"
echo
2025-02-02 19:52:10 +01:00
read -p "Do you want to proceed with the installation? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
msg_warn "Installation cancelled."
exit 1
fi
2025-02-02 19:41:11 +01:00
2024-12-20 18:54:00 +01:00
2025-02-02 19:21:58 +01:00
# Check system dependencies
msg_info "Checking system dependencies..."
# Install `whiptail`
2025-01-09 21:37:09 +01:00
if ! command -v whiptail &> /dev/null; then
2025-02-02 19:21:58 +01:00
msg_info "Installing whiptail..."
2025-01-09 21:37:09 +01:00
if apt-get update && apt-get install -y whiptail; then
2025-02-02 19:21:58 +01:00
msg_ok "whiptail installed successfully."
2025-01-09 21:37:09 +01:00
else
2025-02-02 19:21:58 +01:00
msg_error "Failed to install whiptail. Please install it manually."
2025-01-09 21:37:09 +01:00
exit 1
fi
2025-02-02 19:21:58 +01:00
else
msg_ok "whiptail is already installed."
2025-01-09 21:37:09 +01:00
fi
2025-02-02 19:21:58 +01:00
# Install `curl`
2025-01-12 17:08:33 +01:00
if ! command -v curl &> /dev/null; then
2025-02-02 19:21:58 +01:00
msg_info "Installing curl..."
2025-01-12 17:08:33 +01:00
if apt-get update && apt-get install -y curl; then
2025-02-02 19:21:58 +01:00
msg_ok "curl installed successfully."
else
msg_error "Failed to install curl. Please install it manually."
exit 1
fi
else
msg_ok "curl is already installed."
fi
# Install `jq`
if ! command -v jq &> /dev/null; then
msg_info "Installing jq..."
if apt-get update && apt-get install -y jq; then
msg_ok "jq installed successfully."
else
msg_error "Failed to install jq. Please install it manually."
exit 1
fi
else
msg_ok "jq is already installed."
fi
# Install Python and virtualenv
if ! command -v python3 &> /dev/null; then
msg_info "Installing Python 3..."
if apt-get update && apt-get install -y python3 python3-venv python3-pip; then
msg_ok "Python 3 installed successfully."
2025-01-12 17:08:33 +01:00
else
2025-02-02 19:21:58 +01:00
msg_error "Failed to install Python 3. Please install it manually."
2025-01-12 17:08:33 +01:00
exit 1
fi
2025-02-02 19:21:58 +01:00
else
msg_ok "Python 3 is already installed."
2025-01-12 17:08:33 +01:00
fi
2025-02-02 19:21:58 +01:00
# Create and configure the virtual environment
msg_info "Setting up the virtual environment for translations..."
if [ ! -d "$VENV_PATH" ]; then
python3 -m venv "$VENV_PATH"
source "$VENV_PATH/bin/activate"
if pip install googletrans==4.0.0-rc1; then
msg_ok "Virtual environment configured and googletrans installed."
else
msg_error "Failed to configure the virtual environment or install googletrans."
deactivate
exit 1
fi
deactivate
else
msg_ok "Virtual environment already configured."
fi
2025-01-12 17:08:33 +01:00
2025-02-02 19:21:58 +01:00
# Create necessary folders
msg_info "Creating necessary directories..."
mkdir -p "$BASE_DIR"
msg_ok "Directories created."
2024-12-20 21:44:20 +01:00
2025-02-02 19:21:58 +01:00
# Download the cache file
msg_info "Downloading the cache file..."
if wget -qO "$CACHE_FILE" "$REPO_URL/lang/cache.json"; then
msg_ok "Cache file downloaded successfully."
else
msg_error "Failed to download the cache file. Check the URL and your Internet connection."
exit 1
fi
# Download utils.sh
msg_info "Downloading utils.sh..."
if wget -qO "$UTILS_FILE" "$REPO_URL/scripts/utils.sh"; then
msg_ok "utils.sh downloaded successfully."
else
msg_error "Failed to download utils.sh. Check the URL and your Internet connection."
exit 1
fi
# Download the main script (menu.sh)
msg_info "Downloading the main script..."
2025-01-09 21:37:09 +01:00
if wget -qO "$INSTALL_DIR/$MENU_SCRIPT" "$REPO_URL/$MENU_SCRIPT"; then
chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
2025-02-02 19:21:58 +01:00
msg_ok "Main script downloaded and made executable."
2025-01-09 21:37:09 +01:00
else
2025-02-02 19:21:58 +01:00
msg_error "Failed to download the main script. Check the URL and your Internet connection."
2024-12-20 21:44:20 +01:00
exit 1
2024-12-20 18:54:00 +01:00
fi
2025-02-02 19:21:58 +01:00
# Download the initial version
msg_info "Downloading version file..."
2025-01-09 21:37:09 +01:00
if wget -qO "$LOCAL_VERSION_FILE" "$REPO_URL/version.txt"; then
2025-02-02 19:21:58 +01:00
msg_ok "Version file downloaded."
2025-01-09 21:37:09 +01:00
else
2025-02-02 19:21:58 +01:00
msg_error "Failed to download the version file."
2024-12-20 21:44:20 +01:00
exit 1
2024-12-20 21:41:34 +01:00
fi
2025-02-02 19:21:58 +01:00
# Confirmation
#msg_ok "ProxMenux has been installed successfully."
#echo -e "${GN} 🌟 Run: menu.sh as root to start the menu.${CL}"
#msg_ok "ProxMenux has been installed successfully."
echo
echo -e "${YW}╭─────────────────────────────────────────────────────╮${CL}"
echo -e "${YW}${CL} ${GN}🌟 ProxMenux has been installed successfull 🌟 ${CL} ${YW}${CL}"
echo -e "${YW}╰─────────────────────────────────────────────────────╯${CL}"
echo
echo -ne "${GN}"
type_text "To run ProxMenu, simply execute this command in the console or terminal:"
echo -e "${YWB} menu.sh${CL}"
echo
2024-12-20 18:54:00 +01:00
2025-02-02 19:21:58 +01:00
# Exit
2024-12-20 21:44:20 +01:00
exit 0