#!/sbin/openrc-run
name="OpenBao server"
description="OpenBao is a tool for securely accessing secrets"
description_reload="Reload configuration"

extra_started_commands="reload"

command="/usr/bin/bao"
command_args="${openbao_opts}"
command_user="${RC_SVCNAME}:${RC_SVCNAME}"

supervisor=supervise-daemon
output_log="/var/log/${RC_SVCNAME}.log"
error_log="/var/log/${RC_SVCNAME}.log"
respawn_max=0
respawn_delay=10

depend() {
	need net
	after firewall
}

start_pre() {
	checkpath -f -m 0644 -o "$command_user" "$output_log" "$error_log"
}

reload() {
	start_pre \
		&& ebegin "Reloading $RC_SVCNAME configuration" \
		&& $supervisor "$RC_SVCNAME" --signal HUP
	eend $?
}
