From f134b1d39cce637c42ff516c00ee374d01e6c561 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Thu, 2 Feb 2023 03:02:12 -0500 Subject: [PATCH] common/environment/setup/install.sh: always add log service - overridable by having a log service at `$pkgname/files/$service/log` - warns if stderr is not redirected in the main service - uses a sane default run script with the service name set as tag and daemon facility --- common/environment/setup/install.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh index 5f0571de14a..b0c5b22f4c2 100644 --- a/common/environment/setup/install.sh +++ b/common/environment/setup/install.sh @@ -19,11 +19,12 @@ done _vsv() { local service="$1" + local facility="${2:-daemon}" local LN_OPTS="-s" local svdir="${PKGDESTDIR}/etc/sv/${service}" - if [ $# -lt 1 ]; then - msg_red "$pkgver: vsv: 1 argument expected: \n" + if [ $# -lt 1 ] || [ $# -gt 2 ]; then + msg_red "$pkgver: vsv: up to 2 arguments expected: []\n" return 1 fi @@ -34,17 +35,25 @@ _vsv() { vmkdir etc/sv vcopy "${FILESDIR}/$service" etc/sv if [ ! -L $svdir/run ]; then + grep -Fq 'exec 2>&1' $svdir/run || msg_warn "$pkgver: vsv: service '$service' does not contain 'exec 2>&1' to log stderr\n" chmod 755 $svdir/run fi if [ -e $svdir/finish ] && [ ! -L $svdir/finish ]; then chmod 755 $svdir/finish fi ln ${LN_OPTS} /run/runit/supervise.${service} $svdir/supervise - if [ -d $svdir/log ]; then - ln ${LN_OPTS} /run/runit/supervise.${service}-log $svdir/log/supervise - if [ -e $svdir/log/run ] && [ ! -L $svdir/log/run ]; then - chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run - fi + if [ -d $svdir/log ] || [ -L $svdir/log ]; then + msg_warn "$pkgver: vsv: overriding default log service\n" + else + mkdir $svdir/log + cat <<-EOF > $svdir/log/run + #!/bin/sh + exec vlogger -t $service -p $facility + EOF + fi + ln ${LN_OPTS} /run/runit/supervise.${service}-log $svdir/log/supervise + if [ -e $svdir/log/run ] && [ ! -L $svdir/log/run ]; then + chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run fi }