diff --git a/home/home.go b/home/home.go index 3c2dce58..10235664 100644 --- a/home/home.go +++ b/home/home.go @@ -147,13 +147,8 @@ func version() string { // run is a blocking method! // nolint func run(args options) { - // config file path can be overridden by command-line arguments: - if args.configFilename != "" { - Context.configFilename = args.configFilename - } else { - // Default config file name - Context.configFilename = "AdGuardHome.yaml" - } + // configure config filename + initConfigFilename(args) // configure working dir and config path initWorkingDir(args) @@ -411,6 +406,16 @@ func writePIDFile(fn string) bool { return true } +func initConfigFilename(args options) { + // config file path can be overridden by command-line arguments: + if args.configFilename != "" { + Context.configFilename = args.configFilename + } else { + // Default config file name + Context.configFilename = "AdGuardHome.yaml" + } +} + // initWorkingDir initializes the workDir // if no command-line arguments specified, we use the directory where our binary file is located func initWorkingDir(args options) { diff --git a/home/service.go b/home/service.go index b48c743b..fbe612cf 100644 --- a/home/service.go +++ b/home/service.go @@ -164,6 +164,8 @@ func handleServiceControlAction(opts options) { log.Fatalf("Failed to run service: %s", err) } } else if action == "install" { + initConfigFilename(opts) + initWorkingDir(opts) handleServiceInstallCommand(s) } else if action == "uninstall" { handleServiceUninstallCommand(s)