#! /bin/sh -
# rc.perp: perpd startup script for perpboot
# ===

set -e

### --- configure ---
PERP_VAR=/var/run/perp
PERPD_OPTS="-a6"


### --- script ---

## note: perpboot defines PERP_BASE on startup

## clean setup for runtime control files:
rm -Rf ${PERP_VAR}
mkdir -p ${PERP_VAR}
chmod 0700 ${PERP_VAR}

## clean symlink:
rm -Rf ${PERP_BASE}/.control
ln -sf ${PERP_VAR} ${PERP_BASE}/.control

## exec perpd:
##   * options as configured above
##   * runchoom(8) abate linux oom-killer
##   * runlimit(8) configured in ./rlimit.conf
##   * PERP_BASE defined in environment by perpboot(8)
exec \
  runchoom \
  runlimit -F ./rlimit.conf \
  perpd ${PERPD_OPTS} ${PERP_BASE}

### EOF
