summaryrefslogtreecommitdiff
path: root/s6-svscan-user.openrc
blob: c6a94e232b8afd12a0eb128375b707eec7f3c2ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
}