summaryrefslogtreecommitdiff
path: root/system/utmps/utmps.initd
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-15 00:38:18 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-15 00:38:18 -0500
commitaa63ef787e3fdd611599c6327733e2846a11315e (patch)
tree9a47cb3d791c0e642261c7a0b6d16ece65342618 /system/utmps/utmps.initd
parenta12b74b878220dc796e4e4cb44d277466212113e (diff)
downloadpackages-aa63ef787e3fdd611599c6327733e2846a11315e.tar.gz
packages-aa63ef787e3fdd611599c6327733e2846a11315e.tar.bz2
packages-aa63ef787e3fdd611599c6327733e2846a11315e.tar.xz
packages-aa63ef787e3fdd611599c6327733e2846a11315e.zip
system/utmps: new package
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 $?
+}