Forgor to push 💀

This commit is contained in:
2026-02-18 21:58:56 +01:00
parent ac98a90222
commit 9ea5b8668f
13 changed files with 473 additions and 153 deletions

View File

@@ -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)
}
}
}