rework hook implementation to work on dpkg triggered
This commit is contained in:
parent
d9ff050676
commit
a7cef62574
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -80,4 +80,4 @@ jobs:
|
|||||||
--title "pve-mod $TAG" \
|
--title "pve-mod $TAG" \
|
||||||
--notes "$NOTES" \
|
--notes "$NOTES" \
|
||||||
"$DEB" \
|
"$DEB" \
|
||||||
"src/Scripts/install.sh"
|
"src/install.sh"
|
||||||
|
|||||||
4
.github/workflows/version-bump.yml
vendored
4
.github/workflows/version-bump.yml
vendored
@ -5,6 +5,10 @@ name: Version Bump
|
|||||||
# and opens (or updates) a "Release vX.Y.Z" PR to main.
|
# and opens (or updates) a "Release vX.Y.Z" PR to main.
|
||||||
# The changelog commit touches only debian/changelog (not src/),
|
# The changelog commit touches only debian/changelog (not src/),
|
||||||
# so it does not re-trigger this workflow.
|
# so it does not re-trigger this workflow.
|
||||||
|
#
|
||||||
|
# NOTE: GITHUB_TOKEN cannot push to forks, so this workflow only works for
|
||||||
|
# branches on the upstream repo (Meliox/PVE-mods). External contributors
|
||||||
|
# opening PRs from forks will not get an automatic version bump.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|||||||
34
debian/pve-mod.postinst
vendored
34
debian/pve-mod.postinst
vendored
@ -5,21 +5,16 @@ NODES_PM="/usr/share/perl5/PVE/API2/Nodes.pm"
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
configure)
|
configure)
|
||||||
# Check for legacy bash-script install markers and warn the user.
|
# If a legacy bash-script installation is present, revert it cleanly first.
|
||||||
if grep -qF '$res->{sensorsJSONOutput}' "$NODES_PM" 2>/dev/null || \
|
if grep -qF '$res->{sensorsJSONOutput}' "$NODES_PM" 2>/dev/null || \
|
||||||
grep -qF '$res->{systemInfo}' "$NODES_PM" 2>/dev/null; then
|
grep -qF '$res->{systemInfo}' "$NODES_PM" 2>/dev/null; then
|
||||||
echo ""
|
echo "pve-mod: Legacy bash-script installation detected — reverting before upgrade."
|
||||||
echo "WARNING: A legacy pve-mod bash-script installation was detected in Nodes.pm."
|
/usr/lib/pve-mod/revert-patches.sh || true
|
||||||
echo "The old installation should be removed first to avoid conflicts:"
|
|
||||||
echo " bash /path/to/pve-mod-gui-sensors.sh uninstall"
|
|
||||||
echo ""
|
|
||||||
echo "Skipping patch application. Run 'pve-mod-configure' after removing the old install."
|
|
||||||
echo ""
|
|
||||||
else
|
|
||||||
# Apply patches for any enabled modules (idempotent, safe on upgrades).
|
|
||||||
/usr/lib/pve-mod/apply-patches.sh 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Apply patches for any enabled modules. Fails loudly on error.
|
||||||
|
/usr/lib/pve-mod/apply-patches.sh
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "pve-mod installed successfully."
|
echo "pve-mod installed successfully."
|
||||||
@ -28,6 +23,23 @@ case "$1" in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
triggered)
|
||||||
|
# Fired by dpkg when pve-manager is upgraded. Only re-apply patches
|
||||||
|
# if the user has opted in via 'pve-mod-configure'.
|
||||||
|
TRIGGER_ENABLED=$(awk -F= '/^\[pve_trigger\]/{s=1} s && /^enabled=/{print $2; exit}' \
|
||||||
|
/etc/pve-mod/pve-mod.conf 2>/dev/null || echo 0)
|
||||||
|
if [ "${TRIGGER_ENABLED}" = "1" ]; then
|
||||||
|
echo "pve-mod: pve-manager upgrade detected — re-applying patches."
|
||||||
|
if ! /usr/lib/pve-mod/apply-patches.sh; then
|
||||||
|
echo "pve-mod: WARNING: Failed to re-apply patches. Run 'pve-mod-configure' to fix." >&2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "pve-mod: WARNING: pve-manager was upgraded but auto re-patching is disabled." >&2
|
||||||
|
echo "pve-mod: The Proxmox UI modifications may no longer be active." >&2
|
||||||
|
echo "pve-mod: Run 'pve-mod-configure' to re-apply patches." >&2
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
abort-upgrade|abort-remove|abort-deconfigure)
|
abort-upgrade|abort-remove|abort-deconfigure)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
1
debian/pve-mod.triggers
vendored
Normal file
1
debian/pve-mod.triggers
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
interest pve-manager
|
||||||
2
debian/rules
vendored
2
debian/rules
vendored
@ -36,8 +36,6 @@ override_dh_install:
|
|||||||
debian/pve-mod/usr/lib/pve-mod/apply-patches.sh
|
debian/pve-mod/usr/lib/pve-mod/apply-patches.sh
|
||||||
install -Dm755 src/PVENodeInfo/revert-patches.sh \
|
install -Dm755 src/PVENodeInfo/revert-patches.sh \
|
||||||
debian/pve-mod/usr/lib/pve-mod/revert-patches.sh
|
debian/pve-mod/usr/lib/pve-mod/revert-patches.sh
|
||||||
install -Dm755 src/pve-mod-apt-hook.sh \
|
|
||||||
debian/pve-mod/usr/lib/pve-mod/apt-hook.sh
|
|
||||||
# Configure tool
|
# Configure tool
|
||||||
install -Dm755 src/Scripts/pve-mod-configure \
|
install -Dm755 src/Scripts/pve-mod-configure \
|
||||||
debian/pve-mod/usr/sbin/pve-mod-configure
|
debian/pve-mod/usr/sbin/pve-mod-configure
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
CONF_FILE="/etc/pve-mod/pve-mod.conf"
|
CONF_FILE="/etc/pve-mod/pve-mod.conf"
|
||||||
APT_HOOK_FILE="/etc/apt/apt.conf.d/99-pve-mod"
|
|
||||||
APPLY_PATCHES="/usr/lib/pve-mod/apply-patches.sh"
|
APPLY_PATCHES="/usr/lib/pve-mod/apply-patches.sh"
|
||||||
NODES_PM="/usr/share/perl5/PVE/API2/Nodes.pm"
|
NODES_PM="/usr/share/perl5/PVE/API2/Nodes.pm"
|
||||||
|
|
||||||
@ -317,8 +316,8 @@ device_name=${UPS_DEVICE_NAME}
|
|||||||
enabled=${ENABLE_SYSTEM_INFO}
|
enabled=${ENABLE_SYSTEM_INFO}
|
||||||
type=${SYSTEM_INFO_TYPE}
|
type=${SYSTEM_INFO_TYPE}
|
||||||
|
|
||||||
[apt_hook]
|
[pve_trigger]
|
||||||
enabled=${APT_HOOK_ENABLED}
|
enabled=${PVE_TRIGGER_ENABLED}
|
||||||
|
|
||||||
[service]
|
[service]
|
||||||
mode=embedded
|
mode=embedded
|
||||||
@ -327,35 +326,6 @@ EOF
|
|||||||
}
|
}
|
||||||
#endregion write config
|
#endregion write config
|
||||||
|
|
||||||
#region apt hook
|
|
||||||
configure_apt_hook() {
|
|
||||||
msgb "\n=== Automatic Re-patching (apt hook) ==="
|
|
||||||
echo "After a Proxmox upgrade, patched files (Nodes.pm, pvemanagerlib.js) may be"
|
|
||||||
echo "overwritten. An apt hook can re-apply patches automatically after every apt run."
|
|
||||||
echo "Enabling may pose the risk should something go wrong during the re-patching process (e.g. Proxmox changes)."
|
|
||||||
local choice
|
|
||||||
choice=$(ask "Enable automatic re-patching after apt/dpkg operations? (y/N)")
|
|
||||||
case "$choice" in
|
|
||||||
[yY])
|
|
||||||
APT_HOOK_ENABLED=1
|
|
||||||
cat > "$APT_HOOK_FILE" <<'HOOKEOF'
|
|
||||||
DPkg::Post-Invoke { "/usr/lib/pve-mod/apt-hook.sh || true"; };
|
|
||||||
HOOKEOF
|
|
||||||
info "Apt hook installed: $APT_HOOK_FILE"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
APT_HOOK_ENABLED=0
|
|
||||||
if [[ -f "$APT_HOOK_FILE" ]]; then
|
|
||||||
rm -f "$APT_HOOK_FILE"
|
|
||||||
info "Apt hook removed."
|
|
||||||
else
|
|
||||||
info "Apt hook not enabled."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
#endregion apt hook
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
# ── Root check ────────────────────────────────────────────────────────────
|
# ── Root check ────────────────────────────────────────────────────────────
|
||||||
[[ $EUID -eq 0 ]] || err "This script must be run as root."
|
[[ $EUID -eq 0 ]] || err "This script must be run as root."
|
||||||
@ -391,7 +361,7 @@ main() {
|
|||||||
ENABLE_GPU_HISTORY=0
|
ENABLE_GPU_HISTORY=0
|
||||||
ENABLE_UPS=0; UPS_DEVICE_NAME="ups@localhost"
|
ENABLE_UPS=0; UPS_DEVICE_NAME="ups@localhost"
|
||||||
ENABLE_SYSTEM_INFO=0; SYSTEM_INFO_TYPE=1
|
ENABLE_SYSTEM_INFO=0; SYSTEM_INFO_TYPE=1
|
||||||
APT_HOOK_ENABLED=0
|
PVE_TRIGGER_ENABLED=0
|
||||||
|
|
||||||
# ── Module selection ──────────────────────────────────────────────────────
|
# ── Module selection ──────────────────────────────────────────────────────
|
||||||
msgb "\n=== pve-mod Module Selection ==="
|
msgb "\n=== pve-mod Module Selection ==="
|
||||||
@ -421,8 +391,16 @@ main() {
|
|||||||
info "Subscription nag screen removal will be applied."
|
info "Subscription nag screen removal will be applied."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Apt hook ──────────────────────────────────────────────────────────────
|
# ── Re-patch on PVE upgrade ───────────────────────────────────────────────
|
||||||
configure_apt_hook
|
msgb "\n=== Auto Re-patching on PVE Upgrade ==="
|
||||||
|
echo "pve-mod registers a dpkg trigger on pve-manager. When pve-manager is"
|
||||||
|
echo "upgraded, the trigger fires and can automatically re-apply patches."
|
||||||
|
local triggerChoice
|
||||||
|
triggerChoice=$(ask "Re-apply patches automatically when pve-manager upgrades? (y/N)")
|
||||||
|
case "$triggerChoice" in
|
||||||
|
[yY]) PVE_TRIGGER_ENABLED=1; info "Auto re-patching enabled." ;;
|
||||||
|
*) PVE_TRIGGER_ENABLED=0; info "Auto re-patching disabled. Run 'pve-mod-configure' after a PVE upgrade." ;;
|
||||||
|
esac
|
||||||
|
|
||||||
# ── Write config and apply ────────────────────────────────────────────────
|
# ── Write config and apply ────────────────────────────────────────────────
|
||||||
write_config
|
write_config
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# /usr/lib/pve-mod/apt-hook.sh
|
|
||||||
#
|
|
||||||
# Installed to /etc/apt/apt.conf.d/99-pve-mod by pve-mod-configure when the
|
|
||||||
# user enables the apt hook. Re-applies PVE file patches after any dpkg run
|
|
||||||
# (e.g. after a pve-manager upgrade overwrites patched files).
|
|
||||||
|
|
||||||
/usr/lib/pve-mod/apply-patches.sh || true
|
|
||||||
@ -31,7 +31,7 @@ device_name=ups@localhost
|
|||||||
enabled=0
|
enabled=0
|
||||||
type=1
|
type=1
|
||||||
|
|
||||||
[apt_hook]
|
[pve_trigger]
|
||||||
enabled=0
|
enabled=0
|
||||||
|
|
||||||
[service]
|
[service]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user