From da9c4920abf97231e190b3c820891d142ed99021 Mon Sep 17 00:00:00 2001 From: Manuel Date: Thu, 4 Jan 2018 13:41:14 +0100 Subject: [PATCH] add log directory creation if it does not exist. --- main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.go b/main.go index de084f4..614ee1b 100644 --- a/main.go +++ b/main.go @@ -135,6 +135,19 @@ func server(c *cli.Context) error { return err } + // check for the logdir existence + logsLocation, e := os.Stat(c.String("logs-location")) + if e != nil { + err = os.MkdirAll(c.String("logs-location"), os.ModeDir | os.FileMode(0750) ) + if err != nil { + return err + } + } else { + if !logsLocation.IsDir() { + log.Fatal("log directory cannnot be created") + } + } + opts := []ssh.Option{} // custom PublicKeyAuth handler opts = append(opts, ssh.PublicKeyAuth(publicKeyAuthHandler(db, c)))