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

name="${RC_SVCNAME}"

config="${CADDY_CONFIG:-/etc/caddy/Caddyfile}"
pidfile="/run/${RC_SVCNAME}/caddy.pid"

command="caddy"
command_args="run --config ${config} --pidfile ${pidfile}"
command_user="caddy:http"
command_background=yes

depend() {
	use net
	after dns
}

start_pre() {
	checkpath -q -d -o "${command_user}" "/run/${RC_SVCNAME}"
}