diff --git a/systemd/booted.go b/systemd/booted.go new file mode 100644 index 0000000..2aae931 --- /dev/null +++ b/systemd/booted.go @@ -0,0 +1,15 @@ +package systemd + +import ( + "os" +) + +// Conversion to Go of systemd's sd_booted() +func SdBooted() bool { + s, err := os.Stat("/run/systemd/system") + if err != nil { + return false + } + + return s.IsDir() +}