Browse code

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 <alexl@redhat.com> (github: alexlarsson)

Alexander Larsson authored on 2014/02/21 18:48:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,15 @@
0
+package systemd
1
+
2
+import (
3
+	"os"
4
+)
5
+
6
+// Conversion to Go of systemd's sd_booted()
7
+func SdBooted() bool {
8
+	s, err := os.Stat("/run/systemd/system")
9
+	if err != nil {
10
+		return false
11
+	}
12
+
13
+	return s.IsDir()
14
+}