Files
ansible_role_proxmox_provision/files/pve-remove-nag.sh
Jose 75cff9590d
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 16s
Gitleaks Scan / gitleaks (push) Successful in 4s
Markdown Lint / markdown-lint (push) Successful in 5s
feat : Add new script pve-remove-nag.sh for removing Nag messages in PVE UIs
This commit introduces a new script `pve-remove-nag.sh` designed to remove nag messages from both the Proxmox VE web and mobile user interfaces. The script is refactored to improve installation process, and the UI patching logic has been temporarily commented out for further refinement.
2026-02-09 18:12:13 +01:00

47 lines
1.6 KiB
Bash

#!/bin/sh
# source: https://github.com/community-scripts/ProxmoxVE/blob/main/tools/pve/post-pve-install.sh
# Commit c464b95
WEB_JS=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
if [ -s "$WEB_JS" ] && ! grep -q NoMoreNagging "$WEB_JS"; then
echo "Patching Web UI nag..."
sed -i \
-e "/data\.status/ s/!//" \
-e "/data\.status/ s/active/NoMoreNagging/" \
"$WEB_JS"
fi
MOBILE_TPL=/usr/share/pve-yew-mobile-gui/index.html.tpl
MARKER="<!-- MANAGED BLOCK FOR MOBILE NAG -->"
if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then
echo "Patching Mobile UI nag..."
cat <<'EOF' >> "$MOBILE_TPL"
<!-- MANAGED BLOCK FOR MOBILE NAG -->
<script>
function removeSubscriptionElements() {
const dialogs =
document.querySelectorAll('dialog.pwt-outer-dialog');
dialogs.forEach(dialog => {
const text = (dialog.textContent || '').toLowerCase();
if (text.includes('subscription')) dialog.remove();
});
const cards = document.querySelectorAll(
'.pwt-card.pwt-p-2.pwt-d-flex.pwt-interactive.pwt-justify-content-center'
);
cards.forEach(card => {
const text = (card.textContent || '').toLowerCase();
const hasButton = card.querySelector('button');
if (!hasButton && text.includes('subscription')) card.remove();
});
}
const observer = new MutationObserver(removeSubscriptionElements);
observer.observe(document.body, { childList: true, subtree: true });
removeSubscriptionElements();
setInterval(removeSubscriptionElements, 300);
setTimeout(() => observer.disconnect(), 10000);
</script>
EOF
fi