#!/sbin/openrc-run
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

name="Owncast server"
description="Owncast is a self-hosted live video and web chat server"

command=/usr/bin/owncast
user=owncast
group=owncast
pidfile=/var/run/owncast.pid
dir=/var/lib/owncast

depend() {
	use net
}

start() {
	ebegin "Starting Owncast server"
	start-stop-daemon --start --exec "${command}" \
		--user "${user}":"${group}" \
		--chdir "${dir}" \
		--pidfile "${pidfile}" \
		--make-pidfile --background
	eend $?
}

stop() {
	ebegin "Stopping Owncast server"
	start-stop-daemon --stop --exec "${command}" \
		--pidfile "${pidfile}" \
	eend $?
}
