Compare commits

...

3 Commits

Author SHA1 Message Date
James Swineson
7f8200b83a doc: binary is now automatically invoked during post install, so no need to wait 2022-12-19 17:35:35 +08:00
James Swineson
6168590598
Update README.md 2022-12-19 17:33:04 +08:00
James Swineson
82850c151b ditch fpm and use nfpm from now on (as per #3 and #9) 2022-12-19 17:21:24 +08:00
11 changed files with 187 additions and 27 deletions

2
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.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
@ -193,4 +194,3 @@ $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

View File

@ -1,3 +1,7 @@
# pve-fake-subscription
![JavaScript free](https://img.shields.io/badge/JavaScript-free-%09%23f7df1e "No JavaScript is involved in this project. ")
Disables the "No valid subscription" dialog on all Proxmox products. 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. > I am really poor and I can't afford a license. I just want to get rid of the annoying dialog.
@ -5,18 +9,20 @@ 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.2) - 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)
Highlights: Highlights:
- Non-intrusive: zero modification of any system file - Non-intrusive: zero modification of any system file
- Future-proof: persists between system updates & major upgrades - Future-proof: persists between system updates & major upgrades
- Hassle-free: you can uninstall at any time - Hassle-free: you can uninstall at any time
- Comes with standard Debian package, easy to manage and automate - 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 - **No JavaScript is involved** in the whole process, as I believe JavaScript is harmful to developers
## Installation ## Installation / Usage
1. [Download the latest release](https://github.com/Jamesits/pve-fake-subscription/releases/latest) 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. Install: run `dpkg -i pve-fake-subscription_*.deb` as root on every node
@ -24,11 +30,10 @@ Highlights:
Notes: 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`.
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)
- [Proxmox Mail Gateway (PMG)](https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html#pmg_package_repositories) - [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) - [Proxmox Backup Server (PBS)](https://pbs.proxmox.com/docs/installation.html#proxmox-backup-no-subscription-repository)
@ -45,10 +50,8 @@ This will revert your system to a "no subscription key" status.
## Building the Package ## Building the Package
Run everything as root on a Debian 10 system: Install [nFPM](https://nfpm.goreleaser.com/install/), then:
```shell ```shell
apt-get install ruby ruby-dev rubygems build-essential
gem install fpm
./package.sh ./package.sh
``` ```

40
nfpm.yaml Normal file
View File

@ -0,0 +1,40 @@
name: "pve-fake-subscription"
arch: "all"
platform: "linux"
version: "0.0.9"
version_schema: "semver"
version_metadata: "git"
epoch: 0
release: 1
section: "admin"
priority: "optinal"
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"

View File

@ -2,20 +2,15 @@
set -Eeuo pipefail set -Eeuo pipefail
cd "$( dirname "${BASH_SOURCE[0]}" )" || exit 1 cd "$( dirname "${BASH_SOURCE[0]}" )" || exit 1
fpm -s dir -t deb --force \ OUT_DIR="out"
-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" \
--url "https://github.com/Jamesits/pve-fake-subscription" \
-v 0.0.8 \
--license "GLWTS(Good Luck With That Shit) Public License" \
--depends "python3" \
--architecture all \
--deb-dist "unstable" \
--deb-priority "optional" \
--deb-systemd "usr/lib/systemd/system/pve-fake-subscription.timer" \
--deb-systemd-enable --deb-systemd-auto-start --deb-systemd-restart-after-upgrade \
--after-remove "scripts/purge" \
./usr
# temporary removed as of https://github.com/jordansissel/fpm/issues/1472 rm -rf "${OUT_DIR}"
#--deb-after-purge "scripts/purge" \ mkdir -p "${OUT_DIR}"
# build package
nfpm pkg --packager deb --target "${OUT_DIR}"
# generate checksum
pushd "${OUT_DIR}" >/dev/null
sha256sum -b -- * > sha256sum.txt
popd >/dev/null

48
scripts/postinst Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
after_upgrade() {
:
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
pve-fake-subscription
}
after_install() {
:
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
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

41
scripts/postrm Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
after_remove() {
:
rm -f /etc/subscription
rm -f /etc/pmg/subscription
rm -f /etc/proxmox-backup/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

29
scripts/prerm Executable file
View File

@ -0,0 +1,29 @@
#!/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

View File

@ -1,3 +0,0 @@
rm -f /etc/subscription
rm -f /etc/pmg/subscription
rm -f /etc/proxmox-backup/subscription

View File

@ -0,0 +1 @@
enable pve-fake-subscription.timer

View File

@ -4,4 +4,3 @@ Description=Fake a Proxmox VE subscription
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/bin/pve-fake-subscription ExecStart=/usr/bin/pve-fake-subscription

View File

@ -0,0 +1,7 @@
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