blob: 4ca256cebdd2c9e143d6ca48ad6645533699a39d (
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
|
#!/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;
}
}
}
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
else
/usr/bin/certbot -n --agree-tos -m doy@tozt.net --nginx -d tozt.net --config-dir "$config_dir"
fi
|