Skip to content

Commit

Permalink
support different extensions for scripts (issue #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
reddec committed Jan 21, 2020
1 parent 35d1e53 commit 1ee87e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/tinc-boot/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ type Render interface {
}

func (cmd *Cmd) script(name string) func(render Render) error {
filename := filepath.Join(cmd.Dir(), name)
filename := filepath.Join(cmd.Dir(), name+scripts.Extension)
return func(render Render) error {
err := os.MkdirAll(filepath.Dir(filename), 0755)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions scripts/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"text/template"
)

const Extension = ""

var TincUp = template.Must(template.New("").Parse(`#!/usr/bin/env bash
ip addr add {{.Addr}}/{{.Mask}} dev $INTERFACE
ip link set dev $INTERFACE up
Expand Down
2 changes: 2 additions & 0 deletions scripts/scripts_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"text/template"
)

const Extension = ".bat"

var TincUp = template.Must(template.New("").Parse(`
netsh interface ip set dns '%INTERFACE%' static {{.Addr}} {{.MaskAsAddr}}
start /B {{.Bin}} monitor
Expand Down

0 comments on commit 1ee87e6

Please sign in to comment.