#!/sbin/openrc-run

# fallback values for /etc/conf.d/thelounge
: ${command_user:=thelounge:thelounge}
: ${directory:=/var/lib/thelounge}
: ${logdir:=/var/log/thelounge}

name="thelounge"
command="/usr/bin/thelounge"
command_args="start"
command_background=true
pidfile="/run/thelounge.pid"

depend() {
	need net
	use dns
	after firewall
}

start_pre() {
	checkpath -d -o "$command_user" "$directory"

	if [ -n "$logdir" ]; then
		checkpath -d -o "$command_user" "$logdir"
	fi

	if [ -n "$output_log" ]; then
		checkpath -f -o "$command_user" "$output_log"
	fi

	if [ -n "$error_log" ]; then
		checkpath -f -o "$command_user" "$error_log"
	fi
}
