Add proxmox-nag-remover.sh
This commit is contained in:
214
proxmox-nag-remover.sh
Normal file
214
proxmox-nag-remover.sh
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Universal Proxmox Subscription Nag Remover
|
||||||
|
# Works with PVE (Proxmox VE), PBS (Proxmox Backup Server), and PMG (Proxmox Mail Gateway)
|
||||||
|
#
|
||||||
|
# Based on community-scripts by tteck and contributors
|
||||||
|
# Original scripts: https://community-scripts.github.io/ProxmoxVE/
|
||||||
|
# License: MIT
|
||||||
|
# Copyright (c) 2021-2025 community-scripts contributors
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
RD=$(echo "\033[01;31m")
|
||||||
|
YW=$(echo "\033[33m")
|
||||||
|
GN=$(echo "\033[1;92m")
|
||||||
|
BL=$(echo "\033[94m")
|
||||||
|
CL=$(echo "\033[m")
|
||||||
|
BFR="\\r\\033[K"
|
||||||
|
HOLD="-"
|
||||||
|
CM="${GN}✓${CL}"
|
||||||
|
CROSS="${RD}✗${CL}"
|
||||||
|
INFO="${BL}ℹ${CL}"
|
||||||
|
|
||||||
|
# Output functions
|
||||||
|
msg_info() {
|
||||||
|
local msg="$1"
|
||||||
|
echo -ne " ${HOLD} ${YW}${msg}..."
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_ok() {
|
||||||
|
local msg="$1"
|
||||||
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_error() {
|
||||||
|
local msg="$1"
|
||||||
|
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_note() {
|
||||||
|
local msg="$1"
|
||||||
|
echo -e " ${INFO} ${BL}${msg}${CL}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Header
|
||||||
|
header_info() {
|
||||||
|
clear
|
||||||
|
cat <<"EOF"
|
||||||
|
╔═════════════════════════════════════════════════════════════════════════════╗
|
||||||
|
║ Universal Proxmox Nag Remover ║
|
||||||
|
║ PVE • PBS • PMG Support ║
|
||||||
|
╚═════════════════════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
|
EOF
|
||||||
|
echo -e "${BL}Universal Subscription Nag Remover for All Proxmox Products${CL}"
|
||||||
|
echo -e "${YW}Based on community-scripts: https://community-scripts.github.io/ProxmoxVE/${CL}"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Detect Proxmox product
|
||||||
|
detect_proxmox() {
|
||||||
|
local product=""
|
||||||
|
local version=""
|
||||||
|
|
||||||
|
if command -v pveversion >/dev/null 2>&1; then
|
||||||
|
product="PVE"
|
||||||
|
version=$(pveversion | head -1)
|
||||||
|
elif command -v proxmox-backup-manager >/dev/null 2>&1; then
|
||||||
|
product="PBS"
|
||||||
|
version=$(proxmox-backup-manager version 2>/dev/null | head -1 || echo "PBS detected")
|
||||||
|
elif command -v pmgversion >/dev/null 2>&1; then
|
||||||
|
product="PMG"
|
||||||
|
version=$(pmgversion | head -1)
|
||||||
|
elif [ -f /usr/bin/pmg-admin ]; then
|
||||||
|
product="PMG"
|
||||||
|
version="PMG detected"
|
||||||
|
else
|
||||||
|
msg_error "No supported Proxmox product detected"
|
||||||
|
echo ""
|
||||||
|
echo "This script supports:"
|
||||||
|
echo " • Proxmox VE (PVE)"
|
||||||
|
echo " • Proxmox Backup Server (PBS)"
|
||||||
|
echo " • Proxmox Mail Gateway (PMG)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$product|$version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Apply nag removal based on product
|
||||||
|
apply_nag_removal() {
|
||||||
|
local product="$1"
|
||||||
|
|
||||||
|
case $product in
|
||||||
|
PVE)
|
||||||
|
msg_info "Applying PVE subscription nag removal"
|
||||||
|
|
||||||
|
# PVE uses the more comprehensive regex pattern
|
||||||
|
cat > /etc/apt/apt.conf.d/no-nag-script << 'EOF'
|
||||||
|
DPkg::Post-Invoke { "dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ $? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/.*data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi"; };
|
||||||
|
EOF
|
||||||
|
|
||||||
|
apt --reinstall install proxmox-widget-toolkit &>/dev/null
|
||||||
|
msg_ok "PVE subscription nag removal applied"
|
||||||
|
;;
|
||||||
|
|
||||||
|
PBS)
|
||||||
|
msg_info "Applying PBS subscription nag removal"
|
||||||
|
|
||||||
|
# PBS uses simpler regex pattern
|
||||||
|
cat > /etc/apt/apt.conf.d/no-nag-script << 'EOF'
|
||||||
|
DPkg::Post-Invoke { "dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ $? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi"; };
|
||||||
|
EOF
|
||||||
|
|
||||||
|
apt --reinstall install proxmox-widget-toolkit &>/dev/null
|
||||||
|
msg_ok "PBS subscription nag removal applied"
|
||||||
|
;;
|
||||||
|
|
||||||
|
PMG)
|
||||||
|
msg_info "Applying PMG subscription nag removal"
|
||||||
|
|
||||||
|
# PMG needs both normal GUI and mobile GUI fixes
|
||||||
|
cat > /etc/apt/apt.conf.d/no-nag-script << 'EOF'
|
||||||
|
DPkg::Post-Invoke { "dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ $? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/.*data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi"; };
|
||||||
|
DPkg::Post-Invoke { "dpkg -V pmg-gui | grep -q '/pmgmanagerlib-mobile\.js$'; if [ $? -eq 1 ]; then { echo 'Removing subscription nag from Mobile UI...'; sed -i '/data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/pmg-gui/js/pmgmanagerlib-mobile.js; }; fi"; };
|
||||||
|
EOF
|
||||||
|
|
||||||
|
apt --reinstall install proxmox-widget-toolkit pmg-gui &>/dev/null
|
||||||
|
msg_ok "PMG subscription nag removal applied (desktop & mobile)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main execution
|
||||||
|
main() {
|
||||||
|
# Check if running as root
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "This script must be run as root (use sudo)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
header_info
|
||||||
|
|
||||||
|
# Detect Proxmox product
|
||||||
|
msg_info "Detecting Proxmox product"
|
||||||
|
detection_result=$(detect_proxmox)
|
||||||
|
IFS='|' read -r PRODUCT VERSION <<< "$detection_result"
|
||||||
|
msg_ok "Detected $PRODUCT"
|
||||||
|
|
||||||
|
msg_note "$VERSION"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Check if already installed
|
||||||
|
if [[ -f /etc/apt/apt.conf.d/no-nag-script ]]; then
|
||||||
|
msg_info "Subscription nag removal already installed"
|
||||||
|
echo ""
|
||||||
|
echo "The nag removal is already active and will persist through updates."
|
||||||
|
echo "To reinstall, delete /etc/apt/apt.conf.d/no-nag-script and run again."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show subscription support message
|
||||||
|
echo -e "${YW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}"
|
||||||
|
echo -e "${BL} Support Subscriptions${CL}"
|
||||||
|
echo -e "${YW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}"
|
||||||
|
echo ""
|
||||||
|
echo "Supporting the software's development team is essential. Check their official"
|
||||||
|
echo "website's Support Subscriptions for pricing. Without their dedicated work,"
|
||||||
|
echo "we wouldn't have this exceptional software."
|
||||||
|
echo ""
|
||||||
|
echo -e "${YW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Confirm installation
|
||||||
|
echo "This will disable the subscription nag message that appears when logging"
|
||||||
|
echo "into the web interface. The fix will automatically reapply after updates."
|
||||||
|
echo ""
|
||||||
|
while true; do
|
||||||
|
read -p "Continue with subscription nag removal? (y/n): " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]*) break ;;
|
||||||
|
[Nn]*)
|
||||||
|
echo "Aborted."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*) echo "Please answer yes or no." ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Apply the fix
|
||||||
|
apply_nag_removal "$PRODUCT"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "${GN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}"
|
||||||
|
echo -e "${GN} Installation Complete${CL}"
|
||||||
|
echo -e "${GN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}"
|
||||||
|
echo ""
|
||||||
|
echo "✓ The subscription nag has been disabled for $PRODUCT"
|
||||||
|
echo "✓ The fix will automatically reapply after Proxmox updates"
|
||||||
|
echo "✓ Clear your browser cache and refresh the web interface"
|
||||||
|
echo ""
|
||||||
|
if [[ "$PRODUCT" == "PMG" ]]; then
|
||||||
|
echo "✓ Both desktop and mobile interfaces have been patched"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
echo -e "${YW}Original community-scripts: https://community-scripts.github.io/ProxmoxVE/${CL}"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run main function
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user