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 <A.Garipov@AdGuard.COM>
Date:   Mon Feb 1 13:24:22 2021 +0300

    scripts: fix removing

commit d199998e4bc0c2d8f1facac5fed30011cae1166e
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Feb 1 13:15:51 2021 +0300

    scripts: make sure wd is set when inistalling
This commit is contained in:
Ainar Garipov 2021-02-01 14:12:57 +03:00
parent a83c3cf2ea
commit 6f155f78b6
2 changed files with 10 additions and 3 deletions

View File

@ -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"
`

View File

@ -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}"