From 39397c1a05444b58481bd5f3ca365263c5f5ca82 Mon Sep 17 00:00:00 2001 From: Jamie Ralph Date: Sat, 1 Aug 2026 19:37:20 +0100 Subject: [PATCH] Initial release --- .github/workflows/build.yml | 23 ++++ .github/workflows/release.yml | 26 ++++ .gitignore | 4 + LICENSE | 21 +++ README.md | 93 ++++++++++++++ build.sh | 25 ++++ install.sh | 16 +++ package/DEBIAN/conffiles | 2 + package/DEBIAN/control | 12 ++ package/DEBIAN/md5sums | 6 + package/DEBIAN/postinst | 10 ++ .../apt/apt.conf.d/99-pve-gui-sensors-auto | 3 + package/etc/pve-gui-sensors-auto/config | 9 ++ .../usr/local/sbin/pve-gui-sensors-refresh | 121 ++++++++++++++++++ .../usr/local/sbin/pve-gui-sensors-uninstall | 11 ++ .../doc/pve-gui-sensors-auto/README.Debian | 18 +++ .../share/doc/pve-gui-sensors-auto/copyright | 11 ++ 17 files changed, 411 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100755 build.sh create mode 100755 install.sh create mode 100644 package/DEBIAN/conffiles create mode 100644 package/DEBIAN/control create mode 100644 package/DEBIAN/md5sums create mode 100755 package/DEBIAN/postinst create mode 100644 package/etc/apt/apt.conf.d/99-pve-gui-sensors-auto create mode 100644 package/etc/pve-gui-sensors-auto/config create mode 100755 package/usr/local/sbin/pve-gui-sensors-refresh create mode 100755 package/usr/local/sbin/pve-gui-sensors-uninstall create mode 100644 package/usr/share/doc/pve-gui-sensors-auto/README.Debian create mode 100644 package/usr/share/doc/pve-gui-sensors-auto/copyright diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..89785c2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build Debian package + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build package + run: ./build.sh + - name: Upload package artifact + uses: actions/upload-artifact@v4 + with: + name: pve-gui-sensors-auto + path: dist/*.deb diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1711720 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release Debian package + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Verify tag matches package version + run: | + version=$(awk '$1=="Version:" {print $2}' package/DEBIAN/control) + test "v$version" = "${GITHUB_REF_NAME}" + - name: Build package + run: ./build.sh + - name: Create GitHub release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + files: dist/*.deb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61c5d5a --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +dist/*.deb +*.buildinfo +*.changes +*.upload diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9541e78 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Jamie Ralph + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..290ea8b --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# pve-gui-sensors-auto + +A small Debian package that automatically reapplies the Meliox Proxmox VE GUI sensor modification after Proxmox package upgrades replace the patched files. + +This repository does **not** redistribute the Meliox installer. When a refresh is required, it downloads the installer from the official [`Meliox/PVE-mods`](https://github.com/Meliox/PVE-mods) repository. + +## Defaults + +- Average temperature per CPU +- Show fans reporting zero RPM +- Celsius +- UPS information disabled +- System information layout `1` + +Settings are stored in: + +```text +/etc/pve-gui-sensors-auto/config +``` + +## Install from a release + +Download the latest `.deb` from **Releases**, then run: + +```bash +apt install ./pve-gui-sensors-auto_*_all.deb +``` + +To avoid APT's harmless `_apt` warning, place the file in `/tmp` rather than `/root`: + +```bash +cp pve-gui-sensors-auto_*_all.deb /tmp/ +apt install /tmp/pve-gui-sensors-auto_*_all.deb +``` + +## Commands + +```bash +pve-gui-sensors-refresh --status +pve-gui-sensors-refresh +pve-gui-sensors-uninstall +``` + +Logs are written to: + +```text +/var/log/pve-gui-sensors-auto.log +``` + +## How it works + +The package installs an APT `DPkg::Post-Invoke` hook. After package operations it checks both Proxmox files modified by the upstream sensor script: + +```text +/usr/share/pve-manager/js/pvemanagerlib.js +/usr/share/perl5/PVE/API2/Nodes.pm +``` + +- If both are patched, it exits without changes. +- If both are clean, it downloads the current upstream installer and reapplies the saved choices. +- If only one file appears patched, it refuses to proceed to avoid compounding a partial modification. + +## Build locally + +On Debian or Proxmox VE: + +```bash +sudo apt install dpkg-dev +./build.sh +``` + +The package is written to `dist/`. + +## Publish a release + +1. Update `Version:` in `package/DEBIAN/control`. +2. Commit and push. +3. Create and push a matching tag: + +```bash +git tag v1.1.0 +git push origin v1.1.0 +``` + +GitHub Actions will build the package and attach it to a GitHub Release. + +## Important limitations + +This package modifies files owned by Proxmox packages. A major Proxmox UI or API change may require an update to the upstream Meliox installer. Always keep normal Proxmox backups and verify the GUI after significant upgrades. + +## Licence + +The automation package is MIT licensed. The downloaded Meliox installer remains subject to its own licence and copyright terms. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..2c16080 --- /dev/null +++ b/build.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PKGDIR="$ROOT/package" +DIST="$ROOT/dist" + +PACKAGE="$(awk '$1=="Package:" {print $2}' "$PKGDIR/DEBIAN/control")" +VERSION="$(awk '$1=="Version:" {print $2}' "$PKGDIR/DEBIAN/control")" +ARCH="$(awk '$1=="Architecture:" {print $2}' "$PKGDIR/DEBIAN/control")" +OUTPUT="$DIST/${PACKAGE}_${VERSION}_${ARCH}.deb" + +mkdir -p "$DIST" +rm -f "$PKGDIR/DEBIAN/md5sums" +( + cd "$PKGDIR" + find . -type f ! -path './DEBIAN/*' -print0 \ + | sort -z \ + | xargs -0 md5sum \ + | sed 's# \./# #' > DEBIAN/md5sums +) + +chmod 755 "$PKGDIR/DEBIAN/postinst" "$PKGDIR/usr/local/sbin/"* +dpkg-deb --root-owner-group --build "$PKGDIR" "$OUTPUT" +echo "$OUTPUT" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..78d1093 --- /dev/null +++ b/install.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO="${REPO:-JamieRalph/pve-gui-sensors-auto}" +API="https://api.github.com/repos/$REPO/releases/latest" +URL="$(curl -fsSL "$API" | grep -o 'https://[^" ]*_all\.deb' | head -n1)" + +if [[ -z "$URL" ]]; then + echo "Could not find a .deb asset in the latest release." >&2 + exit 1 +fi + +TMP="$(mktemp --suffix=.deb)" +trap 'rm -f "$TMP"' EXIT +curl -fL "$URL" -o "$TMP" +apt install -y "$TMP" diff --git a/package/DEBIAN/conffiles b/package/DEBIAN/conffiles new file mode 100644 index 0000000..bff331e --- /dev/null +++ b/package/DEBIAN/conffiles @@ -0,0 +1,2 @@ +/etc/pve-gui-sensors-auto/config +/etc/apt/apt.conf.d/99-pve-gui-sensors-auto diff --git a/package/DEBIAN/control b/package/DEBIAN/control new file mode 100644 index 0000000..c257fda --- /dev/null +++ b/package/DEBIAN/control @@ -0,0 +1,12 @@ +Package: pve-gui-sensors-auto +Version: 1.1.0 +Section: admin +Priority: optional +Architecture: all +Depends: bash, ca-certificates, curl, lm-sensors +Recommends: pve-manager +Maintainer: Jamie Ralph +Homepage: https://github.com/Meliox/PVE-mods +Description: Automatically maintain the Meliox Proxmox GUI sensor modification + Detects when Proxmox package upgrades replace the modified web UI and API + files, then reapplies the sensor display using saved non-interactive choices. diff --git a/package/DEBIAN/md5sums b/package/DEBIAN/md5sums new file mode 100644 index 0000000..19d344f --- /dev/null +++ b/package/DEBIAN/md5sums @@ -0,0 +1,6 @@ +223b52904dd1735cf3059d1b75e6f651 etc/apt/apt.conf.d/99-pve-gui-sensors-auto +62a144474796d99e86b765b7dd2562c8 etc/pve-gui-sensors-auto/config +73efbaec483522b2246641e2ba28d750 usr/local/sbin/pve-gui-sensors-refresh +0e62615b5ae61a7f2a25491c87090c77 usr/local/sbin/pve-gui-sensors-uninstall +8d97034195990b99dd289459bdcbd07c usr/share/doc/pve-gui-sensors-auto/README.Debian +dc8fa8e2ac5803063a8a3a593788c43e usr/share/doc/pve-gui-sensors-auto/copyright diff --git a/package/DEBIAN/postinst b/package/DEBIAN/postinst new file mode 100755 index 0000000..9504740 --- /dev/null +++ b/package/DEBIAN/postinst @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +case "${1:-}" in + configure) + mkdir -p /var/lib/pve-gui-sensors-auto /var/log + chmod 700 /var/lib/pve-gui-sensors-auto + /usr/local/sbin/pve-gui-sensors-refresh --quiet || true + ;; +esac +exit 0 diff --git a/package/etc/apt/apt.conf.d/99-pve-gui-sensors-auto b/package/etc/apt/apt.conf.d/99-pve-gui-sensors-auto new file mode 100644 index 0000000..ab263fe --- /dev/null +++ b/package/etc/apt/apt.conf.d/99-pve-gui-sensors-auto @@ -0,0 +1,3 @@ +DPkg::Post-Invoke { + "/usr/local/sbin/pve-gui-sensors-refresh --quiet || true"; +}; diff --git a/package/etc/pve-gui-sensors-auto/config b/package/etc/pve-gui-sensors-auto/config new file mode 100644 index 0000000..ae8fef8 --- /dev/null +++ b/package/etc/pve-gui-sensors-auto/config @@ -0,0 +1,9 @@ +# Saved installer choices +CPU_DISPLAY="a" +SHOW_ZERO_FANS="y" +TEMPERATURE_UNIT="c" +ENABLE_UPS="n" +SYSTEM_INFORMATION="1" + +# Official upstream installer. Change only if the project moves the script. +INSTALLER_URL="https://raw.githubusercontent.com/Meliox/PVE-mods/refs/heads/main/legacy-scripts/pve-mod-gui-sensors.sh" diff --git a/package/usr/local/sbin/pve-gui-sensors-refresh b/package/usr/local/sbin/pve-gui-sensors-refresh new file mode 100755 index 0000000..a59ff30 --- /dev/null +++ b/package/usr/local/sbin/pve-gui-sensors-refresh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +set -euo pipefail + +CONFIG="/etc/pve-gui-sensors-auto/config" +STATE_DIR="/var/lib/pve-gui-sensors-auto" +WORK_DIR="$STATE_DIR/upstream" +LOG="/var/log/pve-gui-sensors-auto.log" +PVE_JS="/usr/share/pve-manager/js/pvemanagerlib.js" +NODES_PM="/usr/share/perl5/PVE/API2/Nodes.pm" +QUIET=0 +FORCE=0 + +usage() { + cat <&2; usage >&2; exit 2 ;; + esac + shift +done + +mkdir -p "$STATE_DIR" "$WORK_DIR" +touch "$LOG" +chmod 700 "$STATE_DIR" + +log() { + printf '%s\n' "$*" >>"$LOG" + if [[ "$QUIET" -eq 0 ]]; then printf '%s\n' "$*"; fi +} + +if [[ ! -r "$CONFIG" ]]; then + log "ERROR: missing configuration: $CONFIG" + exit 1 +fi +# shellcheck disable=SC1090 +source "$CONFIG" + +for required in CPU_DISPLAY SHOW_ZERO_FANS TEMPERATURE_UNIT ENABLE_UPS SYSTEM_INFORMATION INSTALLER_URL; do + if [[ -z "${!required:-}" ]]; then + log "ERROR: missing setting $required in $CONFIG" + exit 1 + fi +done + +if [[ ! -f "$PVE_JS" || ! -f "$NODES_PM" ]]; then + log "INFO: Proxmox GUI files are not installed; nothing to do." + exit 0 +fi + +js=0; perl=0 +grep -q 'sensorsOutput' "$PVE_JS" && js=1 || true +grep -q 'sensorsOutput' "$NODES_PM" && perl=1 || true + +if [[ "$MODE" == "status" ]]; then + case "$js:$perl" in + 1:1) echo "installed" ;; + 0:0) echo "not-installed" ;; + *) echo "partial" ;; + esac + exit 0 +fi + +log "" +log "==================================================" +log "PVE GUI sensors check: $(date -Is)" +log "==================================================" + +if [[ "$js" -eq 1 && "$perl" -eq 1 && "$FORCE" -eq 0 ]]; then + log "Sensor modification is already fully installed." + exit 0 +fi + +if [[ "$js" -ne "$perl" ]]; then + log "ERROR: partial sensor modification detected." + log "Refusing to patch automatically; repair or restore the Proxmox files first." + exit 2 +fi + +if [[ "$FORCE" -eq 1 && "$js" -eq 1 ]]; then + log "ERROR: --force cannot overwrite an installed modification." + exit 2 +fi + +INSTALLER="$WORK_DIR/pve-mod-gui-sensors.sh" +TMP="$INSTALLER.tmp" +log "Downloading official Meliox installer..." +curl --fail --silent --show-error --location "$INSTALLER_URL" -o "$TMP" + +if ! grep -q 'pve-mod-gui-sensors' "$TMP" && ! grep -q 'sensors display mod' "$TMP"; then + log "ERROR: downloaded file does not look like the expected installer." + rm -f "$TMP" + exit 3 +fi + +mv "$TMP" "$INSTALLER" +chmod 700 "$INSTALLER" + +# Remove only the installer's old backup directory after confirming both target +# files are unpatched. This lets each Proxmox update create fresh compatible backups. +rm -rf "$WORK_DIR/backup" "$WORK_DIR/PVE-MODS" + +log "Applying saved choices: average CPU, zero-RPM fans shown, Celsius, UPS off, system information 1." +cd "$WORK_DIR" +printf '%s\n%s\n%s\n%s\n%s\n\n' \ + "$CPU_DISPLAY" "$SHOW_ZERO_FANS" "$TEMPERATURE_UNIT" "$ENABLE_UPS" "$SYSTEM_INFORMATION" \ + | bash "$INSTALLER" install + +systemctl restart pveproxy +log "Sensor modification successfully installed." diff --git a/package/usr/local/sbin/pve-gui-sensors-uninstall b/package/usr/local/sbin/pve-gui-sensors-uninstall new file mode 100755 index 0000000..6b7a4c4 --- /dev/null +++ b/package/usr/local/sbin/pve-gui-sensors-uninstall @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euo pipefail +WORK_DIR="/var/lib/pve-gui-sensors-auto/upstream" +INSTALLER="$WORK_DIR/pve-mod-gui-sensors.sh" +if [[ ! -x "$INSTALLER" ]]; then + echo "No saved upstream installer exists. Run a refresh first." >&2 + exit 1 +fi +cd "$WORK_DIR" +bash "$INSTALLER" uninstall +systemctl restart pveproxy diff --git a/package/usr/share/doc/pve-gui-sensors-auto/README.Debian b/package/usr/share/doc/pve-gui-sensors-auto/README.Debian new file mode 100644 index 0000000..764fa3b --- /dev/null +++ b/package/usr/share/doc/pve-gui-sensors-auto/README.Debian @@ -0,0 +1,18 @@ +pve-gui-sensors-auto +==================== + +Commands: + pve-gui-sensors-refresh Check and reapply when missing + pve-gui-sensors-refresh --status Show installed/not-installed/partial + pve-gui-sensors-uninstall Restore the latest saved clean files + +Configuration: + /etc/pve-gui-sensors-auto/config + +Log: + /var/log/pve-gui-sensors-auto.log + +The package downloads the installer from the official Meliox/PVE-mods GitHub +repository only when the modification needs to be applied. The installer edits +Proxmox-managed files, so a major Proxmox UI change may require an upstream +script update. diff --git a/package/usr/share/doc/pve-gui-sensors-auto/copyright b/package/usr/share/doc/pve-gui-sensors-auto/copyright new file mode 100644 index 0000000..b7da762 --- /dev/null +++ b/package/usr/share/doc/pve-gui-sensors-auto/copyright @@ -0,0 +1,11 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: pve-gui-sensors-auto +Source: local package + +Files: * +Copyright: 2026 Jamie Ralph +License: MIT + +This package does not redistribute the Meliox installer. It downloads it from +the official upstream repository when required. The upstream installer remains +subject to its own copyright and licence terms.