blob: a90368f109cdc72e628361d5e7b925f1088d3657 (
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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/usr/bin/env bash
set -eu
set -o pipefail
config_dir="$1"
if systemctl is-active -q nginx; then
is_running=1
else
is_running=
fi
cleanup() {
if [ -z "$is_running" ]; then
systemctl stop nginx
fi
if [ -e /etc/nginx/nginx.conf.backup ]; then
mv /etc/nginx/nginx.conf.backup /etc/nginx.conf
fi
}
trap cleanup EXIT
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
cat > /etc/nginx/nginx.conf <<EOF
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80 default;
server_name tozt.net;
location / {
root /tmp;
}
}
server {
listen 80;
server_name blog.tozt.net;
location / {
root /tmp;
}
}
server {
listen 80;
server_name paste.tozt.net;
location / {
root /tmp;
}
}
server {
listen 80;
server_name git.tozt.net;
location / {
root /tmp;
}
}
server {
listen 80;
server_name rss.tozt.net;
location / {
root /tmp;
}
}
server {
listen 80;
server_name munin.tozt.net;
location / {
root /tmp;
}
}
server {
listen 80;
server_name metabase.tozt.net;
location / {
root /tmp;
}
}
server {
listen 80;
server_name rc-teleterm.tozt.net;
location / {
root /tmp;
}
}
}
EOF
if [ -z "$is_running" ]; then
systemctl start nginx
fi
if [ -z "$config_dir" ]; then
/usr/bin/certbot -n --agree-tos -m doy@tozt.net --nginx -d tozt.net -d blog.tozt.net -d paste.tozt.net -d git.tozt.net -d rss.tozt.net -d munin.tozt.net -d metabase.tozt.net -d rc-teleterm.tozt.net -d bitwarden.tozt.net
else
/usr/bin/certbot -n --agree-tos -m doy@tozt.net --nginx -d tozt.net -d blog.tozt.net -d paste.tozt.net -d git.tozt.net -d rss.tozt.net -d munin.tozt.net -d metabase.tozt.net -d rc-teleterm.tozt.net -d bitwarden.tozt.net --config-dir "$config_dir"
fi
|