8 Commits
Author SHA1 Message Date
Scott B 7ace374dfe prettied up installer output 2020-01-22 04:19:57 -08:00
Scott B be8176180b Updated README 2020-01-21 20:40:01 -08:00
Scott B c94ebe1cc4 patch: refuse to install on non-debian systems 2020-01-21 19:57:18 -08:00
Scott B 235e99056f fixup make-release 2020-01-21 05:50:17 -08:00
Scott B c567d211d5 Updated README 2020-01-21 02:44:37 -08:00
Scott B 27cf664aeb version 3 draft: POSIX shell port 2020-01-21 02:15:44 -08:00
Scott B fe28b7c099 version 3 draft: install.sh rewrite, added install/uninstall routines 2020-01-21 02:15:44 -08:00
Scott B 9f3a23fc88 code cleanup: codefmt pass 2020-01-21 02:12:05 -08:00
4 changed files with 250 additions and 90 deletions

No files matched your search

+89 -9
View File
@@ -1,19 +1,99 @@
pve-nag-buster # pve-nag-buster
Persistent license nag removal for Proxmox VE 5.x https://github.com/foundObjects/pve-nag-buster
A bash script and dpkg pre/post install hooks to persistently remove the license nags from Proxmox VE 5.x. This is a dpkg post install hook script that persistently removes license nags
from Proxmox VE 5.x and up. Install it once and you won't see another license
nag until Proxmox changes their web-ui code significantly.
The main script does two things: it removes the "unlicensed node" popup nag from the web gui and it switches repositories from pve-enterprise to pve-no-subscription. The script is called every time a package updates the web gui or the Please support the Proxmox team by [buying a subscription](https://www.proxmox.com/en/proxmox-ve/pricing) if it's within your
pve-enterprise source list and will only run if packages containing those files are changed. There are no external dependencies beyond the base packages installed with PVE by default (awk, sed, grep, wget). means. High quality open source software like Proxmox needs our support!
For your convenience the install script also contains a base64 encoded copy of pve-nag-buster.sh for use offline. I'd have just packed everything into install.sh by default but making everyone download, unxz and base64 decode a HEREDOC to look at my code seemed rude. ### How does it work?
To install: The included hook script removes the "unlicensed node" popup nag from the web
gui and disables the pve-enterprise repository list. This script is called
every time a package updates the web gui or the pve-enterprise source list and
will only run if packages containing those files are changed. The installer
drops the hook script and creates dpkg hooks to call it then adds the
pve-no-subscription repo list. There are no external dependencies beyond the
base packages installed with PVE by default (awk, sed, grep, wget).
### Installation
``` ```
wget https://raw.githubusercontent.com/foundObjects/pve-nag-buster/master/install.sh wget https://raw.githubusercontent.com/foundObjects/pve-nag-buster/master/install.sh
# Read the script # Always read scripts downloaded from the internet before running them with sudo
chmod +x install.sh && ./install.sh chmod +x install.sh && sudo ./install.sh
``` ```
With Git:
```
git clone https://github.com/foundObjects/pve-nag-buster.git
# Always read scripts downloaded from the internet before running them with sudo
cd pve-nag-buster && sudo ./install.sh
```
### Uninstall:
```
./install.sh --uninstall
# remove /etc/apt/sources.list.d/pve-no-subscription.list if desired
```
### Notes:
#### Why is there base64 in my peanut-butter?
For convenience the install script also contains a base64 encoded copy of the
hook script, this makes installation possible without access to github or a
full clone of the project directory.
To inspect the base64 encoded script run `./install.sh --emit`; this dumps the
encoded copy to stdout and quits. To install using the stored copy just run
`sudo ./install.sh --offline`, no internet required.
#### Git repo history
Sorry to all 5 of you who forked the repo before about 2020-01-20; I rewrote
git history to cleanup the commit noise from adding files through GitHub's web
UI.
If you need to sync a cloned repo with the new history and haven't made any
changes:
```
git fetch --all -p -P
git push -f . origin/master:master
```
If you've made changes to the code:
Migrating to the new master branch should be fairly straightforward, the v02
tag repo state in the new commit history is identical to the repo state before
the rebase.
```
# save and commit your work
git commit -a -m "WIP"
# make a backup of your branch Just In Case™
git checkout -b backup
git checkout -
git fetch --all
git rebase -f --onto v02 origin/old-master <your branch here>
```
I highly recommend picking at least the following bugfix commits if you don't
want to track new work in master, they fix a couple of potential problems.
* a260891 hook script: fixed grep test issue
* 427b23b more reliable hook trigger removal
### Credits:
Thanks to John McLaren for his [blog post](https://www.reddit.com/user/seaqueue) documenting the web gui patch:
### Contact:
[Open an issue](https://github.com/foundObjects/pve-nag-buster/issues) on GitHub or contact me as [/u/SeaQueue on Reddit](https://www.reddit.com/user/seaqueue).
Please get in touch if you find a way to improve anything, otherwise enjoy! Please get in touch if you find a way to improve anything, otherwise enjoy!
+146 -61
View File
@@ -1,9 +1,10 @@
#!/bin/bash #!/bin/sh
case "$(readlink /proc/$$/exe)" in */bash) set -euo pipefail ;; *) set -eu ;; esac
# pve-nag-buster (v02a) https://github.com/foundObjects/pve-nag-buster # pve-nag-buster (v03) https://github.com/foundObjects/pve-nag-buster
# Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue) # Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue)
# #
# Removes Proxmox VE 5.x license nags automatically after updates # Removes Proxmox VE 5.x+ license nags automatically after updates
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -19,73 +20,157 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
RELEASE=$(awk -F"[)(]+" '/VERSION=/ {print $2}' /etc/os-release) # ensure a predictable environment
PATH=/usr/sbin:/usr/bin:/sbin:/bin
\unalias -a
# create the pve-no-subscription list # installer main body:
_main() {
echo "$0: Creating PVE no-subscription repo list ..." # ensure $1 exists so 'set -u' doesn't error out
cat <<EOF>"/etc/apt/sources.list.d/pve-no-subscription.list" { [ "$#" -eq "0" ] && set -- ""; } > /dev/null 2>&1
# .list file automatically generated by pve-nag-buster:$0 at $(date)
#
# If $0 is run again this file will likely be overwritten
#
deb http://download.proxmox.com/debian/pve $RELEASE pve-no-subscription
EOF
# create dpkg pre/post install hooks for persistence
cat <<'EOF' >/etc/apt/apt.conf.d/86pve-nags
DPkg::Pre-Install-Pkgs {
"while read -r pkg; do case $pkg in *proxmox-widget-toolkit* | *pve-manager*) touch /tmp/.pve-nag-buster && exit 0; esac done < /dev/stdin";
};
DPkg::Post-Invoke {
"[ -f /tmp/.pve-nag-buster ] && { /usr/share/pve-nag-buster.sh; rm -f /tmp/.pve-nag-buster; }; exit 0";
};
EOF
# fetch the post-install patch script, patches license nag and switches to pve-no-subscription repository as needed
if true ; then
wget https://raw.githubusercontent.com/foundObjects/pve-nag-buster/v02-tracking/pve-nag-buster.sh \
-O "/usr/share/pve-nag-buster.sh" && \
chmod +x "/usr/share/pve-nag-buster.sh" && \
/usr/share/pve-nag-buster.sh
case "$1" in
"--emit")
# call the emit_script() function to stdout and exit, use this to verify
# that the base64 encoded script below isn't doing anything malicious
# does not require root
emit_script
;;
"--uninstall")
# uninstall, requires root
assert_root
_uninstall
;;
"--install" | "--offline" | "")
# install dpkg hooks, requires root
assert_root
_install "$@"
;;
*)
# unknown flags, print usage and exit
_usage
;;
esac
exit 0 exit 0
fi }
# this is the end, example offline code below _uninstall() {
set -x
[ -f "/etc/apt/apt.conf.d/86pve-nags" ] &&
rm -f "/etc/apt/apt.conf.d/86pve-nags"
[ -f "/usr/share/pve-nag-buster.sh" ] &&
rm -f "/usr/share/pve-nag-buster.sh"
# Example code for inclusion into host provisioning scripts offline: this is just pve-nag-buster.sh echo "Script and dpkg hooks removed, please manually remove /etc/apt/sources.list.d/pve-no-subscription.list if desired"
# run through "xz -z -9 -c pve-nag-buster.sh | base64" to avoid needing to fetch the script from github }
# To use this installer offline just nuke the entire if block above.
_install() {
# create hooks and no-subscription repo list, install hook script, run once
VERSION_CODENAME=''
ID=''
. /etc/os-release
case "$ID" in
"debian")
if [ -n "$VERSION_CODENAME" ]; then
RELEASE="$VERSION_CODENAME"
else
RELEASE=$(awk -F"[)(]+" '/VERSION=/ {print $2}' /etc/os-release)
fi
;;
#"ubuntu") # it doesn't look like this is possible anymore
# ;;
*)
echo "Sorry, I don't know how to handle your Linux distribution '$ID'"
exit 1
;;
esac
# create the pve-no-subscription list
echo "Creating PVE no-subscription repo list ..."
cat <<- EOF > "/etc/apt/sources.list.d/pve-no-subscription.list"
# .list file automatically generated by pve-nag-buster at $(date)
#
# If pve-nag-buster is installed again this file will be overwritten
#
deb http://download.proxmox.com/debian/pve $RELEASE pve-no-subscription
EOF
# create dpkg pre/post install hooks for persistence
echo "Creating dpkg hooks in /etc/apt/apt.conf.d ..."
cat <<- 'EOF' > "/etc/apt/apt.conf.d/86pve-nags"
DPkg::Pre-Install-Pkgs {
"while read -r pkg; do case $pkg in *proxmox-widget-toolkit* | *pve-manager*) touch /tmp/.pve-nag-buster && exit 0; esac done < /dev/stdin";
};
DPkg::Post-Invoke {
"[ -f /tmp/.pve-nag-buster ] && { /usr/share/pve-nag-buster.sh; rm -f /tmp/.pve-nag-buster; }; exit 0";
};
EOF
# install the hook script
temp=''
if [ "$1" = "--offline" ]; then
# packed script requested
temp="$(mktemp)" && trap "rm -f $temp" EXIT
emit_script > "$temp"
elif [ -f "pve-nag-buster.sh" ]; then
# local copy available
temp="pve-nag-buster.sh"
else
# fetch from github
echo "Fetching hook script from GitHub ..."
tempd="$(mktemp -d)" &&
trap "echo 'Cleaning up temporary files ...'; rm -f $tempd/*; rmdir $tempd" EXIT
temp="$tempd/pve-nag-buster.sh"
wget https://raw.githubusercontent.com/foundObjects/pve-nag-buster/master/pve-nag-buster.sh \
-q --show-progress -O "$temp"
fi
echo "Installing hook script as /usr/share/pve-nag-buster.sh"
install -o root -m 0550 "$temp" "/usr/share/pve-nag-buster.sh"
echo "Running patch script"
/usr/share/pve-nag-buster.sh
return 0
}
# emit a stored copy of pve-nag-buster.sh offline -- this is intended to be used during
# offline provisioning where we don't have access to github or a full cloned copy of the
# project
# run 'install.sh --emit' to dump stored script to stdout
# Important: if you're not me you should probably decode this and read it to make sure I'm not doing # Important: if you're not me you should probably decode this and read it to make sure I'm not doing
# something malicious like mining dogecoin or stealing your valuable cat pictures # something malicious like mining dogecoin or stealing your valuable cat pictures
# pve-nag-buster.sh (v02a) inline: # pve-nag-buster.sh (v03) encoded below:
base64 -d << 'YEET' | unxz > "/usr/share/pve-nag-buster.sh" emit_script() {
/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4AXRA3pdABGIQkY99Bhqpmevep/kIs9shoiNvzAP074w base64 -d << 'YEET' | unxz
LI3FnbhLtpij4weS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DVyjoaEkC9pTzwPvDkiJA+0cFEydxEOfMqvG3HMCcKIPN+EMh0tW Iuf4iF+nbiIhXIN8xfaBSOFUwxcANeaOxYLMfjMS05v1NtMOqEdIYzVXni0DHqtxs9dQaaM/jC4S
Vm9ABSQn4A9kAAAAxDleg/tFU5sAAZYH0gsAAGBjQjqxxGf7AgAAAAAEWVo= mwrfKTTLKCewSTGVsFSOGNPwOAM5/Fxu3snKRlYeLwKC7uq9uTFR/L64HzG0TPfjmkH24hNsuhe7
JtcdlRcbL5rHN9C5PNOpCqcEeRDmVsS0sgAAAMwFRS7YkAXGAAGmB/cLAADBO9SpscRn+wIAAAAA
BFla
YEET YEET
chmod +x "/usr/share/pve-nag-buster.sh" }
/usr/share/pve-nag-buster.sh
assert_root() { [ "$(id -u)" -eq '0' ] || { echo "This action requires root." && exit 1; }; }
_usage() { echo "Usage: $(basename "$0") (--emit|--offline|--uninstall)"; }
_main "$@"
+6 -12
View File
@@ -1,22 +1,16 @@
#!/bin/sh #!/bin/sh
_VERS="v02a" _VERS="v03"
_BRANCH=$(git branch --show-current) || _BRANCH=$(git branch --show-current) >/dev/null 2>&1 ||
{ echo "can't poll branch, defaulting to master" && _BRANCH="master"; } { echo "can't poll branch, defaulting to master" && _BRANCH="master"; }
# update versions before packing install.sh # update versions before packing install.sh
sed -i \ sed -i -r \
-e "s;(v[[:digit:]][[:digit:]]);($_VERS);" \ -e "s;\(v[[:digit:]][[:digit:]].?\);\($_VERS\);" \
-e "s;nag-buster/.*/;nag-buster/$_BRANCH/;" \ -e "s;(nag-buster/).*(/(pve-nag-buster|install)\.sh);\1$_BRANCH\2;" \
pve-nag-buster.sh install.sh README.md pve-nag-buster.sh install.sh README.md
#sed -i -e "s/([v[[:digit:]][[:digit:]])/($_VERS)/" pve-nag-buster.sh install.sh
#sed -i -e "s;nag-buster/.*/;nag-buster/$_BRANCH/;" install.sh README.md
# I have no idea what I'm doing 🐶 # TODO there's probably a two liner to handle all of this in awk:
#awk 'FNR==NR{s=(!s)?$0:s RS $0;next} /__BASE64__/{sub(/__BASE64__/, s)} 1' \
# <(xz -z -9 -c pve-nag-buster.sh | base64) src/install > install.sh
# TODO: there's probably a two liner to handle all of this in awk
# pack install.sh # pack install.sh
{ {
+9 -8
View File
@@ -1,9 +1,9 @@
#!/bin/bash #!/bin/sh
# #
# pve-nag-buster.sh (v02a) https://github.com/foundObjects/pve-nag-buster # pve-nag-buster.sh (v03) https://github.com/foundObjects/pve-nag-buster
# Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue) # Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue)
# #
# Removes Proxmox VE 5.x license nags automatically after updates # Removes Proxmox VE 5.x+ license nags automatically after updates
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@@ -21,13 +21,14 @@
NAGTOKEN="data.status !== 'Active'" NAGTOKEN="data.status !== 'Active'"
NAGFILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js" NAGFILE="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js"
SCRIPT="$(basename $0)"
# disable license nag: https://johnscs.com/remove-proxmox51-subscription-notice/ # disable license nag: https://johnscs.com/remove-proxmox51-subscription-notice/
if grep -qs "$NAGTOKEN" "$NAGFILE" > /dev/null 2>&1; then if grep -qs "$NAGTOKEN" "$NAGFILE" > /dev/null 2>&1; then
echo "$0: Removing Nag ..." echo "$SCRIPT: Removing Nag ..."
sed -i.orig "s/$NAGTOKEN/false/g" "$NAGFILE" sed -i.orig "s/$NAGTOKEN/false/g" "$NAGFILE"
systemctl restart pveproxy.service systemctl restart pveproxy.service
fi fi
# disable paid repo list # disable paid repo list
@@ -35,6 +36,6 @@ fi
PAID_BASE="/etc/apt/sources.list.d/pve-enterprise" PAID_BASE="/etc/apt/sources.list.d/pve-enterprise"
if [ -f "$PAID_BASE.list" ]; then if [ -f "$PAID_BASE.list" ]; then
echo "$0: Disabling PVE paid repo list ..." echo "$SCRIPT: Disabling PVE paid repo list ..."
mv -f "$PAID_BASE.list" "$PAID_BASE.disabled" mv -f "$PAID_BASE.list" "$PAID_BASE.disabled"
fi fi