Skip to content

Commit

Permalink
fix: init SSH path if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyYe committed Jun 22, 2021
1 parent 73d80bd commit e14f675
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/skm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"

"github.com/TimothyYe/skm"
"github.com/fatih/color"

cli "gopkg.in/urfave/cli.v1"
)
Expand Down Expand Up @@ -59,6 +60,17 @@ func mustGetEnvironment(ctx *cli.Context) *skm.Environment {
if storePath == "" || sshPath == "" {
log.Fatalf("store-path (%v) and ssh-path (%v) have to be set!", storePath, sshPath)
}

// create SSH path if it doesn't exist
if _, err := os.Stat(sshPath); os.IsNotExist(err) {
err := os.Mkdir(sshPath, 0755)

if err != nil {
color.Red("%sFailed to initialize SSH path!", skm.CrossSymbol)
return nil
}
}

if resticPath == "" {
resticPath, _ = exec.LookPath("restic")
}
Expand Down

0 comments on commit e14f675

Please sign in to comment.