Pull request: 6717-fix-conf-symlink

Updates #6717.

Squashed commit of the following:

commit d17a6de1485e68887a1732dfaa6844f433519b9f
Merge: 806ff9bad 9305c4581
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Mon Apr 1 09:22:33 2024 +0800

    Merge remote-tracking branch 'origin/master' into 6717-fix-conf-symlink

    # Conflicts:
    #	CHANGELOG.md

commit 806ff9bad09e8bf253a1bdc379fbed2b1a56c5a7
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Thu Mar 28 09:00:00 2024 +0800

    home: imp code

commit 06dbcfead7c43fac146e92e4a83145dcd5c07b40
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Mar 27 13:55:30 2024 +0800

    all: changelog

commit 5476625eacfda06efec768865e0885c502d37607
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Mar 27 13:43:17 2024 +0800

    home: fix conf symlink usage
This commit is contained in:
Dimitry Kolyshev 2024-04-01 11:31:51 +03:00
parent 9305c45813
commit 7d9f33b2f0
3 changed files with 12 additions and 7 deletions

View File

@ -38,8 +38,11 @@ NOTE: Add new changes BELOW THIS COMMENT.
### Fixed
- Resetting DNS upstream mode when applying unrelated settings ([#6851]).
- Symbolic links to config YAML are replaced by a copy of the real file by AGH
after startup ([#6717]).
[#5829]: https://github.com/AdguardTeam/AdGuardHome/issues/5829
[#6717]: https://github.com/AdguardTeam/AdGuardHome/issues/6717
[#6851]: https://github.com/AdguardTeam/AdGuardHome/issues/6851
<!--

View File

@ -539,13 +539,13 @@ func fatalOnError(err error) {
// run configures and starts AdGuard Home.
func run(opts options, clientBuildFS fs.FS, done chan struct{}) {
// Configure config filename.
initConfigFilename(opts)
// Configure working dir and config path.
// Configure working dir.
err := initWorkingDir(opts)
fatalOnError(err)
// Configure config filename.
initConfigFilename(opts)
// Configure log level and output.
err = configureLogger(opts)
fatalOnError(err)
@ -760,11 +760,12 @@ func writePIDFile(fn string) bool {
}
// initConfigFilename sets up context config file path. This file path can be
// overridden by command-line arguments, or is set to default.
// overridden by command-line arguments, or is set to default. Must only be
// called after initializing the workDir with initWorkingDir.
func initConfigFilename(opts options) {
confPath := opts.confFilename
if confPath == "" {
Context.confFilePath = "AdGuardHome.yaml"
Context.confFilePath = filepath.Join(Context.workDir, "AdGuardHome.yaml")
return
}

View File

@ -271,11 +271,12 @@ func handleServiceCommand(s service.Service, action string, opts options) (err e
return fmt.Errorf("failed to run service: %w", err)
}
case "install":
initConfigFilename(opts)
if err = initWorkingDir(opts); err != nil {
return fmt.Errorf("failed to init working dir: %w", err)
}
initConfigFilename(opts)
handleServiceInstallCommand(s)
case "uninstall":
handleServiceUninstallCommand(s)