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
This commit is contained in:
parent
b5cc077b8b
commit
f134b1d39c
|
@ -19,11 +19,12 @@ done
|
||||||
|
|
||||||
_vsv() {
|
_vsv() {
|
||||||
local service="$1"
|
local service="$1"
|
||||||
|
local facility="${2:-daemon}"
|
||||||
local LN_OPTS="-s"
|
local LN_OPTS="-s"
|
||||||
local svdir="${PKGDESTDIR}/etc/sv/${service}"
|
local svdir="${PKGDESTDIR}/etc/sv/${service}"
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
||||||
msg_red "$pkgver: vsv: 1 argument expected: <service>\n"
|
msg_red "$pkgver: vsv: up to 2 arguments expected: <service> [<log facility>]\n"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -34,18 +35,26 @@ _vsv() {
|
||||||
vmkdir etc/sv
|
vmkdir etc/sv
|
||||||
vcopy "${FILESDIR}/$service" etc/sv
|
vcopy "${FILESDIR}/$service" etc/sv
|
||||||
if [ ! -L $svdir/run ]; then
|
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
|
chmod 755 $svdir/run
|
||||||
fi
|
fi
|
||||||
if [ -e $svdir/finish ] && [ ! -L $svdir/finish ]; then
|
if [ -e $svdir/finish ] && [ ! -L $svdir/finish ]; then
|
||||||
chmod 755 $svdir/finish
|
chmod 755 $svdir/finish
|
||||||
fi
|
fi
|
||||||
ln ${LN_OPTS} /run/runit/supervise.${service} $svdir/supervise
|
ln ${LN_OPTS} /run/runit/supervise.${service} $svdir/supervise
|
||||||
if [ -d $svdir/log ]; then
|
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
|
ln ${LN_OPTS} /run/runit/supervise.${service}-log $svdir/log/supervise
|
||||||
if [ -e $svdir/log/run ] && [ ! -L $svdir/log/run ]; then
|
if [ -e $svdir/log/run ] && [ ! -L $svdir/log/run ]; then
|
||||||
chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run
|
chmod 755 ${PKGDESTDIR}/etc/sv/${service}/log/run
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_vbin() {
|
_vbin() {
|
||||||
|
|
Loading…
Reference in New Issue