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

: ${GVM_USER:=gvm}
: ${GVM_GROUP:=$(id -ng ${GVM_USER})}
: ${NOTUS_TIMEOUT:=30}

name="Greenbone Notus Scanner"
command=/usr/bin/notus-scanner
command_user="${GVM_USER}:${GVM_GROUP}"
pidfile="/run/notus-scanner/${RC_SVCNAME}.pid"
configfile="/etc/gvm/notus-scanner.toml"
command_args="--pid-file ${pidfile} \
	--config ${configfile}"
retry="${NOTUS_TIMEOUT}"

depend() {
	after bootmisc
	need localmount mosquitto
}

start_pre() {
        checkpath -d --owner ${GVM_USER} /run/notus-scanner
}

start_post() {
	ewaitfile 10 ${pidfile}
	checkpath -d --owner root:root /run/notus-scanner
	checkpath -f --owner root:root ${pidfile}
}
