Initial release

This commit is contained in:
Jamie Ralph 2026-08-01 19:37:20 +01:00
commit 39397c1a05
17 changed files with 411 additions and 0 deletions

23
.github/workflows/build.yml vendored Normal file
View File

@ -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

26
.github/workflows/release.yml vendored Normal file
View File

@ -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

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
dist/*.deb
*.buildinfo
*.changes
*.upload

21
LICENSE Normal file
View File

@ -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.

93
README.md Normal file
View File

@ -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.

25
build.sh Executable file
View File

@ -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"

16
install.sh Executable file
View File

@ -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"

2
package/DEBIAN/conffiles Normal file
View File

@ -0,0 +1,2 @@
/etc/pve-gui-sensors-auto/config
/etc/apt/apt.conf.d/99-pve-gui-sensors-auto

12
package/DEBIAN/control Normal file
View File

@ -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 <local@localhost>
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.

6
package/DEBIAN/md5sums Normal file
View File

@ -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

10
package/DEBIAN/postinst Executable file
View File

@ -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

View File

@ -0,0 +1,3 @@
DPkg::Post-Invoke {
"/usr/local/sbin/pve-gui-sensors-refresh --quiet || true";
};

View File

@ -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"

View File

@ -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 <<USAGE
Usage: pve-gui-sensors-refresh [--quiet] [--force] [--status]
--quiet Log to file without normal terminal output
--force Re-run installer after confirming files are unpatched
--status Report patch state and exit
USAGE
}
MODE="refresh"
while (($#)); do
case "$1" in
--quiet) QUIET=1 ;;
--force) FORCE=1 ;;
--status) MODE="status" ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown option: $1" >&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."

View File

@ -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

View File

@ -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.

View File

@ -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.