Skip to content

Commit

Permalink
Revert #579 (#604)
Browse files Browse the repository at this point in the history
* fix: different `configFilePath` for normal and SYSTEM users

In Windows, the home directories for normal user and SYSTEM user are different. Add `-c` option to fix this issue.

* Revert #579

This reverts commit 8c4974a.
  • Loading branch information
WaterLemons2k authored Mar 11, 2023
1 parent f3e1924 commit 51cce0d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
12 changes: 1 addition & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,12 @@ func getService() service.Service {
options["SysvScript"] = sysvScript
}

dir, err := os.UserHomeDir()
if err != nil {
log.Println("Getting Home directory failed: ", err)
}

svcConfig := &service.Config{
Name: "ddns-go",
DisplayName: "ddns-go",
Description: "简单好用的DDNS。自动更新域名解析到公网IP(支持阿里云、腾讯云dnspod、Cloudflare、Callback、华为云、百度云、porkbun、GoDaddy、Google Domains)",
Arguments: []string{"-l", *listen, "-f", strconv.Itoa(*every)},
Arguments: []string{"-l", *listen, "-f", strconv.Itoa(*every), "-c", *configFilePath},
Option: options,
EnvVars: map[string]string{"HOME": dir},
}

if *configFilePath != util.GetConfigFilePathDefault() {
svcConfig.Arguments = append(svcConfig.Arguments, "-c", *configFilePath)
}

if *noWebService {
Expand Down
3 changes: 1 addition & 2 deletions util/user.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"log"
"os"
)

Expand All @@ -20,7 +19,7 @@ func GetConfigFilePath() string {
func GetConfigFilePathDefault() string {
dir, err := os.UserHomeDir()
if err != nil {
log.Println("Getting Home directory failed: ", err)
// log.Println("Getting Home directory failed: ", err)
return "../.ddns_go_config.yaml"
}
return dir + string(os.PathSeparator) + ".ddns_go_config.yaml"
Expand Down

0 comments on commit 51cce0d

Please sign in to comment.