38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func makeDirs() {
|
|
err := os.MkdirAll("/etc/certman", 0775)
|
|
if err != nil {
|
|
if !os.IsExist(err) {
|
|
fmt.Println("Unable to create config directory")
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
err = os.Mkdir("/etc/certman/conf", 0775)
|
|
if err != nil {
|
|
if !os.IsExist(err) {
|
|
fmt.Println("Unable to create config directory")
|
|
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)
|
|
}
|
|
|
|
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)
|
|
}
|