From 6f155f78b6ea7811417221b67c4f2fa6704a68ff Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Mon, 1 Feb 2021 14:12:57 +0300 Subject: [PATCH] Pull request: scripts: make sure wd is set when inistalling Merge in DNS/adguard-home from 2614-install-wd to master Updates #2614. Squashed commit of the following: commit 8e59fa29138654326a66dbf5d165fa49a5aec46e Author: Ainar Garipov Date: Mon Feb 1 13:24:22 2021 +0300 scripts: fix removing commit d199998e4bc0c2d8f1facac5fed30011cae1166e Author: Ainar Garipov Date: Mon Feb 1 13:15:51 2021 +0300 scripts: make sure wd is set when inistalling --- internal/home/service.go | 9 ++++++++- scripts/install.sh | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/home/service.go b/internal/home/service.go index aa243634..3d817446 100644 --- a/internal/home/service.go +++ b/internal/home/service.go @@ -15,6 +15,9 @@ import ( "github.com/kardianos/service" ) +// TODO(a.garipov): Move shell templates into actual files. Either during the +// v0.106.0 cycle using packr or during the following cycle using go:embed. + const ( launchdStdoutPath = "/var/log/AdGuardHome.stdout.log" launchdStderrPath = "/var/log/AdGuardHome.stderr.log" @@ -504,6 +507,10 @@ status() { } ` +// TODO(a.garipov): Don't use .WorkingDirectory here. There are currently no +// guarantees that it will actually be the required directory. +// +// See https://github.com/AdguardTeam/AdGuardHome/issues/2614. const freeBSDScript = `#!/bin/sh # PROVIDE: {{.Name}} # REQUIRE: networking @@ -514,6 +521,6 @@ name="{{.Name}}" {{.Name}}_user="root" pidfile="/var/run/${name}.pid" command="/usr/sbin/daemon" -command_args="-P ${pidfile} -r -f {{.WorkingDirectory}}/{{.Name}}" +command_args="-P ${pidfile} -f -r {{.WorkingDirectory}}/{{.Name}}" run_rc_command "$1" ` diff --git a/scripts/install.sh b/scripts/install.sh index ecc2303b..551f84fc 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -230,8 +230,8 @@ main() { unpack "${PKG_NAME}" "${OUT_DIR}" "${PKG_EXT}" || error_exit "Cannot unpack the package" - # Install AdGuard Home service and run it - ${AGH_DIR}/AdGuardHome -s install || error_exit "Cannot install AdGuardHome as a service" + # Install AdGuard Home service and run it. + ( cd "${AGH_DIR}" && ./AdGuardHome -s install || error_exit "Cannot install AdGuardHome as a service" ) rm "${PKG_NAME}"