#!/sbin/openrc-run
supervisor=supervise-daemon

name=radicale
description="Free and open-source CalDAV and CardDAV server"

command=/usr/bin/radicale
command_args="$radicale_opts"
command_user=radicale:radicale

logdir="/var/log/radicale"
logfile="$logdir/radicale.log"
supervise_daemon_args="--stderr $logfile"

depend() {
	use net
	need localmount
}

start_pre() {
	checkpath -d -o radicale /var/lib/radicale
	checkpath -d -o radicale "$logdir"
	checkpath -f -o radicale "$logfile"

	checkpath -f -o root:radicale -m640 /etc/radicale/config
	checkpath -f -o root:radicale -m640 /etc/radicale/rights
	checkpath -f -o root:radicale -m640 /etc/radicale/users
}
