3
0

std_service_logger 701 B

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