# Copyright 2021-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit check-reqs systemd go-module-fem

go-module_set_globals

DESCRIPTION="Limited DNS server with RESTful API to handle ACME DNS challenges securely"
HOMEPAGE="https://github.com/acme-dns/acme-dns"
SRC_URI="
	https://github.com/acme-dns/acme-dns/archive/v${PV}.tar.gz -> ${P}.gh.tar.gz
	${GO_FEM_SRC_URI}
"

LICENSE="MIT Apache-2.0 BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="systemd"

RDEPEND="
	acct-user/acme-dns
	acct-group/acme-dns
	sys-libs/libcap
	!systemd? ( sys-apps/openrc )
"

EGO_PN="github.com/acme-dns/acme-dns"

CHECKREQS_DISK_BUILD=1G

src_install() {
	go-module-fem_src_install

	insinto /etc/acme-dns
	doins config.cfg

	sed -i 's#usr/local#usr#g' acme-dns.service || die
	systemd_dounit acme-dns.service

	newconfd "${FILESDIR}/${PN}-confd" "${PN}"
	newinitd "${FILESDIR}/${PN}-initd" "${PN}"

	keepdir "/var/lib/${PN}"
}