logger 379 B

12345678910111213141516171819202122
  1. #!/bin/sh --
  2. # shellcheck shell=sh
  3. set -ue
  4. : "${PWD:=$(pwd)}"
  5. NAME="${PWD%/*}"
  6. NAME="${NAME##*/}"
  7. if [ "${USER_LOG:-}" = 1 ]; then
  8. BASE="${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}/${USER:-$(whoami)}}"
  9. else
  10. BASE=/var
  11. fi
  12. LOG="${BASE:?}/log/runit/${NAME:?}.log"
  13. [ -f "${LOG}" ] || {
  14. : | install -Dm600 -- /proc/self/fd/0 "${LOG}"
  15. }
  16. exec /etc/runit/functions/runit-logger >>"${LOG}"