busybox/examples/var_service/std_service_logger
Denys Vlasenko 14339191af examples/var_service/: use standard logger script, viewer and pager scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 23:23:09 +02:00

33 lines
701 B
Bash
Executable File

#!/bin/sh
user=logger
exec >/dev/null 2>&1
service="${PWD%/log}"
service="${service##*/}"
logdir="/var/log/service/$service"
mkdir -p "$logdir"
chown -R "$user": "$logdir"
chmod -R go-rwxst,u+rwX "$logdir"
# TODO: if "$logdir/config" does not exist,
# based on service's preferences, write some setup in it:
# e.g. smaller nNUM directive ("I'm not that important,
# save 2 rather than default 10 one-megabyte log files")
# Convenience symlink in this log/ directory:
rm logdir
ln -s "$logdir" logdir
# Make current dir accessible to logger:
chmod a+rX .
args=""
test "$LOG_NOTIMESTAMP" || args="-tt"
exec \
env - PATH="$PATH" \
chpst -u "$user" -m $((20 * 1024*1024)) \
svlogd $args "$logdir"