Skip to content

Commit

Permalink
chore: action update
Browse files Browse the repository at this point in the history
  • Loading branch information
yzy613 committed Feb 28, 2023
1 parent 85859e0 commit 6f97496
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 53 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Go

on:
push:
branches: [ master ]
tags: [ v* ]
branches: [ "master" ]
tags: [ "v*" ]
pull_request:
branches: [ master ]
branches: [ "master" ]

jobs:
build:
Expand All @@ -20,16 +20,16 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: "1.20"

- name: Build client
run: make -f Makefile.client

- name: Build server
run: make -f Makefile.server

- name: Upload release assets
uses: alexellis/upload-assets@0.3.0
- name: Upload release binaries
uses: alexellis/upload-assets@0.4.0
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion internal/client/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

var (
installPath = "/etc/systemd/system/" + RunningName + ".service"
installPath = "/etc/systemd/system/" + ProjName + ".service"
HttpsInsecure = false
)

Expand Down
2 changes: 1 addition & 1 deletion internal/client/dnspod.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func postman(url, src string) (dst []byte, err error) {
}
}(req.Body)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("User-Agent", RunningName+"/"+common.LocalVersion+" ()")
req.Header.Set("User-Agent", ProjName+"/"+common.LocalVersion+" ()")
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
Expand Down
78 changes: 39 additions & 39 deletions internal/client/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

const (
RunningName = "ddns-watchdog-client"
ProjName = "ddns-watchdog-client"
NetworkCardFileName = "network_card.json"
)

Expand All @@ -33,52 +33,52 @@ type AsyncServiceCallback func(enabledServices common.Enable, ipv4, ipv6 string)
func Install() (err error) {
if common.IsWindows() {
err = errors.New("windows 暂不支持安装到系统")
} else {
// 注册系统服务
if Client.CheckCycleMinutes == 0 {
err = errors.New("设置一下 " + ConfDirectoryName + "/" + ConfFileName + " 的 check_cycle_minutes 吧")
return
}
wd, err := os.Getwd()
if err != nil {
return err
}
serviceContent := []byte(
"[Unit]\n" +
"Description=" + RunningName + " Service\n" +
"After=network.target\n\n" +
"[Service]\n" +
"Type=simple\n" +
"WorkingDirectory=" + wd +
"\nExecStart=" + wd + "/" + RunningName + " -c " + ConfDirectoryName +
"\nRestart=on-failure\n" +
"RestartSec=2\n\n" +
"[Install]\n" +
"WantedBy=multi-user.target\n")
err = os.WriteFile(installPath, serviceContent, 0600)
if err != nil {
return err
}
log.Println("可以使用 systemctl 控制 " + RunningName + " 服务了")
return
}
// 注册系统服务
if Client.CheckCycleMinutes == 0 {
err = errors.New("设置一下 " + ConfDirectoryName + "/" + ConfFileName + " 的 check_cycle_minutes 吧")
return
}
wd, err := os.Getwd()
if err != nil {
return err
}
serviceContent := []byte(
"[Unit]\n" +
"Description=" + ProjName + " Service\n" +
"After=network.target\n\n" +
"[Service]\n" +
"Type=simple\n" +
"WorkingDirectory=" + wd +
"\nExecStart=" + wd + "/" + ProjName + " -c " + ConfDirectoryName +
"\nRestart=on-failure\n" +
"RestartSec=2\n\n" +
"[Install]\n" +
"WantedBy=multi-user.target\n")
err = os.WriteFile(installPath, serviceContent, 0600)
if err != nil {
return err
}
log.Println("可以使用 systemctl 管理 " + ProjName + " 服务了")
return
}

func Uninstall() (err error) {
if common.IsWindows() {
err = errors.New("windows 暂不支持安装到系统")
} else {
wd, err := os.Getwd()
if err != nil {
return err
}
err = os.Remove(installPath)
if err != nil {
return err
}
log.Println("卸载服务成功")
log.Println("若要完全删除,请移步到 " + wd + " 和 " + ConfDirectoryName + " 完全删除")
return
}
wd, err := os.Getwd()
if err != nil {
return err
}
err = os.Remove(installPath)
if err != nil {
return err
}
log.Println("卸载服务成功")
log.Println("若要完全删除,请移步到 " + wd + " 和 " + ConfDirectoryName + " 完全删除")
return
}

Expand Down
8 changes: 2 additions & 6 deletions internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
LocalVersion = "1.5.4-rc1"
LocalVersion = "1.5.4"
DefaultAPIUrl = "https://yzyweb.cn/ddns-watchdog"
DefaultIPv6APIUrl = "https://yzyweb.cn/ddns-watchdog6"
ProjectUrl = "https://github.com/yzy613/ddns-watchdog"
Expand Down Expand Up @@ -68,11 +68,7 @@ func FormatDirectoryPath(srcPath string) (dstPath string) {
}

func IsWindows() bool {
if runtime.GOOS == "windows" {
return true
} else {
return false
}
return runtime.GOOS == "windows"
}

func IsDirExistAndCreate(dirPath string) (err error) {
Expand Down

0 comments on commit 6f97496

Please sign in to comment.