#!/sbin/openrc-run

name="Pocket ID"
command="/usr/bin/pocket-id"
command_user="pocket-id:pocket-id"
command_background=true
supervisor="supervise-daemon"
directory="/var/lib/pocket-id"
pidfile="/run/$RC_SVCNAME.pid"
output_log="/var/log/$RC_SVCNAME.log"
error_log="/var/log/$RC_SVCNAME.log"

depend() {
	need net
	after firewall
}

start_pre() {
	checkpath -d -m 750 -o "$command_user" "$directory"
	checkpath -f -m 644 -o "$command_user" "$output_log"

	# re-source the conf.d file with allexport so its settings reach
	# the daemon's environment, which is how pocket-id is configured
	set -a
	# shellcheck disable=SC1090
	. "/etc/conf.d/$RC_SVCNAME"
	set +a
}
