-
-
Notifications
You must be signed in to change notification settings - Fork 406
Just launch nut-server systemd servide if we are not on netclient mode #3233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Tested with ExecCondition=/bin/sh -c '[ "$MODE" != "netclient" ]' an
| # Note: foreground mode "-F" by default skips writing a PID file (and | ||
| # needs default Type=simple); we can use "-FF" here to create the file | ||
| # anyway, so that old "upsd -c reload" works rather than systemd action: | ||
| ExecCondition=@SBINDIR@/sh -c '[ "$MODE" != "netclient" ]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SBINDIR@ is for NUT's system binaries; this is not necessarily where OS binaries co-exist.
I think Unix standards dictate that a /sbin/sh (for system scripts) exists, may be or not be same as /bin/sh (default for interactive users) - so please rather refer to one of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I've check
debian:
bin -> usr/bin
sbin -> usr/sbin
/usr/sbin/upsd
/usr/bin/sh
Arch:
bin -> usr/bin/
sbin -> usr/bin/
/usr/bin/upsd
/usr/bin/sh
So it's the same PATH on Arch but not debian. It's in /bin/sh / /usr/bin/sh on both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Searching the use of ExecCondition with sh, a few more examples use /bin/sh like
- https://stackoverflow.com/questions/76055699/how-can-i-negate-the-exit-code-of-a-command-used-in-execcondition-of-a-systemd-s
- https://devsolus.com/how-can-i-negate-the-exit-code-of-a-command-used-in-execcondition-of-a-systemd-service/
- https://ro.qask.org/server/2022/11/05/systemd-valoare-l-necunoscuta-execcondition-in-sectiunea-service
- https://serverfault.com/questions/1068680/systemd-unknown-lvalue-execcondition-in-section-service
- Feature request: Option to suppress normal output jqlang/jq#1225
And others just sh
- https://stackoverflow.com/questions/68491889/execcondition-doesnt-prevent-start-of-service
- https://unix.stackexchange.com/questions/659647/execcondition-doesnt-prevent-start-of-service
- https://stackoverflow.com/questions/41067756/condition-on-script-status
- Add a service condition for $XDG_SESSION_TYPE systemd/systemd#15067
|
This looks like a neat idea in fact, may help fix the long-standing issue #837 and loosely related to the likes of #156 (and others referred from these two). Did you check if this actually works, e.g. things are not getting broken by various values of Other than that, your original issue can be addressed by |
|
Thanks I didn't find those issues. This it's what I have tested with
I could complicate the test with something like Happy to do more testing if anyone has something in mind. |
Not sure if there is a better way to call `sh` without assuming a static dir. Something like `command -v sh`
Tested with
ExecCondition=/bin/sh -c '[ "$MODE" != "netclient" ]'This is more than a RFC than an intent to have the PR merged.
nut.targettries to startnut-driver.targetnut-server.servicenut-monitor.service.On distros like Arch where nut is packaged as only one package, configured as netclient system,
nut-server.servicefails withFatal error: at least one UPS must be defined in ups.conf.Tried to just enable
nut-monitor.servicebut seems not to work withoutnut.targetenabled. 1If
upsdcould detect theMODE=netclientand exits without failing could be another solution.So my questions is: if making
nut-server.serviceonly start if we are not onMODE=netclientis something that upstream could consider? , or if I should ask this on Arch itself?Thanks for this great software!