ryran / reboot-guard Goto Github PK
View Code? Open in Web Editor NEWBlock systemd-initiated poweroff/reboot/halt until configurable condition checks pass
License: GNU General Public License v3.0
Block systemd-initiated poweroff/reboot/halt until configurable condition checks pass
License: GNU General Public License v3.0
Maybe it's something strange with how my machine is configured, but when I turn on reboot-guard and run systemctl reboot (or sudo systemctl reboot) my KDE session dies, although the machine restart is blocked.
My use case is on stack exchange https://unix.stackexchange.com/questions/282237/how-can-i-prevent-systemctl-reboot-or-systemctl-poweroff-from-executing and this was suggested as the answer. I would really like for this to work, so I can accept that answer after 18 months :-)
The only time someone will see WARNING: Exiting due to -1 or -0 option
is when they're running rguard
directly from a cmdline ... and in that case this "warning" seems a bit unnecessary.
To help the operator get used to reboot-guard and to prevent negative perception, it would be quite useful to be able to display a custom message like:
[root]# systemctl reboot
Failed to issue method call: Operation refused, unit reboot.target may be requested by dependency only. This service is blocked by reboot-guard ...etc..etc...etc.
A requirement of the rguard design was that it would work on RHEL7 out of the box, so python3 was unfortunately out of the question. For other operating systems where python2 is not the default python, rguard will fail. We should be explicitly specifying this in the shebang.
On minimal modern fedora installations, it's common to have no python2 and it sucks to have to install that just for reboot-guard. It would be good to make it so that reboot-guard works with either 2.7 or 3.6+
I used to have tvheadend running in a odroid c1. lately I needed to do transcoding and the odroid c1 is too weak so I set it up in a proper machine. I do care about power consumption so I needed to figure out a way of having the machine hibernated while not watching the iptv but also being sure it wouldnt hibernate while streaming video. reboot-guard is what I needed since I did not want to deal with systemd inhibitor locks and dbus. I do have a background service that queries the tvheadend api. if there is a subscription or a recording going on it saves the info to a file that I'm monitoring with inotify watch. depending on the contents I tell reboot-guard to avoid hibernate or not.
cheers.
The rguard.service
file should do something out of the box instead of requiring you to configure it.
I think the most intuitive thing would be for it to block shutdown as long as the service is running, e.g., via --run false
.
We are trying to use this for graceful shutdown purpose, the details I wrote in systemd mailing list.
There the problem is once ACPI signal comes, shutdown process will be blocked by this service.
How to continue shutdown process once ./rguard -1 --run sleep 30
was finished?
Because shutdown will not retry automatically.
Thanks!
it does not handle (rm_dir) /run/systemd/system/{halt,shutdown,poweroff}.target.d/{}.conf files
tested in archlinux with systemd 233-3
rguard -1 -d debug output:
DEBUG: Adding RefuseManualStart=yes to /run/systemd/system/poweroff.target.d/reboot-guard.conf
WARNING: ☹ Blocked poweroff.target
DEBUG: Adding RefuseManualStart=yes to /run/systemd/system/reboot.target.d/reboot-guard.conf
WARNING: ☹ Blocked reboot.target
DEBUG: Adding RefuseManualStart=yes to /run/systemd/system/halt.target.d/reboot-guard.conf
WARNING: ☹ Blocked halt.target
DEBUG: Reloading systemd via: systemctl daemon-reload
INFO: Exiting due to -1 or -0 option
rguard -0 -d debug output:
DEBUG: Unit poweroff.target already configured with RefuseManualStart=no
DEBUG: Unit reboot.target already configured with RefuseManualStart=no
DEBUG: Unit halt.target already configured with RefuseManualStart=no
Yup.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.