When starting the adguardhome service after installing the port or package, it writes an AdGuardHome.yaml config file, a data directory, and possibly other files to /usr/local/bin/. This is because AdGuard Home defaults to the directory of the binary for both its config file and working directory. Here is a patch that adds variables with reasonable defaults for adguardhome’s config and work-dir arguments to the rc.d script: ``` diff --git a/www/adguardhome/Makefile b/www/adguardhome/Makefile index aa0996e711ef..b329ee41c71b 100644 --- a/www/adguardhome/Makefile +++ b/www/adguardhome/Makefile @@ -27,7 +27,8 @@ GO_BUILDFLAGS= -ldflags="-s -w -X github.com/AdguardTeam/AdGuardHome/internal/v DEV_UPDATE_MODE= no USER= root # it has to run as root because it listens on the privileged DNS port -SUB_LIST= USER=${USER} +GROUP= wheel +SUB_LIST= USER=${USER} GROUP=${GROUP} USE_RC_SUBR= ${PORTNAME} CPE_VENDOR= adguard diff --git a/www/adguardhome/files/adguardhome.in b/www/adguardhome/files/adguardhome.in index 902745da6a35..6a9fd0fb6532 100644 --- a/www/adguardhome/files/adguardhome.in +++ b/www/adguardhome/files/adguardhome.in @@ -14,12 +14,26 @@ rcvar=adguardhome_enable load_rc_config $name -adguardhome_enable=${adguardhome_enable:-"NO"} +: ${adguardhome_enable:=NO} +: ${adguardhome_config:=/usr/local/etc/AdGuardHome.yaml} +: ${adguardhome_user:=%%USER%%} +: ${adguardhome_group:=%%GROUP%%} +: ${adguardhome_work_dir:=/var/db/adguardhome} logfile="/var/log/${name}.log" procname=%%PREFIX%%/bin/adguardhome command="/usr/sbin/daemon" -command_args="-u %%USER%% -o ${logfile} -t ${name} %%PREFIX%%/bin/adguardhome" +command_args="-u ${adguardhome_user} -o ${logfile} -t ${name} %%PREFIX%%/bin/adguardhome -c ${adguardhome_config} -w ${adguardhome_work_dir}" + +start_precmd="${name}_prestart" + +adguardhome_prestart() +{ + if [ ! -d ${adguardhome_work_dir} ]; then + install -d -m 0750 -o ${adguardhome_user} -g ${adguardhome_group} \ + ${adguardhome_work_dir} + fi +} run_rc_command "$1" ```
Committed, thanks!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=95bf6629820c81523de4693a7c6299ed62c7e1f6 commit 95bf6629820c81523de4693a7c6299ed62c7e1f6 Author: Tobias Bölz <freebsd-bugs@boelz.eu> AuthorDate: 2023-01-13 07:16:44 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2023-01-13 07:19:27 +0000 www/adguardhome: Make AdGuardHome to write files into a dedicated directory PR: 268890 www/adguardhome/Makefile | 4 +++- www/adguardhome/files/adguardhome.in | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)
Just noting that this breaks existing installations, details here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269083