Skip to content

Commit

Permalink
experimental support for PMG
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesits committed Sep 28, 2019
1 parent 8336ba4 commit e039945
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -32,4 +33,3 @@ apt-get install ruby ruby-dev rubygems build-essential
gem install --no-ri --no-rdoc fpm
./package.sh
```

4 changes: 2 additions & 2 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
3 changes: 2 additions & 1 deletion scripts/purge
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rm /etc/subscription
!rm /etc/subscription
!rm /etc/pmg/subscription
25 changes: 14 additions & 11 deletions usr/bin/pve-fake-subscription
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand All @@ -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")

0 comments on commit e039945

Please sign in to comment.