Proxmox VE nag removal, scripted
This is a follow-up on the method of manual removal of the “no valid subscription” popup, since the component is being repeatedly rebuilt due to active GUI development.
The script is simplistic, makes use of Perl (which is part of PVE stack) and follows the exact same steps for the predictable and safe outcome as the manual method did. Unlike other scripts available, it does NOT risk partial matches of other (unintended) parts of code in the future and their inadvertent removal, it also contains the exact copy of the JavaScript to be seen in context.
Script
#!/usr/bin/perl -pi.bak
use strict;
use warnings;
# original
my $o = quotemeta << 'EOF';
checked_command: function(orig_cmd) {
Proxmox.Utils.API2Request(
{
url: '/nodes/localhost/subscription',
method: 'GET',
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
success: function(response, opts) {
let res = response.result;
if (res === null || res === undefined || !res || res
.data.status.toLowerCase() !== 'active') {
Ext.Msg.show({
title: gettext('No valid subscription'),
icon: Ext.Msg.WARNING,
message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
buttons: Ext.Msg.OK,
callback: function(btn) {
if (btn !== 'ok') {
return;
}
orig_cmd();
},
});
} else {
orig_cmd();
}
},
},
);
},
EOF
# replacement
my $r = << 'EOF';
checked_command: function(orig_cmd) {
Proxmox.Utils.API2Request(
{
url: '/nodes/localhost/subscription',
method: 'GET',
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
success: function(response, opts) {
orig_cmd();
},
},
);
},
EOF
BEGIN { undef $/; } s/$o/$r/;
Shebang 1 arguments provide for execution of the script over input, sed
-style (-p
), 2 and also guarantee a backup copy is retained (-i.bak
).
Original pattern ($o
)and its replacement ($r
) are assigned to variables using HEREDOC 3 notation in full, the original gets non-word characters escaped (quotemeta
) for use with regular expressions.
The entire replacement is in a single shot on multi-line (undef $/;
) pattern, where original is substituted for replacement (s/$o/$r/;
) or, if not found, nothing is modified.
Download
The script is maintained here and can be directly downloaded:
wget https://free-pmx.srht.site/snippets/pve-no-nag/pve-no-nag.pl
Manual page also available.
The license is GNU GPLv3+: This is free software - you are free to change and redistribute it.
Use
Important
All actions below preferably performed over direct SSH connection or console, NOT via Web GUI.
The script can be run with no execute rights pointing at the JavaScript library:
perl pve-no-nag.pl /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
Verify
Result can be confirmed by comparing the backed up and the in-place modified file:
diff -u /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js{.bak,}
--- /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.bak 2024-11-27 11:25:44.000000000 +0000
+++ /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js 2024-12-13 18:25:55.984436026 +0000
@@ -560,24 +560,7 @@
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
success: function(response, opts) {
- let res = response.result;
- if (res === null || res === undefined || !res || res
- .data.status.toLowerCase() !== 'active') {
- Ext.Msg.show({
- title: gettext('No valid subscription'),
- icon: Ext.Msg.WARNING,
- message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
- buttons: Ext.Msg.OK,
- callback: function(btn) {
- if (btn !== 'ok') {
- return;
- }
- orig_cmd();
- },
- });
- } else {
orig_cmd();
- }
},
},
);
Restore
Should anything go wrong, the original file can also be simply reinstalled:
apt reinstall proxmox-widget-toolkit
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 220 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://download.proxmox.com/debian/pve bookworm/pve-no-subscription amd64 proxmox-widget-toolkit all 4.3.3 [220 kB]
Fetched 220 kB in 0s (723 kB/s)
(Reading database ... 53687 files and directories currently installed.)
Preparing to unpack .../proxmox-widget-toolkit_4.3.3_all.deb ...
Unpacking proxmox-widget-toolkit (4.3.3) over (4.3.3) ...
Setting up proxmox-widget-toolkit (4.3.3) ...