experimental support for PMG

This commit is contained in:
James Swineson 2019-09-28 14:20:22 +08:00
parent 8336ba4728
commit e039945235
4 changed files with 19 additions and 15 deletions

View File

@ -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
```

View File

@ -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" \

View File

@ -1 +1,2 @@
rm /etc/subscription
!rm /etc/subscription
!rm /etc/pmg/subscription

View File

@ -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")