mirror of
https://github.com/Luzifer/vault-openvpn.git
synced 2024-12-26 06:41:20 +00:00
Allow path to templates to be configured
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
bf3f4fafe1
commit
3874e1dc79
1 changed files with 4 additions and 1 deletions
5
main.go
5
main.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -46,6 +47,7 @@ var (
|
||||||
CertTTL time.Duration `flag:"ttl" vardefault:"ttl" description:"Set the TTL for this certificate"`
|
CertTTL time.Duration `flag:"ttl" vardefault:"ttl" description:"Set the TTL for this certificate"`
|
||||||
|
|
||||||
LogLevel string `flag:"log-level" vardefault:"log-level" description:"Log level to use (debug, info, warning, error)"`
|
LogLevel string `flag:"log-level" vardefault:"log-level" description:"Log level to use (debug, info, warning, error)"`
|
||||||
|
TemplatePath string `flag:"template-path" vardefault:"template-path" description:"Path to read the client.conf / server.conf template from"`
|
||||||
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
|
@ -55,6 +57,7 @@ var (
|
||||||
"auto-revoke": "true",
|
"auto-revoke": "true",
|
||||||
"ttl": "8760h",
|
"ttl": "8760h",
|
||||||
"log-level": "info",
|
"log-level": "info",
|
||||||
|
"template-path": ".",
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "dev"
|
version = "dev"
|
||||||
|
@ -281,7 +284,7 @@ func generateCertificateConfig(tplName, fqdn string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderTemplate(tplName string, tplv *templateVars) error {
|
func renderTemplate(tplName string, tplv *templateVars) error {
|
||||||
raw, err := ioutil.ReadFile(tplName)
|
raw, err := ioutil.ReadFile(path.Join(cfg.TemplatePath, tplName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue