Add support for ~ expansion for DB filepath

This commit is contained in:
David Stotijn
2020-09-28 21:53:51 +02:00
parent b17c70bc0a
commit ce4805452f
2 changed files with 7 additions and 1 deletions

View File

@ -32,7 +32,7 @@ var (
func main() {
flag.StringVar(&caCertFile, "cert", "~/.hetty/hetty_cert.pem", "CA certificate filepath. Creates a new CA certificate is file doesn't exist")
flag.StringVar(&caKeyFile, "key", "~/.hetty/hetty_key.pem", "CA private key filepath. Creates a new CA private key if file doesn't exist")
flag.StringVar(&dbFile, "db", "~/hetty/hetty.bolt", "Database file path")
flag.StringVar(&dbFile, "db", "~/.hetty/hetty.bolt", "Database file path")
flag.StringVar(&addr, "addr", ":8080", "TCP address to listen on, in the form \"host:port\"")
flag.StringVar(&adminPath, "adminPath", "", "File path to admin build")
flag.Parse()
@ -46,6 +46,10 @@ func main() {
if err != nil {
log.Fatalf("[FATAL] Could not parse CA private key filepath: %v", err)
}
dbFile, err := homedir.Expand(dbFile)
if err != nil {
log.Fatalf("[FATAL] Could not parse CA private key filepath: %v", err)
}
// Load existing CA certificate and key from disk, or generate and write
// to disk if no files exist yet.