mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-08-14 00:42:23 +00:00
Update remove-banner-pve8.sh
This commit is contained in:
parent
b6ca91980b
commit
54fd8a0332
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ==========================================================
|
# ==========================================================
|
||||||
# Remove Subscription Banner - Proxmox VE 8.x ONLY
|
# Remove Subscription Banner - Proxmox VE 8.4.9
|
||||||
# ==========================================================
|
# ==========================================================
|
||||||
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
|
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
|
||||||
BASE_DIR="/usr/local/share/proxmenux"
|
BASE_DIR="/usr/local/share/proxmenux"
|
||||||
@ -15,7 +15,7 @@ fi
|
|||||||
load_language
|
load_language
|
||||||
initialize_cache
|
initialize_cache
|
||||||
|
|
||||||
# Tool registration system
|
|
||||||
ensure_tools_json() {
|
ensure_tools_json() {
|
||||||
[ -f "$TOOLS_JSON" ] || echo "{}" > "$TOOLS_JSON"
|
[ -f "$TOOLS_JSON" ] || echo "{}" > "$TOOLS_JSON"
|
||||||
}
|
}
|
||||||
@ -31,88 +31,41 @@ remove_subscription_banner_pve8() {
|
|||||||
local JS_FILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js"
|
local JS_FILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js"
|
||||||
local GZ_FILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.gz"
|
local GZ_FILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.gz"
|
||||||
local APT_HOOK="/etc/apt/apt.conf.d/no-nag-script"
|
local APT_HOOK="/etc/apt/apt.conf.d/no-nag-script"
|
||||||
|
|
||||||
# Verify PVE 8.x
|
|
||||||
local pve_version=$(pveversion 2>/dev/null | grep -oP 'pve-manager/\K[0-9]+\.[0-9]+' | head -1)
|
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)
|
local pve_major=$(echo "$pve_version" | cut -d. -f1)
|
||||||
|
|
||||||
if [ "$pve_major" -ge 9 ] 2>/dev/null; then
|
if [[ "$pve_major" -ge 9 ]]; then
|
||||||
msg_error "This script is for PVE 8.x only. Detected PVE $pve_version"
|
msg_error "This script is for PVE 8.x only. Detected PVE $pve_version"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_info "Detected Proxmox VE $pve_version - Applying PVE 8.x patches"
|
msg_info "Detected Proxmox VE $pve_version - Applying safe JS patch..."
|
||||||
|
|
||||||
# Verify that the file exists
|
if [[ ! -f "$JS_FILE" ]]; then
|
||||||
if [ ! -f "$JS_FILE" ]; then
|
|
||||||
msg_error "JavaScript file not found: $JS_FILE"
|
msg_error "JavaScript file not found: $JS_FILE"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cp "$JS_FILE" "${JS_FILE}.bak.$(date +%s)"
|
||||||
for f in /etc/apt/apt.conf.d/*nag*; do
|
|
||||||
[[ -e "$f" ]] && rm -f "$f"
|
sed -i "s/No valid subscription/Subscription active/g" "$JS_FILE"
|
||||||
done
|
sed -i "s/Ext.Msg.WARNING/Ext.Msg.INFO/g" "$JS_FILE"
|
||||||
|
|
||||||
|
|
||||||
sed -i "s/res\.data\.status\.toLowerCase() !== 'NoMoreNagging'/false/g" "$JS_FILE"
|
|
||||||
sed -i "s/res\.data\.status\.toLowerCase() !== \"NoMoreNagging\"/false/g" "$JS_FILE"
|
|
||||||
sed -i "s/res\.data\.status\.toLowerCase() !== 'active'/false/g" "$JS_FILE"
|
|
||||||
sed -i "s/res\.data\.status !== 'Active'/false/g" "$JS_FILE"
|
|
||||||
sed -i "s/subscription = !(/subscription = false \&\& (/g" "$JS_FILE"
|
|
||||||
|
|
||||||
sed -i '/checked_command: function/,/},$/c\
|
|
||||||
checked_command: function (orig_cmd) {\
|
|
||||||
orig_cmd();\
|
|
||||||
},' "$JS_FILE"
|
|
||||||
|
|
||||||
sed -i "s/title: gettext('No valid subscription')/title: gettext('Subscription Active')/g" "$JS_FILE"
|
|
||||||
sed -i "s/icon: Ext\.Msg\.WARNING/icon: Ext.Msg.INFO/g" "$JS_FILE"
|
|
||||||
|
|
||||||
sed -i '/check_subscription: function/,/},$/c\
|
|
||||||
check_subscription: function () {\
|
|
||||||
let me = this;\
|
|
||||||
let vm = me.getViewModel();\
|
|
||||||
vm.set("subscriptionActive", true);\
|
|
||||||
me.getController().updateState();\
|
|
||||||
},' "$JS_FILE"
|
|
||||||
|
|
||||||
[[ -f "$GZ_FILE" ]] && rm -f "$GZ_FILE"
|
[[ -f "$GZ_FILE" ]] && rm -f "$GZ_FILE"
|
||||||
|
[[ -f "$APT_HOOK" ]] && rm -f "$APT_HOOK"
|
||||||
|
|
||||||
find /var/cache/pve-manager/ -name "*.js*" -delete 2>/dev/null || true
|
find /var/cache/pve-manager/ -name "*.js*" -delete 2>/dev/null || true
|
||||||
find /var/lib/pve-manager/ -name "*.js*" -delete 2>/dev/null || true
|
find /var/lib/pve-manager/ -name "*.js*" -delete 2>/dev/null || true
|
||||||
|
|
||||||
[[ -f "$APT_HOOK" ]] && rm -f "$APT_HOOK"
|
msg_ok "Subscription banner removed successfully."
|
||||||
cat > "$APT_HOOK" << 'EOF'
|
|
||||||
DPkg::Post-Invoke {
|
|
||||||
"test -e /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && sed -i 's/res\\.data\\.status\\.toLowerCase() !== \\'NoMoreNagging\\'/false/g' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js || true";
|
|
||||||
"test -e /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && sed -i 's/res\\.data\\.status\\.toLowerCase() !== \\'active\\'/false/g' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js || true";
|
|
||||||
"test -e /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && sed -i 's/subscription = !(/subscription = false \\&\\& (/g' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js || true";
|
|
||||||
"rm -f /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.gz || true";
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
chmod 644 "$APT_HOOK"
|
|
||||||
|
|
||||||
apt --reinstall install proxmox-widget-toolkit -y > /dev/null 2>&1
|
|
||||||
|
|
||||||
local changes_applied=0
|
|
||||||
if ! grep -q "res\.data\.status\.toLowerCase() !== 'NoMoreNagging'" "$JS_FILE"; then
|
|
||||||
((changes_applied++))
|
|
||||||
fi
|
|
||||||
if ! grep -q "title: gettext('No valid subscription')" "$JS_FILE"; then
|
|
||||||
((changes_applied++))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $changes_applied -gt 0 ]]; then
|
|
||||||
msg_ok "Subscription banner removed successfully."
|
|
||||||
else
|
|
||||||
msg_warn "Patches may not have been applied correctly. Please verify manually."
|
|
||||||
fi
|
|
||||||
|
|
||||||
register_tool "subscription_banner" true
|
register_tool "subscription_banner" true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Execute function if called directly
|
# Execute function if called directly
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
remove_subscription_banner_pve8
|
remove_subscription_banner_pve8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user