Skip to content
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

Support shutdown/reboot/sleep on FreeBSD #761

Closed
danfe opened this issue Dec 30, 2023 · 2 comments
Closed

Support shutdown/reboot/sleep on FreeBSD #761

danfe opened this issue Dec 30, 2023 · 2 comments

Comments

@danfe
Copy link

danfe commented Dec 30, 2023

Consider the following patch I've been running with for a while, works just fine:

--- src/default.h.orig	2023-12-28 18:29:47 UTC
+++ src/default.h
@@ -193,6 +193,11 @@ XSV(const char *, shutdownCommand,              "test 
 XSV(const char *, rebootCommand,                "test -e /run/systemd/system && systemctl reboot || loginctl reboot")
 XSV(const char *, suspendCommand,               "test -e /run/systemd/system && systemctl suspend || loginctl suspend")
 XSV(const char *, hibernateCommand,             "test -e /run/systemd/system && systemctl hibernate || loginctl hibernate")
+#elif __FreeBSD__
+XSV(const char *, shutdownCommand,              "shutdown -p now")
+XSV(const char *, rebootCommand,                "shutdown -r now")
+XSV(const char *, suspendCommand,               "zzz")
+XSV(const char *, hibernateCommand,             0)
 #else
 XSV(const char *, shutdownCommand,              0)
 XSV(const char *, rebootCommand,                0)

Hibernate (suspend to disk, S4) is not supported on FreeBSD.

@gijsbers
Copy link
Collaborator

Would it be OK to use "poweroff" and "reboot" instead?

@danfe
Copy link
Author

danfe commented Jan 10, 2024

Would it be OK to use "poweroff"

Yes, it would: per the manpage, calling poweroff is equivalent to shutdown -p now. However,

and "reboot" instead?

This one is different: reboot merely flushes the file system cache to disk, sends all running processes a SIGTERM (and subsequently a SIGKILL) signal, and restarts the system; it short-circuits the normal shutdown process by not going through all of the RC and other bookkeeping of stopping processes and logging actions properly before killing the OS. You may want to check out this forum thread. Thus, for consistency's sake, I've opted for shutdown(8) in both cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants