#!/sbin/openrc-run

name=mitra
description="Mitra is an ActivityPub microblogging platform written in Rust"

: ${cfgfile:="/etc/mitra/config.yaml"}
export CONFIG_PATH="${cfgfile}"

command="/usr/bin/mitra"
command_args="server"
command_background=true
command_user="mitra:mitra"
pidfile="/run/${RC_SVCNAME}.pid"
directory="/var/lib/mitra"
error_log="/var/log/mitra.log"

required_files="$cfgfile"

depend() {
	need localmount net postgresql
	after firewall
}

start_pre() {
	checkpath -f -m 0640 -o "root:mitra" "$cfgfile"
	checkpath -f -m 0640 -o "$command_user" "$error_log"
	checkpath -d -m 0750 -o "$command_user" "$directory"
}
