1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Package tmpl embeds every file Skiff writes out to the host - jail
// config, rc.d script, nginx vhost, git hook - so the whole tool ships as
// one binary with nothing extra to install alongside it.
package tmpl
import (
"bytes"
_ "embed"
"text/template"
)
//go:embed jail.conf.tmpl
var jailConf string
//go:embed rc.d.tmpl
var rcScript string
//go:embed nginx-app.conf.tmpl
var nginxApp string
//go:embed post-receive.tmpl
var postReceive string
func Render(text string, data any) (string, error) {
t, err := template.New("t").Parse(text)
if err != nil {
return "", err
}
var buf bytes.Buffer
if err := t.Execute(&buf, data); err != nil {
return "", err
}
return buf.String(), nil
}
type JailConfData struct {
Name string
JailRoot string
IP string
Iface string
}
func JailConf(d JailConfData) (string, error) { return Render(jailConf, d) }
type RCData struct{ Name string }
func RCScript(d RCData) (string, error) { return Render(rcScript, d) }
// NginxDomain is one hostname in an app's vhost. CertLive gates HTTPS.
type NginxDomain struct {
Hostname string
Primary bool
CertLive bool
}
type NginxAppData struct {
Name string
IP string
Port int
Webroot string // ACME HTTP-01 challenge webroot, shared across apps
PrimaryHostname string
PrimaryCertLive bool
PrimaryLiveDir string // certbot's live dir for the app's shared cert
Domains []NginxDomain
}
func NginxApp(d NginxAppData) (string, error) { return Render(nginxApp, d) }
type PostReceiveData struct{ Name string }
func PostReceive(d PostReceiveData) (string, error) { return Render(postReceive, d) }
|