holgersson-overlay/net-im/dendrite/files/dendrite.initd

54 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/sbin/openrc-run
DENDRITE=${SVCNAME#*.}
: ${DENDRITE_CONFDIR:=${RC_PREFIX%/}/etc/dendrite}
if [ -n "${DENDRITE}" ] && [ ${SVCNAME} != "dendrite" ]; then
: ${DENDRITE_CONFIG:=${DENDRITE_CONFDIR}/${DENDRITE}.yaml}
: ${DENDRITE_PIDFILE:=${RC_PREFIX%/}/run/dendrite.${DENDRITE}.pid}
: ${DENDRITE_RC_CONFIG:=${RC_PREFIX%/}/etc/conf.d/dendrite.${DENDRITE}}
else
: ${DENDRITE_CONFIG:=${DENDRITE_CONFDIR}/dendrite.yaml}
: ${DENDRITE_PIDFILE:=${RC_PREFIX%/}/run/${SVCNAME}.pid}
: ${DENDRITE_RC_CONFIG:=${RC_PREFIX%/}/etc/conf.d/dendrite}
fi
command="${RC_PREFIX%/}/usr/bin/dendrite"
pidfile="${DENDRITE_PIDFILE}"
command_background=true
command_user="dendrite:dendrite"
directory="/var/lib/dendrite"
command_args="${DENDRITE_OPTS} -config ${DENDRITE_CONFIG}"
checkconfig() {
test -f "${DENDRITE_CONFIG}" || {
echo "\"${DENDRITE_CONFIG}\" does not exist or is not a regular file." >&2
echo "Please, look at https://github.com/matrix-org/dendrite for instructions" >&2
echo "on how to configure your dendrite instance, and use" >&2
echo "\"${DENDRITE_CONFIDR}/dendrite-config-example.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
}