Skip to content

Instantly share code, notes, and snippets.

@tavinus
Last active February 27, 2024 22:47
  • Star 71 You must be signed in to star a gist
  • Fork 24 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tavinus/08a63e7269e0f70d27b8fb86db596f0d to your computer and use it in GitHub Desktop.
Remove PROXMOX 5.x / 6.x / 7.3-4 subscription message popup
#!/bin/sh
#######################################################
#
# Edits the proxmox Subscription file to make it
# think that it has a Subscription.
#
# Will disable the annoying login message about
# missing subscription.
#
# Tested on Proxmox PVE v5.2-1 / v6.0-4 / v6.3-2 / 7.2-11 / 7.3-4
#
# The sed command will create a backup of the changed file.
# There is no guarantee that this will work for future versions.
# Use at your own risk!
#
# OneLiner:
# wget -q -O - 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' | /bin/sh
# curl -L -s 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' | /bin/sh
#
# Save to Local File:
# wget -q -O rem_proxmox_popup.sh 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' && chmod +x rem_proxmox_popup.sh
# curl -L -o rem_proxmox_popup.sh 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' && chmod +x rem_proxmox_popup.sh
#
# Then you can just run the file after updates:
# ./rem_proxmox_popup.sh
#
#######################################################
init_error() {
local ret=1
[ -z "$1" ] || printf "%s\n" "$1"
[ -z "$2" ] || ret=$2
exit $ret
}
# Original command
# sed -i.bak 's/NotFound/Active/g' /usr/share/perl5/PVE/API2/Subscription.pm && systemctl restart pveproxy.service
# Command to restart PVE Proxy and apply changes
PVEPXYRESTART='systemctl restart pveproxy.service'
# File/folder to be changed
TGTPATH='/usr/share/perl5/PVE/API2'
TGTFILE='Subscription.pm'
# Check dependecies
SEDBIN="$(which sed)"
[ -x "$SEDBIN" ] || init_error "Could not find 'sed' binary, aborting..."
# This will also create a .bak file with the original file contents
sed -i.bak 's/NotFound/Active/g' "$TGTPATH/$TGTFILE"
sed -i.bak 's/notfound/active/g' "$TGTPATH/$TGTFILE"
$PVEPXYRESTART
# Removed execution checking, since the terminal gets closed after PVEPXYRESTART anyways
exit 0
@zanechua
Copy link

Works on v6.2

@vsurlien
Copy link

One liner worked perfect on 6.2. Thanks

@meta-n4vn33t
Copy link

meta-n4vn33t commented Sep 25, 2020

Works on version 6.4-5.

Comment updated on 25-05-2021.

@kiekstje
Copy link

Still works in 6.2-4. Thanks 👍

@MarioHRK
Copy link

It works on 6.4-4. Ty

@a3vd
Copy link

a3vd commented May 17, 2021

Works on 6.4-6 Tnxs

@ItownTech
Copy link

Works on 7.0-1. Thanks

@romanpeters
Copy link

Works on 7.2-4, thanks. Anyone made a script for Proxmox Backup Server too?

@tavinus
Copy link
Author

tavinus commented Sep 19, 2022

Need to check if it uses the same file:
'/usr/share/perl5/PVE/API2/Subscription.pm'

And if it is just changing NotFound to Active into it.

If it is all the same. It should just work. Otherwise, needs tuning.

@tavinus
Copy link
Author

tavinus commented Oct 20, 2022

Made a tweak for 7.2-11 (also works on older versions)

@ngadmini
Copy link

ngadmini commented Nov 1, 2022

Made a tweak for 7.2-11 (also works on older versions)

I found this
and it's work on ProxmoxVE v7.2-11 with proxmox-widget-toolkit: 3.5.1 trough ProxmoxVE 7.3-6 with proxmox-widget-toolkit: 3.5.5

