#! /bin/sh -
# rc.log: perpd logger script for perpboot
# ===

### --- configure ---

## required:
LOGDIR=/var/log/perpd
LOGOPTS="-k 8 -s 100000 -t -z"
## suggested:
LOGUSER=log

### --- script ---

## initialize user:
if id ${LOGUSER} >/dev/null 2>/dev/null ; then
  my_uid=$(id -u ${LOGUSER})
  my_gid=$(id -g ${LOGUSER})
else
  LOGUSER=$(id -un)
  my_uid=$(id -u ${LOGUSER})
  my_gid=$(id -g ${LOGUSER})
fi

## initialize logdir:
if ! test -d ${LOGDIR} ; then
  mkdir -p ${LOGDIR}
fi
chown -R ${my_uid}:${my_gid} ${LOGDIR}
chmod 0755 ${LOGDIR}

## exec tinylog with privilege drop:
exec \
  runuid ${LOGUSER} \
      tinylog ${LOGOPTS} ${LOGDIR}

### EOF
