Skip to content

Commit

Permalink
Pull request: 6717-fix-conf-symlink
Browse files Browse the repository at this point in the history
Updates #6717.

Squashed commit of the following:

commit d17a6de
Merge: 806ff9b 9305c45
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 806ff9b
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Thu Mar 28 09:00:00 2024 +0800

    home: imp code

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

    all: changelog

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

    home: fix conf symlink usage
  • Loading branch information
Mizzick committed Apr 1, 2024
1 parent 9305c45 commit 7d9f33b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!--
Expand Down
13 changes: 7 additions & 6 deletions internal/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion internal/home/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7d9f33b

Please sign in to comment.