From e0399452356fad5d71abe543144e41d822b22177 Mon Sep 17 00:00:00 2001 From: James Swineson Date: Sat, 28 Sep 2019 14:20:22 +0800 Subject: [PATCH] experimental support for PMG --- README.md | 2 +- package.sh | 4 ++-- scripts/purge | 3 ++- usr/bin/pve-fake-subscription | 25 ++++++++++++++----------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 75a571e..6a602cd 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ I am really poor and I really can't afford a license. I just want to get rid of ## Features * Works for any version >=5 (we've tested this from 5.3 to 6.0 without any changes in the code) +* Supports Proxmox VE and Proxmox Mail Gateway * Non-intrusive, no changes to any system file, persists between system updates * Comes with standard Debian package, easy to manage and automate * You can uninstall at any time, hassle-free @@ -32,4 +33,3 @@ apt-get install ruby ruby-dev rubygems build-essential gem install --no-ri --no-rdoc fpm ./package.sh ``` - diff --git a/package.sh b/package.sh index c75949c..e08e36c 100755 --- a/package.sh +++ b/package.sh @@ -4,9 +4,9 @@ cd "$( dirname "${BASH_SOURCE[0]}" )" fpm -s dir -t deb --force \ -n pve-fake-subscription \ - --description "Pollute Proxmox VE (>=5.0) subscription cache so it won't alert you on dashboard login" \ + --description "Pollute Proxmox VE (>=5.0) and Proxmox Mail Gateway (>=5.0) subscription cache so it won't alert you on dashboard login" \ --url "https://github.com/Jamesits/pve-fake-subscription" \ - -v 0.0.4 \ + -v 0.0.5 \ --license "GLWTS(Good Luck With That Shit) Public License" \ --depends "python3" \ --depends "libpve-common-perl" \ diff --git a/scripts/purge b/scripts/purge index 1b071de..44d2c31 100755 --- a/scripts/purge +++ b/scripts/purge @@ -1 +1,2 @@ -rm /etc/subscription +!rm /etc/subscription +!rm /etc/pmg/subscription \ No newline at end of file diff --git a/usr/bin/pve-fake-subscription b/usr/bin/pve-fake-subscription index bd5780f..95653f2 100755 --- a/usr/bin/pve-fake-subscription +++ b/usr/bin/pve-fake-subscription @@ -8,20 +8,12 @@ import json import time import re import sys +import os from typing import List -# an 8-socket fake key which should be good for all situations -key = "pve8p-1145141919" - -# key format -# /usr/share/perl5/PVE/API2/Subscription.pm -subscription_pattern = r'pve([1248])([cbsp])-[0-9a-f]{10}' - # /usr/share/perl5/PVE/Subscription.pm shared_key_data = "kjfdlskfhiuewhfk947368" - server_key_file = "/etc/ssh/ssh_host_rsa_key.pub" -subscription_file = "/etc/subscription" def get_timestamp() -> int: return int(time.time()) @@ -50,9 +42,10 @@ def generate_subscription(key: str, server_ids: List[str]) -> str: return key + "\n" + csum + "\n" + data + "\n" -if __name__ == "__main__": +# key_pattern can be find in /usr/share/perl5/{PVE,PMG}/API2/Subscription.pm +def activate(key: str, key_pattern: str, subscription_file: str) -> None: # check if the key format is correct - pattern = re.compile(subscription_pattern) + pattern = re.compile(key_pattern) if not pattern.match(key): print("key format error", file=sys.stderr) sys.exit(1) @@ -69,3 +62,13 @@ if __name__ == "__main__": with open(subscription_file, "w") as f: f.write(subscription) +if __name__ == "__main__": + # Proxmox VE + if os.path.exists("/etc/pve"): + print("Activating Proxmox VE...") + activate("pve8p-1145141919", r'pve([1248])([cbsp])-[0-9a-f]{10}', "/etc/subscription") + + # Proxmox Mail Gateway + if os.path.exists("/etc/pmg"): + print("Activating Proxmox Mail Gateway...") + activate("pmgp-1145141919", r'pmg([cbsp])-[0-9a-f]{10}', "/etc/pmg/subscription")