Forgor to push 💀
This commit is contained in:
31
config.go
31
config.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func makeDirs() {
|
||||
@@ -21,17 +22,29 @@ func makeDirs() {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO make domain level configs override global config
|
||||
func createConfig() {
|
||||
confPath := "/etc/certman/certman.conf"
|
||||
configBytes := []byte("[Git]\nhost = github\nserver = https://gitea.instance.com\nusername = user\napi_token = xxxxxxxxxxxxxxxx\norg_name = org\ntemplate_name = template\n\n[Crypto]\ncert_path = /etc/certman/crypto/cert.pem\nkey_path = /etc/certman/crypto/key.pem")
|
||||
|
||||
createFile(confPath, configBytes)
|
||||
err = os.Mkdir("/var/local/certman", 0660)
|
||||
if err != nil {
|
||||
if !os.IsExist(err) {
|
||||
fmt.Printf("Unable to create certman directory: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func createNewDomainConfig(domain string) {
|
||||
data := []byte("[Cloudflare]\ncf_email = email@example.com\ncf_api_token = xxxxxxxxxxxxxxxx\n\n[Certificates]\ncerts_path = ./certs/" + domain + "\nsubdomains =")
|
||||
createFile("/etc/certman/"+domain+".conf", data)
|
||||
data := []byte(strings.ReplaceAll(defaultDomainConfig, "{domain}", domain))
|
||||
createFile("/etc/certman/conf/"+domain+".conf", 0755, data)
|
||||
}
|
||||
|
||||
func createNewDomainCertsDir(domain string) {
|
||||
err := os.Mkdir("/var/local/certman/"+domain, 0660)
|
||||
if err != nil {
|
||||
if os.IsExist(err) {
|
||||
fmt.Println("Directory already exists...")
|
||||
} else {
|
||||
fmt.Printf("Error creating certificate directory for %s: %v\n", domain, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user