From 819fcfab2a16d38c4449fc693c60d9b2fa5f3bcb Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Sat, 26 Aug 2023 13:53:59 +0200 Subject: Add OpenRC helper to launch users S6 --- s6-svscan-user.openrc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 s6-svscan-user.openrc (limited to 's6-svscan-user.openrc') diff --git a/s6-svscan-user.openrc b/s6-svscan-user.openrc new file mode 100644 index 0000000..c6a94e2 --- /dev/null +++ b/s6-svscan-user.openrc @@ -0,0 +1,40 @@ +#!/sbin/openrc-run +# Copyright (c) 2020-2023 Guillermo Ramos. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + + +USER=${RC_SVCNAME#*.} +SVDIR=/home/$USER/s6/service + +description="Launch $USER's s6 services" +command=/bin/s6-svscan +command_args=$SVDIR +command_background=yes +command_user=$USER +pidfile=/var/run/s6-svscan-user.pid +output_log=/home/$USER/s6/s6-svscan-user.log +error_log=/home/$USER/s6/s6-svscan-user.error.log + +depend() +{ + need localmount +} + +stop_post() +{ + ebegin "Waiting for any remaining s6 services" + echo $SVDIR/* | xargs -n 1 -P 0 runuser -u $USER -- s6-svc -wD + eend $? + + ebegin "Waiting for any remaining s6 service loggers" + echo $SVDIR/*/log | xargs -n 1 -P 0 runuser -u $USER -- s6-svc -wD + eend $? + true +} -- cgit v1.2.3