From a7332425a6539902ddb228d0fa73d72bdfcf9704 Mon Sep 17 00:00:00 2001 From: blacktop Date: Mon, 19 Mar 2018 18:47:52 -0600 Subject: [PATCH] mk config dir if doesn't exist --- VERSION | 2 +- server/utils.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f589c86..e7b2312 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -18.03.2-dev \ No newline at end of file +18.03.3-dev \ No newline at end of file diff --git a/server/utils.go b/server/utils.go index b315f70..8d5d722 100644 --- a/server/utils.go +++ b/server/utils.go @@ -1,6 +1,7 @@ package main import ( + "os" "path/filepath" "github.com/kabukky/httpscerts" @@ -10,11 +11,16 @@ import ( // GenerateCerts generates SSL certs for vm-proxy server func GenerateCerts(host string) error { + home, err := homedir.Dir() if err != nil { return errors.Wrap(err, "could not detect users home directory") } + if _, err := os.Stat(filepath.Join(home, ".vmproxy")); os.IsNotExist(err) { + os.Mkdir(filepath.Join(home, ".vmproxy"), os.ModePerm) + } + certPath := filepath.Join(home, ".vmproxy", "cert.pem") keyPath := filepath.Join(home, ".vmproxy", "key.pem")