mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-28 04:06:54 +00:00
Update install_proxmenux.sh
This commit is contained in:
parent
c807a5eca1
commit
c9a364f21b
@ -6,8 +6,8 @@
|
|||||||
# Author : MacRimi
|
# Author : MacRimi
|
||||||
# Copyright : (c) 2024 MacRimi
|
# Copyright : (c) 2024 MacRimi
|
||||||
# License : MIT (https://raw.githubusercontent.com/MacRimi/ProxMenux/main/LICENSE)
|
# License : MIT (https://raw.githubusercontent.com/MacRimi/ProxMenux/main/LICENSE)
|
||||||
# Version : 1.0
|
# Version : 1.1
|
||||||
# Last Updated: 28/01/2025
|
# Last Updated: 06/02/2025
|
||||||
# ==========================================================
|
# ==========================================================
|
||||||
# Description:
|
# Description:
|
||||||
# This script installs and configures ProxMenux, a menu-driven
|
# This script installs and configures ProxMenux, a menu-driven
|
||||||
@ -39,120 +39,162 @@ REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
|
|||||||
UTILS_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/utils.sh"
|
UTILS_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/utils.sh"
|
||||||
INSTALL_DIR="/usr/local/bin"
|
INSTALL_DIR="/usr/local/bin"
|
||||||
BASE_DIR="/usr/local/share/proxmenux"
|
BASE_DIR="/usr/local/share/proxmenux"
|
||||||
|
CONFIG_FILE="$BASE_DIR/config.json"
|
||||||
CACHE_FILE="$BASE_DIR/cache.json"
|
CACHE_FILE="$BASE_DIR/cache.json"
|
||||||
UTILS_FILE="$BASE_DIR/utils.sh"
|
UTILS_FILE="$BASE_DIR/utils.sh"
|
||||||
LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
|
LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
|
||||||
MENU_SCRIPT="menu.sh"
|
MENU_SCRIPT="menu.sh"
|
||||||
|
VENV_PATH="/opt/googletrans-env"
|
||||||
|
|
||||||
|
# Source utils.sh for common functions and styles
|
||||||
if ! source <(curl -sSf "$UTILS_URL"); then
|
if ! source <(curl -sSf "$UTILS_URL"); then
|
||||||
echo "$(translate '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
|
||||||
|
|
||||||
# ==========================================================
|
# ==========================================================
|
||||||
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
update_config() {
|
||||||
msg_error "This script must be run as root."
|
local component="$1"
|
||||||
exit 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" "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${YW}${TAB}Installing ProxMenu: Step $step of $total${CL}"
|
||||||
|
msg_info2 "$message"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# # 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
|
fi
|
||||||
|
|
||||||
|
|
||||||
show_proxmenu_logo
|
DEPS=("whiptail" "curl" "python3" "python3-venv" "python3-pip")
|
||||||
|
|
||||||
|
|
||||||
echo -e "${YW}To function correctly, ProxMenu 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}- ProxMenu 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
|
|
||||||
msg_warn "Installation cancelled."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Install dependencies =====================================
|
|
||||||
|
|
||||||
msg_info "Checking system dependencies..."
|
|
||||||
|
|
||||||
|
|
||||||
DEPS=("whiptail" "curl" "jq" "python3" "python3-venv" "python3-pip")
|
|
||||||
for pkg in "${DEPS[@]}"; do
|
for pkg in "${DEPS[@]}"; do
|
||||||
if ! dpkg -l | grep -qw "$pkg"; then
|
if ! dpkg -l | grep -qw "$pkg"; then
|
||||||
msg_info "Installing $pkg..."
|
msg_info "Installing $pkg..."
|
||||||
if apt-get update && apt-get install -y "$pkg"; then
|
if apt-get install -y "$pkg" > /dev/null 2>&1; then
|
||||||
msg_ok "$pkg installed successfully."
|
msg_ok "$pkg installed successfully."
|
||||||
|
update_config "$pkg" "installed"
|
||||||
else
|
else
|
||||||
msg_error "Failed to install $pkg. Please install it manually."
|
msg_error "Failed to install $pkg. Please install it manually."
|
||||||
exit 1
|
update_config "$pkg" "failed"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
msg_ok "$pkg is already installed."
|
msg_ok "$pkg is already installed."
|
||||||
|
update_config "$pkg" "already_installed"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Set up virtual environment ==============================
|
((current_step++))
|
||||||
|
|
||||||
# msg_info "Setting up the virtual environment for translations..."
|
|
||||||
|
|
||||||
|
|
||||||
#mkdir -p /opt
|
|
||||||
#chmod 755 /opt
|
|
||||||
|
|
||||||
|
# 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
|
if [ ! -d "$VENV_PATH" ] || [ ! -f "$VENV_PATH/bin/activate" ]; then
|
||||||
msg_info "Creating the virtual environment..."
|
msg_info "Creating the virtual environment..."
|
||||||
python3 -m venv --system-site-packages "$VENV_PATH"
|
python3 -m venv --system-site-packages "$VENV_PATH" > /dev/null 2>&1
|
||||||
|
|
||||||
|
|
||||||
if [ ! -f "$VENV_PATH/bin/activate" ]; then
|
if [ ! -f "$VENV_PATH/bin/activate" ]; then
|
||||||
msg_error "Failed to create virtual environment. Please check your Python installation."
|
msg_error "Failed to create virtual environment. Please check your Python installation."
|
||||||
exit 1
|
update_config "virtual_environment" "failed"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
msg_ok "Virtual environment created successfully."
|
||||||
|
update_config "virtual_environment" "created"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
msg_ok "Virtual environment already exists."
|
||||||
|
update_config "virtual_environment" "already_exists"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
source "$VENV_PATH/bin/activate"
|
source "$VENV_PATH/bin/activate"
|
||||||
|
((current_step++))
|
||||||
|
|
||||||
|
# Step 3: Install and upgrade pip and googletrans
|
||||||
|
|
||||||
pip install --upgrade pip
|
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; then
|
if pip install --break-system-packages --no-cache-dir googletrans==4.0.0-rc1 > /dev/null 2>&1; then
|
||||||
msg_ok "Virtual environment configured and googletrans installed."
|
msg_ok "Googletrans installed successfully."
|
||||||
|
update_config "googletrans" "installed"
|
||||||
else
|
else
|
||||||
msg_error "Failed to install googletrans. Please check your internet connection."
|
msg_error "Failed to install googletrans. Please check your internet connection."
|
||||||
if [ -n "$VIRTUAL_ENV" ]; then
|
update_config "googletrans" "failed"
|
||||||
deactivate
|
deactivate
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$VIRTUAL_ENV" ]; then
|
|
||||||
deactivate
|
deactivate
|
||||||
fi
|
((current_step++))
|
||||||
|
|
||||||
# Download necessary files =================================
|
# Step 4: Download necessary files
|
||||||
|
|
||||||
msg_ok "Necessary directories created."
|
show_progress $current_step $total_steps "Downloading necessary files"
|
||||||
mkdir -p "$BASE_DIR"
|
mkdir -p "$BASE_DIR"
|
||||||
|
|
||||||
|
|
||||||
FILES=(
|
FILES=(
|
||||||
"$CACHE_FILE $REPO_URL/lang/cache.json"
|
"$CACHE_FILE $REPO_URL/lang/cache.json"
|
||||||
"$UTILS_FILE $REPO_URL/scripts/utils.sh"
|
"$UTILS_FILE $REPO_URL/scripts/utils.sh"
|
||||||
"$INSTALL_DIR/$MENU_SCRIPT $REPO_URL/$MENU_SCRIPT"
|
"$INSTALL_DIR/$MENU_SCRIPT $REPO_URL/$MENU_SCRIPT"
|
||||||
"$LOCAL_VERSION_FILE $REPO_URL/version.txt"
|
"$LOCAL_VERSION_FILE $REPO_URL/version.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
for file in "${FILES[@]}"; do
|
for file in "${FILES[@]}"; do
|
||||||
IFS=" " read -r dest url <<< "$file"
|
IFS=" " read -r dest url <<< "$file"
|
||||||
msg_info "Downloading ${dest##*/}..."
|
msg_info "Downloading ${dest##*/}..."
|
||||||
@ -160,13 +202,17 @@ for file in "${FILES[@]}"; do
|
|||||||
msg_ok "${dest##*/} downloaded successfully."
|
msg_ok "${dest##*/} downloaded successfully."
|
||||||
else
|
else
|
||||||
msg_error "Failed to download ${dest##*/}. Check your Internet connection."
|
msg_error "Failed to download ${dest##*/}. Check your Internet connection."
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
((current_step++))
|
||||||
|
|
||||||
|
# Final setup
|
||||||
|
|
||||||
chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
|
chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Installation complete ====================================
|
# Installation complete ====================================
|
||||||
echo
|
echo
|
||||||
echo -e "${YW}╭─────────────────────────────────────────────────────╮${CL}"
|
echo -e "${YW}╭─────────────────────────────────────────────────────╮${CL}"
|
||||||
@ -179,9 +225,31 @@ echo -e "${YWB} menu.sh${CL}"
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if [ -f "$BASE_DIR/install_proxmenux.sh" ]; then
|
# Main execution ==========================================
|
||||||
rm -f "$BASE_DIR/install_proxmenux.sh"
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
msg_error "This script must be run as root."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
clear
|
||||||
|
show_proxmenu_logo
|
||||||
|
|
||||||
|
echo -e "${YW}To function correctly, ProxMenu 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}- ProxMenu 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user