#!/sbin/openrc-run ZENDRITE=${SVCNAME#*.} : ${ZENDRITE_CONFDIR:=${RC_PREFIX%/}/etc/dendrite} if [ -n "${ZENDRITE}" ] && [ ${SVCNAME} != "zendrite" ]; then : ${ZENDRITE_CONFIG:=${ZENDRITE_CONFDIR}/${ZENDRITE}.yaml} : ${ZENDRITE_PIDFILE:=${RC_PREFIX%/}/run/zendrite.${ZENDRITE}.pid} : ${ZENDRITE_RC_CONFIG:=${RC_PREFIX%/}/etc/conf.d/zendrite.${ZENDRITE}} else : ${ZENDRITE_CONFIG:=${ZENDRITE_CONFDIR}/zendrite.yaml} : ${ZENDRITE_PIDFILE:=${RC_PREFIX%/}/run/${SVCNAME}.pid} : ${ZENDRITE_RC_CONFIG:=${RC_PREFIX%/}/etc/conf.d/zendrite} fi command="${RC_PREFIX%/}/usr/bin/zendrite" pidfile="${ZENDRITE_PIDFILE}" command_background=true command_user="dendrite:dendrite" directory="/var/lib/dendrite" command_args="${ZENDRITE_OPTS} -config ${ZENDRITE_CONFIG}" checkconfig() { test -f "${ZENDRITE_CONFIG}" || { echo "\"${ZENDRITE_CONFIG}\" does not exist or is not a regular file." >&2 echo "Please, look at https://codefloe.com/pat-s/zendrite for instructions" >&2 echo "on how to configure your zendrite instance, and use" >&2 echo "\"${ZENDRITE_CONFDIR}/zendrite-sample.yaml\" as an example." >&2 return 1 } } start_pre() { # If this isn't a restart, make sure that the user's config isn't # busted before we try to start the daemon (this will produce # better error messages than if we just try to start it blindly). # # If, on the other hand, this *is* a restart, then the stop_pre # action will have ensured that the config is usable and we don't # need to do that again. if [ "${RC_CMD}" != "restart" ] ; then checkconfig || return $? fi } stop_pre() { # If this is a restart, check to make sure the user's config # isn't busted before we stop the running daemon. if [ "${RC_CMD}" = "restart" ] ; then checkconfig || return $? fi }