#!/bin/sh
[ -r conf ] && . ./conf
# Read default configuration
[ -f /etc/default/boinc-client ] && . /etc/default/boinc-client
# Override with global configuration
[ -f /etc/boinc-client.conf ] && . /etc/boinc-client.conf
BOINCEXE_NAME=${BOINCEXE_NAME:-boinc_client}
BOINCCMD_NAME=${BOINCCMD_NAME:-boinccmd}
BOINCUSER=${BOINCUSER:-boinc}
BOINCDIR=${BOINCDIR:-/var/lib/boinc}
LOGFILE=${LOGFILE:-/var/log/${BOINCEXE_NAME}.log}
ERRORLOG=${ERRORLOG:-/var/log/${BOINCEXE_NAME}_err.log}
[ ! -d ${BOINCDIR} ] && mkdir -m 755 -p ${BOINCDIR} && chown ${BOINCUSER} ${BOINCDIR}
[ ! -f ${LOGFILE} ] && touch ${LOGFILE} && chown ${BOINCUSER} ${LOGFILE}
[ ! -f ${ERRORLOG} ] && touch ${ERRORLOG} && chown ${BOINCUSER} ${ERRORLOG}
exec 2>&1
exec chpst -u ${BOINCUSER} ${BOINCEXE_NAME} ${BOINCOPTS}
