Denys Vlasenko | 1433919 | 2018-07-03 23:23:09 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | user=logger |
| 4 | |
| 5 | exec >/dev/null 2>&1 |
| 6 | |
| 7 | service="${PWD%/log}" |
| 8 | service="${service##*/}" |
| 9 | logdir="/var/log/service/$service" |
| 10 | |
| 11 | mkdir -p "$logdir" |
| 12 | chown -R "$user": "$logdir" |
| 13 | chmod -R go-rwxst,u+rwX "$logdir" |
| 14 | # TODO: if "$logdir/config" does not exist, |
| 15 | # based on service's preferences, write some setup in it: |
| 16 | # e.g. smaller nNUM directive ("I'm not that important, |
| 17 | # save 2 rather than default 10 one-megabyte log files") |
| 18 | |
| 19 | # Convenience symlink in this log/ directory: |
| 20 | rm logdir |
| 21 | ln -s "$logdir" logdir |
| 22 | |
| 23 | # Make current dir accessible to logger: |
| 24 | chmod a+rX . |
| 25 | |
| 26 | args="" |
| 27 | test "$LOG_NOTIMESTAMP" || args="-tt" |
| 28 | |
| 29 | exec \ |
| 30 | env - PATH="$PATH" \ |
| 31 | chpst -u "$user" -m $((20 * 1024*1024)) \ |
| 32 | svlogd $args "$logdir" |