Skip to content

Commit 0992082

Browse files
committed
fix windows working directory
1 parent ef06ec7 commit 0992082

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

domain/monitor/config.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package monitor
22

33
import (
44
cmd2 "github.com/reddec/tinc-boot/cmd"
5+
"os"
56
"path/filepath"
67
"time"
78
)
@@ -19,7 +20,13 @@ type Config struct {
1920

2021
func (cfg *Config) Events() *monitorEvents { return &cfg.events }
2122
func (cfg *Config) Root() string {
22-
r, err := filepath.Abs(cfg.Dir)
23+
var dir = cfg.Dir
24+
if cfg.Dir == "." {
25+
if d, err := os.Getwd(); err == nil {
26+
dir = d
27+
}
28+
}
29+
r, err := filepath.Abs(dir)
2330
if err != nil {
2431
panic(err)
2532
}

domain/monitor/service.go

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (ms *service) Address() string { return ms.address }
115115
func (ms *service) reindexLoop() {
116116
reindexTimer := time.NewTicker(ms.cfg.Reindex)
117117
defer reindexTimer.Stop()
118+
ms.askForIndex()
118119
for {
119120
select {
120121
case <-ms.globalContext.Done():

scripts/scripts_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Extension = ".bat"
1010

1111
var TincUp = template.Must(template.New("").Parse(`
1212
netsh interface ipv4 set address name="%INTERFACE%" static {{.Addr}} {{.MaskAsAddr}} store=persistent
13-
cd "%~dp0r"
13+
cd "%~dp0"
1414
start /B "" "{{.Bin}}" monitor
1515
`))
1616

0 commit comments

Comments
 (0)