Fix nag detection: check for community-scripts dpkg hook and pve-nag-buster

The previous detection only checked for void({ in proxmoxlib.js, which
is the manual sed method. The community-scripts post-install uses a
different approach: a persistent dpkg hook (/etc/apt/apt.conf.d/no-nag-script)
that calls /usr/local/bin/pve-remove-nag.sh after every package update.
That script patches data.status lines from "!== 'active'" to
"== 'NoMoreNagging'".

Now checks (in order):
1. Community-scripts hook files (no-nag-script, pve-remove-nag.sh)
2. pve-nag-buster dpkg hooks
3. void({ JS patch (manual method)
4. Nag text removed entirely

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maarten 2026-03-02 17:11:56 +01:00
parent 9a87261823
commit 68daf96e61
1 changed files with 21 additions and 13 deletions

View File

@ -419,22 +419,30 @@ if grep -rq 'pve-no-subscription' /etc/apt/sources.list.d/ 2>/dev/null; then
fi fi
echo "$nosub" echo "$nosub"
echo '---NAG_PATCHED---' echo '---NAG_PATCHED---'
# Check if the subscription nag popup needs patching. # Detect whether the subscription nag popup has been removed.
# PVE 9.x changed the JS logic so the nag never triggers even without # Methods vary by tool and PVE version:
# patching (the condition checks for 'NoMoreNagging' which never matches). # 1. community-scripts post-install: installs a dpkg hook that patches
# PVE 8.x needs the void({ patch to suppress it. # proxmoxlib.js after every update, changing "!== 'active'" to
pve_major=$(pvesh get /version --output-format json 2>/dev/null \ # "== 'NoMoreNagging'" on data.status lines. Leaves behind:
| python3 -c 'import sys,json; print(json.load(sys.stdin)["version"].split(".")[0])' 2>/dev/null \ # - /etc/apt/apt.conf.d/no-nag-script (dpkg hook)
|| echo '8') # - /usr/local/bin/pve-remove-nag.sh (the patcher)
if [ "$pve_major" -ge 9 ] 2>/dev/null; then # 2. pve-nag-buster: similar dpkg hook approach
echo 'yes' # PVE 9+ nag is effectively disabled # 3. Manual sed: replaces Ext.Msg.show with void({
nag_patched='no'
# Check for persistent dpkg hook (community-scripts / pve-nag-buster)
if [ -f /etc/apt/apt.conf.d/no-nag-script ] || [ -f /usr/local/bin/pve-remove-nag.sh ]; then
nag_patched='yes'
# Check for pve-nag-buster package hook
elif ls /etc/dpkg/dpkg.cfg.d/*nag* /etc/apt/apt.conf.d/*nag-buster* 2>/dev/null | grep -q .; then
nag_patched='yes'
# Check JS for void({ patch (manual sed method)
elif grep -q 'void({' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js 2>/dev/null; then elif grep -q 'void({' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js 2>/dev/null; then
echo 'yes' # PVE 8 with JS patch applied nag_patched='yes'
# Check if nag text was removed entirely
elif ! grep -q "No valid subscription" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js 2>/dev/null; then elif ! grep -q "No valid subscription" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js 2>/dev/null; then
echo 'yes' # nag text removed entirely nag_patched='yes'
else
echo 'no'
fi fi
echo "$nag_patched"
echo '---UPGRADABLE---' echo '---UPGRADABLE---'
apt list --upgradable 2>/dev/null | grep -c upgradable || true apt list --upgradable 2>/dev/null | grep -c upgradable || true
echo '---VMBR1---' echo '---VMBR1---'