ProxMenux/scripts/global/remove-banner-pve8.sh

73 lines
2.1 KiB
Bash
Raw Normal View History

2025-08-06 14:23:22 +02:00
#!/bin/bash
# ==========================================================
2025-08-06 17:12:16 +02:00
# Remove Subscription Banner - Proxmox VE 8.4.9
2025-08-06 14:23:22 +02:00
# ==========================================================
2025-08-06 15:19:33 +02:00
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
BASE_DIR="/usr/local/share/proxmenux"
UTILS_FILE="$BASE_DIR/utils.sh"
VENV_PATH="/opt/googletrans-env"
TOOLS_JSON="/usr/local/share/proxmenux/installed_tools.json"
if [[ -f "$UTILS_FILE" ]]; then
source "$UTILS_FILE"
fi
load_language
initialize_cache
2025-08-06 14:23:22 +02:00
2025-08-06 17:12:16 +02:00
2025-08-06 15:27:26 +02:00
ensure_tools_json() {
[ -f "$TOOLS_JSON" ] || echo "{}" > "$TOOLS_JSON"
}
register_tool() {
local tool="$1"
local state="$2"
ensure_tools_json
jq --arg t "$tool" --argjson v "$state" '.[$t]=$v' "$TOOLS_JSON" > "$TOOLS_JSON.tmp" && mv "$TOOLS_JSON.tmp" "$TOOLS_JSON"
}
2025-08-06 14:23:22 +02:00
remove_subscription_banner_pve8() {
local JS_FILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js"
local GZ_FILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.gz"
local APT_HOOK="/etc/apt/apt.conf.d/no-nag-script"
2025-08-06 17:12:16 +02:00
2025-08-06 14:23:22 +02:00
local pve_version=$(pveversion 2>/dev/null | grep -oP 'pve-manager/\K[0-9]+\.[0-9]+' | head -1)
local pve_major=$(echo "$pve_version" | cut -d. -f1)
2025-08-06 17:12:16 +02:00
if [[ "$pve_major" -ge 9 ]]; then
2025-08-06 14:23:22 +02:00
msg_error "This script is for PVE 8.x only. Detected PVE $pve_version"
return 1
fi
2025-08-06 17:12:16 +02:00
msg_info "Detected Proxmox VE $pve_version - Applying safe JS patch..."
if [[ ! -f "$JS_FILE" ]]; then
2025-08-06 14:23:22 +02:00
msg_error "JavaScript file not found: $JS_FILE"
return 1
fi
2025-08-06 17:12:16 +02:00
cp "$JS_FILE" "${JS_FILE}.bak.$(date +%s)"
sed -i "s/No valid subscription/Subscription active/g" "$JS_FILE"
sed -i "s/Ext.Msg.WARNING/Ext.Msg.INFO/g" "$JS_FILE"
2025-08-06 14:23:22 +02:00
[[ -f "$GZ_FILE" ]] && rm -f "$GZ_FILE"
2025-08-06 17:12:16 +02:00
[[ -f "$APT_HOOK" ]] && rm -f "$APT_HOOK"
2025-08-06 14:23:22 +02:00
find /var/cache/pve-manager/ -name "*.js*" -delete 2>/dev/null || true
find /var/lib/pve-manager/ -name "*.js*" -delete 2>/dev/null || true
2025-08-06 17:12:16 +02:00
msg_ok "Subscription banner removed successfully."
2025-08-06 14:23:22 +02:00
register_tool "subscription_banner" true
}
2025-08-06 17:12:16 +02:00
2025-08-06 14:23:22 +02:00
# Execute function if called directly
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
remove_subscription_banner_pve8
fi