mirror of
https://github.com/ergosteur/ergo-proxmox-scripts.git
synced 2026-10-28 13:00:37 -04:00
Retire nut-udev-restart.sh to unused/
It was meant to restart the NUT driver from a udev RUN+= when the UPS re-enumerates on USB, but was never wired up: 50-nut-ups.rules only sets MODE and GROUP. systemd already covers the case. nut-driver@ups.service is Restart=always with RestartUSec=15s, so the driver is retried indefinitely and reattaches to a new device node unaided. It would also not have worked reliably. systemd-udevd kills RUN+= handlers still alive when the event completes, so the backgrounded subshell could be killed mid-sleep, and upsdrvctl would run the driver outside the unit's supervision, competing with systemd's own restarts. Kept with a header recording the rule-based alternative if faster recovery is ever wanted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
29d0a5b923
commit
d33d814876
@@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# nut-udev-restart.sh - safely restart NUT UPS driver on USB event
|
|
||||||
# Location: /opt/ergosteur/nut-udev-restart.sh
|
|
||||||
|
|
||||||
(
|
|
||||||
# small delay so the USB device is fully settled before restarting driver
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
# stop and start the driver
|
|
||||||
/sbin/upsdrvctl stop
|
|
||||||
/sbin/upsdrvctl start
|
|
||||||
) &
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
Executable
+36
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# RETIRED. Kept for reference only.
|
||||||
|
#
|
||||||
|
# Intended to be called from a udev RUN+= when the UPS re-enumerates on USB, to
|
||||||
|
# restart the NUT driver so it reattaches to the new device node. It was never
|
||||||
|
# wired up: /etc/udev/rules.d/50-nut-ups.rules only sets MODE and GROUP.
|
||||||
|
#
|
||||||
|
# Superseded by systemd. nut-driver@ups.service is Restart=always with
|
||||||
|
# RestartUSec=15s, so the driver is already retried indefinitely and picks up a
|
||||||
|
# new device node on its own. This script would only save about 13 seconds.
|
||||||
|
#
|
||||||
|
# It would also not work reliably as written:
|
||||||
|
#
|
||||||
|
# - systemd-udevd runs RUN+= handlers in a cgroup and kills whatever is still
|
||||||
|
# alive when the event completes, so the backgrounded subshell can be killed
|
||||||
|
# mid-sleep and the restart never happens. Long-running work belongs in
|
||||||
|
# ENV{SYSTEMD_WANTS}= or RUN+="systemctl --no-block ...".
|
||||||
|
# - upsdrvctl starts the driver outside nut-driver@ups.service's supervision,
|
||||||
|
# while stopping it makes systemd spawn a competing replacement.
|
||||||
|
#
|
||||||
|
# If faster recovery is ever wanted, drop the script and put the trigger in the
|
||||||
|
# rule instead:
|
||||||
|
#
|
||||||
|
# SUBSYSTEM=="usb", ATTR{idVendor}=="0764", ATTR{idProduct}=="0601", \
|
||||||
|
# ACTION=="add", RUN+="/usr/bin/systemctl --no-block restart nut-driver@ups.service"
|
||||||
|
|
||||||
|
(
|
||||||
|
# small delay so the USB device is fully settled before restarting driver
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# stop and start the driver
|
||||||
|
/sbin/upsdrvctl stop
|
||||||
|
/sbin/upsdrvctl start
|
||||||
|
) &
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user