From 73971df484ac4fac1717fc5965e2adb5b33ca0d2 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 21 Feb 2014 10:48:02 +0100 Subject: [PATCH] Add systemd.SdBooted() This is a conversion of sd_booted() from libsystemd to go and checks if the system was booted with systemd. Docker-DCO-1.1-Signed-off-by: Alexander Larsson (github: alexlarsson) --- systemd/booted.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 systemd/booted.go 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() +}