Skip to content

Commit

Permalink
Create wirey folder if not exists - fixes #5
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Fontana <[email protected]>
  • Loading branch information
fntlnz committed Apr 27, 2018
1 parent eaca900 commit a67e12f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/wirey/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/influxdata/wirey/backend"
Expand Down Expand Up @@ -32,6 +33,13 @@ var rootCmd = &cobra.Command{
log.Fatal(err)
}

privKeyBaseDir := filepath.Dir(privateKeyPath)
if _, err := os.Stat(privKeyBaseDir); os.IsNotExist(err) {
if err := os.Mkdir(privKeyBaseDir, 0600); err != nil {
log.Fatal("Unable to create the base directory for the wirey private key: %s - %s", privKeyBaseDir, err.Error())
}
}

i, err := backend.NewInterface(b, ifname, fmt.Sprintf("%s:%s", endpoint, endpointPort), ipAddr, privateKeyPath)

if err != nil {
Expand Down

0 comments on commit a67e12f

Please sign in to comment.