git: 940d212ecd7c - main - www/adguardhome: Move config and data files to a new location
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 22 Jan 2023 17:42:35 UTC
The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=940d212ecd7c7226713724aebd6df76483100c3b commit 940d212ecd7c7226713724aebd6df76483100c3b Author: Yuri Victorovich <yuri@FreeBSD.org> AuthorDate: 2023-01-22 17:39:50 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2023-01-22 17:42:32 +0000 www/adguardhome: Move config and data files to a new location ... when these files are present at old locations. PR: 269083 Reported by: Jony Hudson <bsd@j-star.org> --- UPDATING | 12 ++++++++++++ www/adguardhome/Makefile | 2 +- www/adguardhome/files/adguardhome.in | 32 +++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/UPDATING b/UPDATING index 9a7db786a272..d4fe28dc24ae 100644 --- a/UPDATING +++ b/UPDATING @@ -20884,3 +20884,15 @@ or The default installation is now configured for running bitlbee as user 'nobody' by default. Make sure any existing configuration files are readable by that user. + +20080122: + AFFECTS: users of www/adguardhome + AUTHOR: yuri@FreeBSD.org + + www/adguardhome now stores configuratio and database information in + $PREFIX/etc/AdGuardHome.yaml and /var/db/adguardhome/data + respectively. 'service adguardhome start' attempts to move config + and data files to the new location but it required manual move when + both old and new files are present. + 'service adguardhome start' prints a warning with relevant + location information. diff --git a/www/adguardhome/Makefile b/www/adguardhome/Makefile index c3f3023f16ad..bb7d8fe62725 100644 --- a/www/adguardhome/Makefile +++ b/www/adguardhome/Makefile @@ -1,7 +1,7 @@ PORTNAME= adguardhome DISTVERSIONPREFIX= v DISTVERSION= 0.107.21 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= www MAINTAINER= yuri@FreeBSD.org diff --git a/www/adguardhome/files/adguardhome.in b/www/adguardhome/files/adguardhome.in index 6a9fd0fb6532..474e2c8a83fa 100644 --- a/www/adguardhome/files/adguardhome.in +++ b/www/adguardhome/files/adguardhome.in @@ -15,10 +15,15 @@ rcvar=adguardhome_enable load_rc_config $name : ${adguardhome_enable:=NO} -: ${adguardhome_config:=/usr/local/etc/AdGuardHome.yaml} +: ${adguardhome_config:=%%PREFIX%%/etc/AdGuardHome.yaml} : ${adguardhome_user:=%%USER%%} : ${adguardhome_group:=%%GROUP%%} : ${adguardhome_work_dir:=/var/db/adguardhome} +: ${adguardhome_work_dir_data:=/var/db/adguardhome/data} + +# old values +: ${adguardhome_config_old:=%%PREFIX%%/bin/AdGuardHome.yaml} +: ${adguardhome_work_dir_data_old:=%%PREFIX%%/bin/data} logfile="/var/log/${name}.log" @@ -30,6 +35,31 @@ start_precmd="${name}_prestart" adguardhome_prestart() { + # check if the old config exists + if [ -f ${adguardhome_config_old} ] || [ -d ${adguardhome_work_dir_data_old} ]; then + if ! [ -f ${adguardhome_config} ] && ! [ -d ${adguardhome_work_dir_data} ]; then # old config exists, new config doesn't exist + # move old config to new locations + if [ -f ${adguardhome_config_old} ]; then + echo "moving old config ${adguardhome_config_old} to the new location ${adguardhome_config}" + mv ${adguardhome_config_old} ${adguardhome_config} + fi + if [ -d ${adguardhome_work_dir_data_old} ]; then + install -d -m 0750 -o ${adguardhome_user} -g ${adguardhome_group} \ + ${adguardhome_work_dir} + echo "moving old config ${adguardhome_work_dir_data_old} to the new location ${adguardhome_work_dir_data}" + mv ${adguardhome_work_dir_data_old} ${adguardhome_work_dir_data} + fi + else # both old and new config exist + echo "(!!!) WARNING ==================================================================" + echo "(!!!) WARNING Both old and new configs exist" + echo "(!!!) WARNING Please choose which configs do you need and remove the old configs" + echo "(!!!) WARNING OLD config locations: ${adguardhome_config_old} ${adguardhome_work_dir_data_old}" + echo "(!!!) WARNING NEW config locations: ${adguardhome_config} ${adguardhome_work_dir_data}" + echo "(!!!) WARNING ==================================================================" + fi + fi + + # install dir if [ ! -d ${adguardhome_work_dir} ]; then install -d -m 0750 -o ${adguardhome_user} -g ${adguardhome_group} \ ${adguardhome_work_dir}