mirror of
https://github.com/Jamesits/pve-fake-subscription
synced 2025-12-06 11:07:00 -05:00
Compare commits
No commits in common. "master" and "v0.0.3" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
*.deb
|
*.deb
|
||||||
/out/
|
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/macos,python,windows,visualstudiocode
|
# Created by https://www.gitignore.io/api/macos,python,windows,visualstudiocode
|
||||||
# Edit at https://www.gitignore.io/?templates=macos,python,windows,visualstudiocode
|
# Edit at https://www.gitignore.io/?templates=macos,python,windows,visualstudiocode
|
||||||
@ -194,3 +193,4 @@ $RECYCLE.BIN/
|
|||||||
*.lnk
|
*.lnk
|
||||||
|
|
||||||
# End of https://www.gitignore.io/api/macos,python,windows,visualstudiocode
|
# End of https://www.gitignore.io/api/macos,python,windows,visualstudiocode
|
||||||
|
|
||||||
|
|||||||
95
README.md
95
README.md
@ -1,98 +1,33 @@
|
|||||||
# pve-fake-subscription
|
I am really poor and I really can't afford a license. I just want to get rid of the annoying dialog on every login.
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Disables the "No valid subscription" dialog on all Proxmox products.
|
|
||||||
|
|
||||||
> I am really poor and I can't afford a license. I just want to get rid of the annoying dialog.
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
Works for:
|
* Works for any version >=5 (we've tested this from 5.3 to 6.0 without any changes in the code)
|
||||||
|
* 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 (you might need to wait a week for the cache to be invalidated because of https://github.com/jordansissel/fpm/issues/1472 )
|
||||||
|
|
||||||
- Proxmox VE (5.x or later; 3.x and 4.x [require some manual actions](#compatibility-information-for-old-proxmox-ve-versions))
|
## Installation
|
||||||
- Proxmox Mail Gateway (5.x or later)
|
|
||||||
- Proxmox Backup Server (1.x or later)
|
|
||||||
|
|
||||||
Highlights:
|
* Go to [release](https://github.com/Jamesits/pve-fake-subscription/releases/latest) to download the latest release
|
||||||
|
* Run `dpkg -i pve-fake-subscription_*.deb` as root on every Proxmox VE node
|
||||||
|
|
||||||
- Non-intrusive: zero modification of any system file
|
## Uninstallation
|
||||||
- Future-proof: persists between system updates & major upgrades
|
|
||||||
- Hassle-free: you can uninstall at any time
|
|
||||||
- Comes with standard Debian package, easy to manage and automate
|
|
||||||
- **No JavaScript is involved** in the whole process, as I believe JavaScript is harmful to developers
|
|
||||||
|
|
||||||
## Usage
|
Run everything as root:
|
||||||
|
|
||||||
### Installation
|
|
||||||
|
|
||||||
1. [Download the latest release](https://github.com/Jamesits/pve-fake-subscription/releases/latest)
|
|
||||||
1. Install: run `dpkg -i pve-fake-subscription_*.deb` as root on every node
|
|
||||||
1. (Optional) `echo "127.0.0.1 shop.maurer-it.com" | sudo tee -a /etc/hosts` to prevent fake keys from being checked against the Proxmox servers
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
|
|
||||||
After installation, please refrain yourself from clicking the "check" button on the "Subscription" page. It will invalidate the cache and temporary revert your instance into an unlicensed status.
|
|
||||||
|
|
||||||
The fake subscription status doesn't grant you free access to the enterprise repository. You should switch to the no-subscription repository if not already done. Use the following method:
|
|
||||||
|
|
||||||
- [Proxmox VE (PVE)](https://pve.proxmox.com/wiki/Package_Repositories#sysadmin_no_subscription_repo)
|
|
||||||
- [Proxmox Mail Gateway (PMG)](https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html#pmg_package_repositories)
|
|
||||||
- [Proxmox Backup Server (PBS)](https://pbs.proxmox.com/docs/installation.html#proxmox-backup-no-subscription-repository)
|
|
||||||
|
|
||||||
### Uninstallation
|
|
||||||
|
|
||||||
Run as root:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
apt purge pve-fake-subscription
|
apt purge pve-fake-subscription
|
||||||
|
rm /etc/subscription
|
||||||
```
|
```
|
||||||
|
|
||||||
This will revert your system to a "no subscription key" status.
|
## Building the Package
|
||||||
|
|
||||||
## Development Notes
|
Run everything as root on a Debian 10 system:
|
||||||
|
|
||||||
### Building the Package
|
|
||||||
|
|
||||||
Install [nFPM](https://nfpm.goreleaser.com/install/), then:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
apt-get install ruby ruby-dev rubygems build-essential
|
||||||
|
gem install --no-ri --no-rdoc fpm
|
||||||
./package.sh
|
./package.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compatibility Information for Old Proxmox VE Versions
|
|
||||||
|
|
||||||
#### PVE 4.x
|
|
||||||
|
|
||||||
After installation or updates, run:
|
|
||||||
```shell
|
|
||||||
sed -i'' -e's/pve8p/pve4p/g' /usr/bin/pve-fake-subscription
|
|
||||||
pve-fake-subscription
|
|
||||||
```
|
|
||||||
|
|
||||||
#### PVE 3.x
|
|
||||||
|
|
||||||
Installation with `dpkg -i` will not work because of missing dependencies. Use the following script to install manually:
|
|
||||||
```shell
|
|
||||||
# extract the deb package
|
|
||||||
mkdir -p /tmp/pve-fake-subscription
|
|
||||||
dpkg-deb -x pve-fake-subscription_*.deb /tmp/pve-fake-subscription
|
|
||||||
|
|
||||||
# patch and install the script
|
|
||||||
sed -i'' -e's/python3/python/g' -e's/pve8p/pve4p/g' /tmp/pve-fake-subscription/usr/bin/pve-fake-subscription
|
|
||||||
mv /tmp/pve-fake-subscription/usr/bin/pve-fake-subscription /usr/local/bin/
|
|
||||||
|
|
||||||
# install the timer
|
|
||||||
ln -sf /usr/local/bin/pve-fake-subscription /etc/cron.hourly/pve-fake-subscription
|
|
||||||
|
|
||||||
# invoke it once
|
|
||||||
/usr/local/bin/pve-fake-subscription
|
|
||||||
|
|
||||||
# remove temporary files
|
|
||||||
rm -rf /tmp/pve-fake-subscription
|
|
||||||
```
|
|
||||||
|
|
||||||
Removal:
|
|
||||||
```shell
|
|
||||||
rm -f /usr/local/bin/pve-fake-subscription /etc/cron.hourly/pve-fake-subscription /etc/subscription
|
|
||||||
```
|
|
||||||
|
|||||||
40
nfpm.yaml
40
nfpm.yaml
@ -1,40 +0,0 @@
|
|||||||
name: "pve-fake-subscription"
|
|
||||||
arch: "all"
|
|
||||||
platform: "linux"
|
|
||||||
version: "0.0.11"
|
|
||||||
version_schema: "semver"
|
|
||||||
version_metadata: "git"
|
|
||||||
|
|
||||||
epoch: 0
|
|
||||||
release: 1
|
|
||||||
section: "admin"
|
|
||||||
priority: "optional"
|
|
||||||
|
|
||||||
maintainer: "Nobody <nobody@example.com>"
|
|
||||||
|
|
||||||
depends:
|
|
||||||
- python3
|
|
||||||
description: |
|
|
||||||
Pollute the subscription cache of Proxmox VE (>=5.0), Proxmox Mail Gateway (>=5.0) & Proxmox Backup Server (>=1.0) so it won't alert you on dashboard login
|
|
||||||
vendor: "none"
|
|
||||||
homepage: "https://github.com/Jamesits/pve-fake-subscription"
|
|
||||||
license: "GLWTS(Good Luck With That Shit) Public License"
|
|
||||||
|
|
||||||
contents:
|
|
||||||
- src: "./usr/bin/pve-fake-subscription"
|
|
||||||
dst: "/usr/bin/pve-fake-subscription"
|
|
||||||
file_info:
|
|
||||||
mode: 0755
|
|
||||||
- src: "./usr/lib/systemd"
|
|
||||||
dst: "/usr/lib/systemd"
|
|
||||||
file_info:
|
|
||||||
mode: 0644
|
|
||||||
- src: "./usr/share/doc/pve-fake-subscription"
|
|
||||||
dst: "/usr/share/doc/pve-fake-subscription"
|
|
||||||
file_info:
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
scripts:
|
|
||||||
postinstall: "./scripts/postinst"
|
|
||||||
preremove: "./scripts/prerm"
|
|
||||||
postremove: "./scripts/postrm"
|
|
||||||
27
package.sh
27
package.sh
@ -1,16 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -Eeuo pipefail
|
|
||||||
cd "$( dirname "${BASH_SOURCE[0]}" )" || exit 1
|
|
||||||
|
|
||||||
OUT_DIR="out"
|
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||||
|
|
||||||
rm -rf "${OUT_DIR}"
|
fpm -s dir -t deb --force \
|
||||||
mkdir -p "${OUT_DIR}"
|
-n pve-fake-subscription \
|
||||||
|
--description "Pollute Proxmox VE (>=5.0) subscription cache so it won't alert you on dashboard login" \
|
||||||
|
--url "https://github.com/Jamesits/pve-fake-subscription" \
|
||||||
|
-v 0.0.3 \
|
||||||
|
--license "GLWTS(Good Luck With That Shit) Public License" \
|
||||||
|
--depends "python3" \
|
||||||
|
--depends "libpve-common-perl" \
|
||||||
|
--architecture all \
|
||||||
|
--deb-dist "unstable" \
|
||||||
|
--deb-priority "optional" \
|
||||||
|
--deb-systemd "usr/lib/systemd/system/pve-fake-subscription.timer" \
|
||||||
|
--deb-after-purge "scripts/purge" \
|
||||||
|
./usr
|
||||||
|
|
||||||
# build package
|
|
||||||
nfpm pkg --packager deb --target "${OUT_DIR}"
|
|
||||||
|
|
||||||
# generate checksum
|
|
||||||
pushd "${OUT_DIR}" >/dev/null
|
|
||||||
sha256sum -b -- * > sha256sum.txt
|
|
||||||
popd >/dev/null
|
|
||||||
|
|||||||
@ -1,56 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
after_upgrade() {
|
|
||||||
:
|
|
||||||
|
|
||||||
if command -v systemctl >/dev/null; then
|
|
||||||
systemctl --system daemon-reload >/dev/null || true
|
|
||||||
debsystemctl=$(command -v deb-systemd-invoke || echo systemctl)
|
|
||||||
if ! systemctl is-enabled pve-fake-subscription.timer >/dev/null
|
|
||||||
then
|
|
||||||
: # Ensure this if-clause is not empty. If it were empty, and we had an 'else', then it is an error in shell syntax
|
|
||||||
systemctl preset pve-fake-subscription.timer >/dev/null || true
|
|
||||||
$debsystemctl start pve-fake-subscription.timer >/dev/null || true
|
|
||||||
else
|
|
||||||
$debsystemctl restart pve-fake-subscription.timer >/dev/null || true
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
ln -sf /usr/bin/pve-fake-subscription /etc/cron.hourly/pve-fake-subscription
|
|
||||||
fi
|
|
||||||
|
|
||||||
pve-fake-subscription
|
|
||||||
}
|
|
||||||
|
|
||||||
after_install() {
|
|
||||||
:
|
|
||||||
|
|
||||||
if command -v systemctl >/dev/null; then
|
|
||||||
systemctl --system daemon-reload >/dev/null || true
|
|
||||||
debsystemctl=$(command -v deb-systemd-invoke || echo systemctl)
|
|
||||||
systemctl preset pve-fake-subscription.timer >/dev/null || true
|
|
||||||
$debsystemctl start pve-fake-subscription.timer >/dev/null || true
|
|
||||||
else
|
|
||||||
ln -sf /usr/bin/pve-fake-subscription /etc/cron.hourly/pve-fake-subscription
|
|
||||||
fi
|
|
||||||
|
|
||||||
pve-fake-subscription
|
|
||||||
}
|
|
||||||
|
|
||||||
if { [ "${1}" = "configure" ] && [ -z "${2}" ]; } || [ "${1}" = "abort-remove" ]; then
|
|
||||||
# "after install" here
|
|
||||||
# "abort-remove" happens when the pre-removal script failed.
|
|
||||||
# In that case, this script, which should be idemptoent, is run
|
|
||||||
# to ensure a clean roll-back of the removal.
|
|
||||||
after_install
|
|
||||||
elif [ "${1}" = "configure" ] && [ -n "${2}" ]; then
|
|
||||||
upgradeFromVersion="${2}"
|
|
||||||
# "after upgrade" here
|
|
||||||
# NOTE: This slot is also used when deb packages are removed,
|
|
||||||
# but their config files aren't, but a newer version of the
|
|
||||||
# package is installed later, called "Config-Files" state.
|
|
||||||
# basically, that still looks a _lot_ like an upgrade to me.
|
|
||||||
after_upgrade "${2}"
|
|
||||||
elif echo "${1}" | grep -E -q "(abort|fail)"; then
|
|
||||||
echo "Failed to install before the post-installation script was run." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
after_remove() {
|
|
||||||
:
|
|
||||||
|
|
||||||
rm -f /etc/subscription
|
|
||||||
rm -f /etc/pmg/subscription
|
|
||||||
rm -f /etc/proxmox-backup/subscription
|
|
||||||
|
|
||||||
rm -f /etc/cron.hourly/pve-fake-subscription
|
|
||||||
}
|
|
||||||
|
|
||||||
after_purge() {
|
|
||||||
:
|
|
||||||
}
|
|
||||||
|
|
||||||
dummy() {
|
|
||||||
:
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "${1}" = "remove" ] || [ "${1}" = "abort-install" ]; then
|
|
||||||
# "after remove" goes here
|
|
||||||
# "abort-install" happens when the pre-installation script failed.
|
|
||||||
# In that case, this script, which should be idemptoent, is run
|
|
||||||
# to ensure a clean roll-back of the installation.
|
|
||||||
after_remove
|
|
||||||
elif [ "${1}" = "purge" ] && [ -z "${2}" ]; then
|
|
||||||
# like "on remove", but executes after dpkg deletes config files
|
|
||||||
# 'apt-get purge' runs 'on remove' section, then this section.
|
|
||||||
# There is no equivalent in RPM or ARCH.
|
|
||||||
after_purge
|
|
||||||
elif [ "${1}" = "upgrade" ]; then
|
|
||||||
# This represents the case where the old package's postrm is called after
|
|
||||||
# the 'preinst' script is called.
|
|
||||||
# We should ignore this and just use 'preinst upgrade' and
|
|
||||||
# 'postinst configure'. The newly installed package should do the
|
|
||||||
# upgrade, not the uninstalled one, since it can't anticipate what new
|
|
||||||
# things it will have to do to upgrade for the new version.
|
|
||||||
dummy
|
|
||||||
elif echo "${1}" | grep -E -q '(fail|abort)'; then
|
|
||||||
echo "Failed to install before the post-removal script was run." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
before_remove() {
|
|
||||||
:
|
|
||||||
|
|
||||||
debsystemctl=$(command -v deb-systemd-invoke || echo systemctl)
|
|
||||||
$debsystemctl stop pve-fake-subscription.timer >/dev/null || true
|
|
||||||
systemctl disable pve-fake-subscription.timer >/dev/null || true
|
|
||||||
systemctl --system daemon-reload >/dev/null || true
|
|
||||||
}
|
|
||||||
|
|
||||||
dummy() {
|
|
||||||
:
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "${1}" = "remove" ] && [ -z "${2}" ]; then
|
|
||||||
# "before remove" goes here
|
|
||||||
before_remove
|
|
||||||
elif [ "${1}" = "upgrade" ]; then
|
|
||||||
# Executed before the old version is removed
|
|
||||||
# upon upgrade.
|
|
||||||
# We should generally not do anything here. The newly installed package
|
|
||||||
# should do the upgrade, not the uninstalled one, since it can't anticipate
|
|
||||||
# what new things it will have to do to upgrade for the new version.
|
|
||||||
dummy
|
|
||||||
elif echo "${1}" | grep -E -q "(fail|abort)"; then
|
|
||||||
echo "Failed to install before the pre-removal script was run." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
1
scripts/purge
Executable file
1
scripts/purge
Executable file
@ -0,0 +1 @@
|
|||||||
|
rm /etc/subscriptions
|
||||||
@ -1,136 +1,71 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Pollute Proxmox software subscription cache so it won't alert you on dashboard login
|
# Pollute Proxmox VE 5.x subscription cache so it won't alert you on dashboard login
|
||||||
# Should be scheduled to run every few hours with a timer to prevent cache from expiring
|
# If you need to prevent it checking keys against a server, please block "shop.maurer-it.com"
|
||||||
# If you need to prevent it checking keys against a server, please block "shop.maurer-it.com" in your hosts file
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
from typing import List
|
||||||
from datetime import datetime, timedelta
|
|
||||||
|
|
||||||
# PVE & PMG: /usr/share/perl5/PVE/Subscription.pm
|
# an 8-socket fake key which should be good for all situations
|
||||||
# PBS: /usr/lib/x86_64-linux-gnu/proxmox-backup/* (source code at `https://git.proxmox.com/git/proxmox-backup.git`)
|
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"
|
shared_key_data = "kjfdlskfhiuewhfk947368"
|
||||||
|
|
||||||
server_key_file = "/etc/ssh/ssh_host_rsa_key.pub"
|
server_key_file = "/etc/ssh/ssh_host_rsa_key.pub"
|
||||||
|
subscription_file = "/etc/subscription"
|
||||||
|
|
||||||
# Default license keys
|
def get_timestamp() -> int:
|
||||||
lic_pve = "pve8p-1145141919"
|
|
||||||
lic_pmg = "pmgp-1145141919"
|
|
||||||
lic_pbs = "pbst-1145141919"
|
|
||||||
|
|
||||||
# UI customization
|
|
||||||
ui_product_name = "YajuuSenpai"
|
|
||||||
ui_message = "Yajuu Senpai has got your back"
|
|
||||||
ui_url = "https://github.com/Jamesits/pve-fake-subscription"
|
|
||||||
|
|
||||||
def get_timestamp():
|
|
||||||
return int(time.time())
|
return int(time.time())
|
||||||
|
|
||||||
# Perl's md5_base64 implementation
|
# perl's md5_base64 implementation
|
||||||
def md5_base64_perl(x):
|
def md5_base64(x: str) -> str:
|
||||||
return base64.b64encode(hashlib.md5(x.encode()).digest()).strip(b'=').decode()
|
return base64.b64encode(hashlib.md5(x.encode()).digest()).strip(b'=')
|
||||||
|
|
||||||
# Rust's `base64::encode(tools::md5sum("something")?);`
|
def generate_server_id(key: str) -> str:
|
||||||
def md5_base64_rs(x):
|
|
||||||
return base64.b64encode(hashlib.md5(x.encode()).digest()).decode()
|
|
||||||
|
|
||||||
def generate_server_id(key):
|
|
||||||
return hashlib.md5(key.encode()).hexdigest().upper()
|
return hashlib.md5(key.encode()).hexdigest().upper()
|
||||||
|
|
||||||
def dt_string(format, offset_secs=0):
|
def generate_subscription(key: str, server_ids: List[str]) -> str:
|
||||||
return (datetime.now() + timedelta(seconds=offset_secs)).strftime(format)
|
|
||||||
|
|
||||||
def generate_subscription_pve_pmg(key, server_ids, product_name=ui_product_name):
|
|
||||||
localinfo = {
|
localinfo = {
|
||||||
"checktime": get_timestamp(),
|
"checktime": get_timestamp(),
|
||||||
"status": "Active",
|
"status": "Active",
|
||||||
"key": key,
|
"key": key,
|
||||||
"validdirectory": ",".join(server_ids),
|
"validdirectory": ",".join(server_ids),
|
||||||
"productname": product_name,
|
"productname": "YajuuSenpai",
|
||||||
"regdate": dt_string("%Y-%m-%d %H:%M:%S"),
|
"regdate": get_timestamp(),
|
||||||
"nextduedate": dt_string("%Y-%m-%d", 1296000),
|
"nextduedate": 2147483647,
|
||||||
}
|
}
|
||||||
|
|
||||||
data = base64.standard_b64encode(json.dumps(localinfo).encode()).decode()
|
data = base64.standard_b64encode(json.dumps(localinfo).encode()).decode()
|
||||||
cat = str(localinfo["checktime"]) + data + "\n" + shared_key_data
|
cat = str(localinfo["checktime"]) + data + "\n" + shared_key_data
|
||||||
csum = md5_base64_perl(cat)
|
csum = md5_base64(cat).decode()
|
||||||
|
|
||||||
return key + "\n" + csum + "\n" + data + "\n"
|
return key + "\n" + csum + "\n" + data + "\n"
|
||||||
|
|
||||||
# key_pattern can be find in /usr/share/perl5/{PVE,PMG}/API2/Subscription.pm
|
|
||||||
# PVE5+: r'pve([1248])([cbsp])-[0-9a-f]{10}'
|
|
||||||
# PVE3/4: r'pve([124])([cbsp])-[0-9a-f]{10}'
|
|
||||||
# PMG: r'pmg([cbsp])-[0-9a-f]{10}'
|
|
||||||
def activate_pve_pmg(key, subscription_file, *args, **kwargs):
|
|
||||||
# check if the key format is correct
|
|
||||||
# pattern = re.compile(key_pattern)
|
|
||||||
# if not pattern.match(key):
|
|
||||||
# print("key format error", file=sys.stderr)
|
|
||||||
# sys.exit(1)
|
|
||||||
|
|
||||||
# get machine ID
|
|
||||||
server_id = ""
|
|
||||||
with open(server_key_file, "r") as f:
|
|
||||||
server_id = generate_server_id(f.read())
|
|
||||||
|
|
||||||
# generate a license file
|
|
||||||
subscription = generate_subscription_pve_pmg(key, [server_id], *args, **kwargs)
|
|
||||||
|
|
||||||
# write license file
|
|
||||||
with open(subscription_file, "w") as f:
|
|
||||||
f.write(subscription)
|
|
||||||
|
|
||||||
def generate_subscription_pbs(key, server_ids, product_name=ui_product_name, message=ui_message, url=ui_url):
|
|
||||||
localinfo = {
|
|
||||||
"status": "active", # PBS: `new`, `notfound`, `active`, `invalid`
|
|
||||||
"serverid": ",".join(server_ids),
|
|
||||||
"checktime": get_timestamp(),
|
|
||||||
"key": key,
|
|
||||||
"message": message,
|
|
||||||
"productname": product_name,
|
|
||||||
"regdate": dt_string("%Y-%m-%d %H:%M:%S"),
|
|
||||||
"nextduedate": dt_string("%Y-%m-%d", 1296000), # 1296000: MAX_LOCAL_KEY_AGE in src/tools/subscription.rs
|
|
||||||
"url": url,
|
|
||||||
}
|
|
||||||
|
|
||||||
data = base64.standard_b64encode(json.dumps(localinfo).encode()).decode()
|
|
||||||
cat = str(localinfo["checktime"]) + data + shared_key_data
|
|
||||||
csum = md5_base64_rs(cat)
|
|
||||||
|
|
||||||
return key + "\n" + csum + "\n" + data + "\n"
|
|
||||||
|
|
||||||
# Key pattern: pbst-xxxxxxxxxx
|
|
||||||
def activate_pbs(key, subscription_file, *args, **kwargs):
|
|
||||||
# get machine ID
|
|
||||||
server_id = ""
|
|
||||||
with open(server_key_file, "r") as f:
|
|
||||||
server_id = generate_server_id(f.read())
|
|
||||||
|
|
||||||
# generate a license file
|
|
||||||
subscription = generate_subscription_pbs(key, [server_id], *args, **kwargs)
|
|
||||||
|
|
||||||
# write license file
|
|
||||||
with open(subscription_file, "w") as f:
|
|
||||||
f.write(subscription)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Proxmox VE
|
# check if the key format is correct
|
||||||
if os.path.exists("/etc/pve"):
|
pattern = re.compile(subscription_pattern)
|
||||||
print("Activating Proxmox VE...")
|
if not pattern.match(key):
|
||||||
activate_pve_pmg(lic_pve, "/etc/subscription")
|
print("key format error", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# Proxmox Mail Gateway
|
# get machine ID
|
||||||
if os.path.exists("/etc/pmg"):
|
server_id = ""
|
||||||
print("Activating Proxmox Mail Gateway...")
|
with open(server_key_file, "r") as f:
|
||||||
activate_pve_pmg(lic_pmg, "/etc/pmg/subscription")
|
server_id = generate_server_id(f.read())
|
||||||
|
|
||||||
|
# generate a license file
|
||||||
|
subscription = generate_subscription(key, [server_id])
|
||||||
|
|
||||||
|
# write license file
|
||||||
|
with open(subscription_file, "w") as f:
|
||||||
|
f.write(subscription)
|
||||||
|
|
||||||
# Proxmox Backup Server
|
|
||||||
if os.path.exists("/etc/proxmox-backup"):
|
|
||||||
print("Activating Proxmox Backup Server...")
|
|
||||||
activate_pbs(lic_pbs, "/etc/proxmox-backup/subscription")
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
enable pve-fake-subscription.timer
|
|
||||||
@ -4,3 +4,4 @@ Description=Fake a Proxmox VE subscription
|
|||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/bin/pve-fake-subscription
|
ExecStart=/usr/bin/pve-fake-subscription
|
||||||
|
|
||||||
|
|||||||
@ -10,3 +10,4 @@ Persistent=true
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy=timers.target
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|
||||||
Upstream-Name: pve-fake-subscription
|
|
||||||
Source: https://github.com/Jamesits/pve-fake-subscription
|
|
||||||
|
|
||||||
Files: *
|
|
||||||
Copyright: 2019 Nobody
|
|
||||||
License: GLWTS(Good Luck With That Shit) Public License
|
|
||||||
Loading…
Reference in New Issue
Block a user