summaryrefslogtreecommitdiff
path: root/system/utmps/utmps.initd
diff options
context:
space:
mode:
Diffstat (limited to 'system/utmps/utmps.initd')
-rw-r--r--system/utmps/utmps.initd32
1 files changed, 32 insertions, 0 deletions
diff --git a/system/utmps/utmps.initd b/system/utmps/utmps.initd
new file mode 100644
index 000000000..db4570031
--- /dev/null
+++ b/system/utmps/utmps.initd
@@ -0,0 +1,32 @@
+#!/sbin/openrc-run
+# Copyright 2018 Laurent Bercot
+# Distributed under the terms of the ISC License.
+#
+# OpenRC is only used here to trigger the s6 mechanisms.
+
+depend() {
+ need s6
+}
+
+start() {
+ ebegin "Starting utmpd and wtmpd services"
+ mkdir -p -m 0755 /run/utmps
+ chown utmp:utmp /run/utmps
+
+ # OpenRC has no readiness notification framework, so it can run this before s6 is ready.
+ # To avoid the race (yes, I have hit it), do a polling check here.
+ # If you want to avoid unnecessary delays, switch to a real service manager like s6-rc.
+ until test -e /run/service/.s6-svscan/control ; do sleep 1 ; done
+
+ ln -nsf /var/lib/utmps/services/utmpd /run/service/utmpd
+ ln -nsf /var/lib/utmps/services/wtmpd /run/service/wtmpd
+ s6-svlisten -U -t 5000 -- /var/lib/utmps/services/utmpd /var/lib/utmps/services/wtmpd "" s6-svscanctl -an /run/service
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping utmpd and wtmpd services"
+ rm -f /run/service/utmpd /run/service/wtmpd
+ s6-svlisten -d -t 5000 -- /var/lib/utmps/services/utmpd /var/lib/utmps/services/wtmpd "" s6-svscanctl -an /run/service
+ eend $?
+}