blob: cb496f83d4b57fcd48741a22296991a82e1b75c5 (
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
|
#!/usr/bin/env bash
set -eu
set -o pipefail
# XXX update to real domain name
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 new.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 new.tozt.net
else
/usr/bin/certbot -n --agree-tos -m doy@tozt.net --nginx -d new.tozt.net --config-dir "$config_dir"
fi
|