#!/sbin/openrc-run

name=ktistec
description="Ktistec is a single-user ActivityPub server written in Crystal"

command="/usr/bin/ktistec"
command_args="
	${ktistec_host:+--bind $ktistec_host}
	${ktistec_port:+--port $ktistec_port}
	$extra_opts
	"
command_background="yes"
command_user="ktistec:ktistec"
pidfile="/run/${RC_SVCNAME}.pid"
directory="/var/lib/ktistec"
output_log="/var/log/ktistec.log"
error_log="/var/log/ktistec.log"

depend() {
	need localmount net
	after firewall
}

start_pre() {
	checkpath -f -m 0640 -o "$command_user" \
		"$output_log" "$error_log"

	checkpath -d -m 0750 -o "$command_user" \
		"$directory" "$directory/public/uploads"
}
