Compare commits

...

2 Commits

Author SHA1 Message Date
James Swineson
68fe060029 fix line ending issue 2022-09-16 09:11:36 +08:00
James Swineson
c83063441d fix compatibility issue on PVE 7.2-11 (#4) 2022-09-16 09:05:14 +08:00
3 changed files with 16 additions and 13 deletions

View File

@ -5,7 +5,7 @@ Disables the "No valid subscription" dialog on all Proxmox products.
## Features ## Features
Works for: Works for:
- Proxmox VE (5.x or later, tested up to 7.0) - Proxmox VE (5.x or later, tested up to 7.2)
- Proxmox Mail Gateway (5.x or later) - Proxmox Mail Gateway (5.x or later)
- Proxmox Backup Server (1.x) - Proxmox Backup Server (1.x)
@ -26,7 +26,7 @@ Notes:
The initial run will be scheduled within 1 minute of the installation. If you don't want to wait, you can invoke it immediately by executing `pve-fake-subscription`. The initial run will be scheduled within 1 minute of the installation. If you don't want to wait, you can invoke it immediately by executing `pve-fake-subscription`.
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. 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: 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 VE (PVE)](https://pve.proxmox.com/wiki/Package_Repositories#sysadmin_no_subscription_repo)
@ -49,6 +49,6 @@ Run everything as root on a Debian 10 system:
```shell ```shell
apt-get install ruby ruby-dev rubygems build-essential apt-get install ruby ruby-dev rubygems build-essential
gem install --no-ri --no-rdoc fpm gem install fpm
./package.sh ./package.sh
``` ```

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
set -Eeuo pipefail
cd "$( dirname "${BASH_SOURCE[0]}" )" cd "$( dirname "${BASH_SOURCE[0]}" )" || exit 1
fpm -s dir -t deb --force \ fpm -s dir -t deb --force \
-n pve-fake-subscription \ -n pve-fake-subscription \
--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" \ --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" \
--url "https://github.com/Jamesits/pve-fake-subscription" \ --url "https://github.com/Jamesits/pve-fake-subscription" \
-v 0.0.7 \ -v 0.0.8 \
--license "GLWTS(Good Luck With That Shit) Public License" \ --license "GLWTS(Good Luck With That Shit) Public License" \
--depends "python3" \ --depends "python3" \
--architecture all \ --architecture all \

View File

@ -22,16 +22,19 @@ def get_timestamp() -> int:
return int(time.time()) return int(time.time())
# Perl's md5_base64 implementation # Perl's md5_base64 implementation
def md5_base64_perl(x: str) -> str: def md5_base64_perl(x: str) -> str:
return base64.b64encode(hashlib.md5(x.encode()).digest()).strip(b'=').decode() return base64.b64encode(hashlib.md5(x.encode()).digest()).strip(b'=').decode()
# Rust's `base64::encode(tools::md5sum("something")?);` # Rust's `base64::encode(tools::md5sum("something")?);`
def md5_base64_rs(x: str) -> str: def md5_base64_rs(x: str) -> str:
return base64.b64encode(hashlib.md5(x.encode()).digest()).decode() return base64.b64encode(hashlib.md5(x.encode()).digest()).decode()
def generate_server_id(key: str) -> str: def generate_server_id(key: str) -> str:
return hashlib.md5(key.encode()).hexdigest().upper() return hashlib.md5(key.encode()).hexdigest().upper()
def dt_string(format: str, offset_secs: int = 0) -> str:
return (datetime.now() + timedelta(seconds=offset_secs)).strftime(format)
def generate_subscription_pve_pmg(key: str, server_ids: List[str]) -> str: def generate_subscription_pve_pmg(key: str, server_ids: List[str]) -> str:
localinfo = { localinfo = {
"checktime": get_timestamp(), "checktime": get_timestamp(),
@ -39,8 +42,8 @@ def generate_subscription_pve_pmg(key: str, server_ids: List[str]) -> str:
"key": key, "key": key,
"validdirectory": ",".join(server_ids), "validdirectory": ",".join(server_ids),
"productname": "YajuuSenpai", "productname": "YajuuSenpai",
"regdate": get_timestamp(), "regdate": dt_string("%Y-%m-%d %H:%M:%S"),
"nextduedate": 2147483647, "nextduedate": dt_string("%Y-%m-%d", 1296000),
} }
data = base64.standard_b64encode(json.dumps(localinfo).encode()).decode() data = base64.standard_b64encode(json.dumps(localinfo).encode()).decode()
@ -79,8 +82,8 @@ def generate_subscription_pbs(key: str, server_ids: List[str]) -> str:
"key": key, "key": key,
"message": "Yajuu Senpai has got your back", "message": "Yajuu Senpai has got your back",
"productname": "YajuuSenpai", "productname": "YajuuSenpai",
"regdate": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "regdate": dt_string("%Y-%m-%d %H:%M:%S"),
"nextduedate": (datetime.now() + timedelta(seconds=1296000)).strftime("%Y-%m-%d"), # 1296000: MAX_LOCAL_KEY_AGE in src/tools/subscription.rs "nextduedate": dt_string("%Y-%m-%d", 1296000), # 1296000: MAX_LOCAL_KEY_AGE in src/tools/subscription.rs
"url": "https://github.com/Jamesits/pve-fake-subscription", "url": "https://github.com/Jamesits/pve-fake-subscription",
} }
@ -114,7 +117,7 @@ if __name__ == "__main__":
if os.path.exists("/etc/pmg"): if os.path.exists("/etc/pmg"):
print("Activating Proxmox Mail Gateway...") print("Activating Proxmox Mail Gateway...")
activate_pve_pmg("pmgp-1145141919", "/etc/pmg/subscription") activate_pve_pmg("pmgp-1145141919", "/etc/pmg/subscription")
# Proxmox Backup Server # Proxmox Backup Server
if os.path.exists("/etc/proxmox-backup"): if os.path.exists("/etc/proxmox-backup"):
print("Activating Proxmox Backup Server...") print("Activating Proxmox Backup Server...")