3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 21:39:25 +01:00
This commit is contained in:
Shivaram Lingamneni 2019-09-11 20:15:34 -04:00
parent 542177213e
commit 04b25eb6bf

View File

@ -39,6 +39,13 @@ func getPassword() string {
return strings.TrimSpace(text) return strings.TrimSpace(text)
} }
func fileDoesNotExist(file string) bool {
if _, err := os.Stat(file); os.IsNotExist(err) {
return true
}
return false
}
// implements the `oragono mkcerts` command // implements the `oragono mkcerts` command
func doMkcerts(configFile string, quiet bool) { func doMkcerts(configFile string, quiet bool) {
config, err := irc.LoadRawConfig(configFile) config, err := irc.LoadRawConfig(configFile)
@ -59,7 +66,7 @@ func doMkcerts(configFile string, quiet bool) {
if existingKey == conf.TLS.Key { if existingKey == conf.TLS.Key {
continue continue
} else { } else {
log.Fatal("Conflicting TLS key files for", conf.TLS.Cert) log.Fatal("Conflicting TLS key files for ", conf.TLS.Cert)
} }
} }
if !quiet { if !quiet {
@ -67,6 +74,9 @@ func doMkcerts(configFile string, quiet bool) {
} }
host := config.Server.Name host := config.Server.Name
cert, key := conf.TLS.Cert, conf.TLS.Key cert, key := conf.TLS.Cert, conf.TLS.Key
if !(fileDoesNotExist(cert) && fileDoesNotExist(key)) {
log.Fatalf("Preexisting TLS cert and/or key files: %s %s", cert, key)
}
err := mkcerts.CreateCert("Oragono", host, cert, key) err := mkcerts.CreateCert("Oragono", host, cert, key)
if err == nil { if err == nil {
if !quiet { if !quiet {