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

ONTHESPOT_USER=${ONTHESPOT_USER:-onthespot}
ONTHESPOT_GROUP=${ONTHESPOT_GROUP:-onthespot}
ONTHESPOT_DIRECTORY=${ONTHESPOT_DIRECTORY:-/var/lib/onthespot}
ONTHESPOT_UMASK=${ONTHESPOT_UMASK:-0022}
ONTHESPOT_IONICE=${ONTHESPOT_IONICE:-0}
ONTHESPOT_NICE=${ONTHESPOT_NICE:-0}

description="OnTheSpot Web UI"
command="/usr/bin/onthespot-web"
command_args="${ONTHESPOT_OPTS}"
pidfile="/run/${RC_SVCNAME}.pid"
command_background="yes"
command_user="${ONTHESPOT_USER}:${ONTHESPOT_GROUP}"
umask="${ONTHESPOT_UMASK}"
start_stop_daemon_args="--ionice ${ONTHESPOT_IONICE} --nicelevel ${ONTHESPOT_NICE}"

depend() {
    need localmount net
}

start_pre() {
    checkpath -q -d -o ${ONTHESPOT_USER}:${ONTHESPOT_GROUP} ${ONTHESPOT_DIRECTORY}
}
