blob: 54c0545bdc4a4453879bccdfea324490daac4959 (
plain) (
blame)
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
|
#!/bin/sh
# acme_certs='site1 site2'
# acme_site1_domains='example.net example.com'
: ${acme_certs:=''}
vhosts_dir=/usr/local/www
# Install packages.
pkg install -y \
nginx \
rsync
# Create ZFS dataset for webroots.
create_dataset -o "mountpoint=${vhosts_dir}" "${state_dataset}/vhosts"
zfs set \
com.sun:auto-snapshot:daily=true \
com.sun:auto-snapshot:weekly=true \
"${state_dataset}/vhosts"
# Configure nginx.
install_template -m 0644 "${nginx_conf_dir}/nginx.conf"
[ -f "${nginx_conf_dir}/vhosts.conf" ] || install -Cv -m 0644 /dev/null "${nginx_conf_dir}/vhosts.conf"
sysrc -v nginx_enable=YES
service nginx restart
install_file -m 0644 /etc/newsyslog.conf.d/nginx.conf
# Acquire public TLS certificates.
install_template -m 0600 /usr/local/etc/sudoers.d/acme
for certname in $acme_certs; do
eval "acme_domains=\${acme_${certname}_domains}"
acme_install_certificate \
-g "$nginx_user" \
-r 'sudo service nginx reload' \
"$certname" \
$acme_domains
done
# Now that we have the ACME certs, add the vhosts.
install_template -m 0644 "${nginx_conf_dir}/vhosts.conf"
service nginx restart
# If any acmeproxy_domains were specified, setup the SFTP proxy.
acme_setup_proxy
|