51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
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(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)
|
|
}
|
|
}
|
|
}
|