Subscription_Message=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
root@pve:~# grep -n -B 1 -A 1 'data.status.toLowerCase.*{$' $Subscription_Message 
513-                if (res === null || res === undefined || !res || res
514:                    .data.status.toLowerCase() !== 'active') {
515-                    Ext.Msg.show({
root@pve:~# sed -i.bak "513,514s/^/\/\//" $Subscription_Message
root@pve:~# sed -i "515i if (false) {" $Subscription_Message
root@pve:~# sed -i "515s/^/\t\t\t/" $Subscription_Message
root@pve:~# grep -n -B 1 -A 2 'data.status.toLowerCase.*{$' $Subscription_Message
513-//              if (res === null || res === undefined || !res || res
514://                  .data.status.toLowerCase() !== 'active') {
515-                    if (false) {
516-                    Ext.Msg.show({
root@pve:~# unset -v Subscription_Message
root@pve:~# systemctl restart pveproxy.service

@tavinus
Copy link
Author

tavinus commented Nov 3, 2022

Interesting, but changes more stuff. Did not test it, since this one works for me...

@ngadmini
Copy link

ngadmini commented Nov 11, 2022

Interesting, but changes more stuff. Did not test it, since this one works for me...

Yups, there are many. Another way is by apt invocation, for pve-manager 7.2-11/b76d3178 with proxmox-widget-toolkit 3.5.1 :

~# echo "DPkg::Post-Invoke { \"sed -i 's/notfound/active/' /usr/share/perl5/PVE/API2/Subscription.pm\"; }" \
| tee -a /etc/apt/apt.conf.d/99pve-API2Subs-hook
DPkg::Post-Invoke { "sed -i 's/notfound/active/' /usr/share/perl5/PVE/API2/Subscription.pm"; }
~# sed -i '1i \/\/ remove naging proxmox subscription message' /etc/apt/apt.conf.d/99pve-API2Subs-hook
~# apt install --reinstall proxmox-widget-toolkit
~# apt-config dump | grep notfound
DPkg::Post-Invoke:: "sed -i 's/notfound/active/' /usr/share/perl5/PVE/API2/Subscription.pm";

regards

@WernerAUT
Copy link

still works with 7.3-3 ;)

@brendenhoffman
Copy link

brendenhoffman commented Jan 25, 2023

No longer works for 7.3-4? I don't know why they keep changing it around and I find the right file to be very hard to find.

Edit: This seems to work. I removed the function rather than trick the system into thinking the subscription is active.
sed -i.bak 's/if (false) { Ext.Msg.show({ title: gettext('''No valid subscription'''),/if (false) { void({ //Ext.Msg.show({ title: gettext('''No valid subscription'''),/g' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js

@tavinus
Copy link
Author

tavinus commented Jan 26, 2023

@brendenhoffman , just tried on 7.3-4 and it worked fine.

It does not seem like they have changed anything.

# cat /usr/share/perl5/PVE/API2/Subscription.pm | grep notfound
                status => "notfound",

It is the same as 7.2.something when I had to update the script.
They changed 'NotFound' to 'notfound', which I patched (works for both).

Maybe you had an older version?

Cheers!
Gus

@brendenhoffman
Copy link

I have no idea lol. Whatever works, at least there is more than one way around

@tavinus
Copy link
Author

tavinus commented Jan 26, 2023

Did you use an old install of the script or did you update it before trying?
What does this line shows on your script header? Does it show 7.2-11?

cat rem_proxmox_popup.sh | grep 'Tested on'
# Tested on Proxmox PVE v5.2-1 / v6.0-4 / v6.3-2 / 7.2-11

You could always run directly the latest version if you want

wget -q -O - 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' | /bin/sh

You can wrap that into a bash script or an alias if you want, eg nano rem_snag.sh

#!/bin/sh
wget -q -O - 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' | /bin/sh

Then chmod +x rem_snag.sh

Do that at your own risk tho. LOL
Cheers!

@ngadmini
Copy link

ngadmini commented Feb 19, 2023

wget -q -O - 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' | /bin/sh

Hi Bro

  1. sed is installed by default. no need to check in script lines: 30-35, 48 and 50
  2. bak file as output command line:54 will chance to replace bak file from command line: 53. avoid these with changing suffix, i.e:
    sed.bak         --> in line 53
    sed.dpkg-dist   --> in line 54
  3. OR, use if ... ; then ... fi statement, ie: if NotFound; then Active and if notfound; then active

regards

@tavinus
Copy link
Author

tavinus commented Feb 22, 2023

  1. It is good practice to run the executable with its full path. It may not be needed, but will never hurt. I always do like that, it also signals that we are using an external program.

  2. Line 54 and 53 had an OR conditional, but I removed to make it always run. The 2 sed runs were added recently to make the script work both in the old versions and new versions of proxmox. Old one uses Capitalization and the new one is all lowercase. The best solution is probably to remove the backup file completely. But yes, we currently get the backup of the second run, old versions of proxmox will not have a proper backup (but they also should not be updating much).

As I mentioned a few years ago in the first comment, we should check if the bak file exists and then number the backups, but that is a lot of complexity for something almost not useful.

If anyone has some code to number the bak files (eg .bak1, bak2, etc) it would be nice. It will need to "find" an unused bak name and then copy the original file to it. This will leave a lot of bak files behind though. I am inclining to just removing the backup option.

@ngadmini
Copy link

ngadmini commented Feb 25, 2023

  1. It is good practice to run the executable with its full path. It may not be needed, but will never hurt. I always do like that, it also signals that we are using an external program.

IMHO, avoiding unnecessary command polluting in scripts and simplicity, is best practice

2. Line 54 and 53 had an OR conditional, but I removed to make it always run. The 2 sed runs were added recently to make the script work both in the old versions and new versions of proxmox. Old one uses Capitalization and the new one is all lowercase. The best solution is probably to remove the backup file completely. But yes, we currently get the backup of the second run, old versions of proxmox will not have a proper backup (but they also should not be updating much).

if portability with the old version is your consideration, i suggest

_file="/usr/share/perl5/PVE/API2/Subscription.pm"
_sed=$(sed -i.bak "s/NotFound/Active/g;s/fotfound/active/g")
if [[ -f ${_file}.bak ]]; then
   rm "${_file}".bak
   "${_sed}" "${_file}"
else
   "${_sed}" "${_file}"
fi

regards

@tavinus
Copy link
Author

tavinus commented Feb 27, 2023

Not sure what is "polluting" what here. Seems fine to me. Feel free to fork and make your own version if you want.

Also, I am not sure how removing the bak file instead of overwriting it solves anything. Testing if the bak file exists is useless for this use case. It changes nothing. Delete + write VS overwrite is basically the same thing.

We would need to check if we have 'NotFoud' or 'notfound' inside the file. Then it could be of some use (we would know if we have the old or the new proxmox and run the sed command only once).

Grouping the 2 sed commands can actually be useful for the current code, but if we decide to check for the 2 possibilities, it would not be needed. I will think about it (and test it).

Also, still does not solve the main problem of overwriting an old bak file, which could be an actual problem.

The easiest solution is probably to timestamp the backup file name. This way we get a new name every time and we know when that happened.

Cheers!

@ngadmini
Copy link

ngadmini commented Mar 7, 2023

... .Feel free to fork and make your own version if you want.

thanks for your suggestion.
following what you suggested, I've rewritten it in my version at these gist.

regards,
nGadmini binti nGadimin

@glenstevens
Copy link

Works with Proxmox 7.4-3 as of this morning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment