forked from dbogatov/nginx-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·50 lines (35 loc) · 1.05 KB
/
test.sh
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
#!/bin/bash
set -e
function setup {
source sites.sh
adduser -D www-data
cp -r dist/* /etc/nginx
mkdir -p /etc/nginx/sites-enabled
mkdir -p /etc/nginx/ssl
mkdir -p /etc/ssl/certs/
openssl dhparam -out /etc/ssl/certs/dhparam.pem 256
openssl req \
-x509 \
-nodes \
-days 365 \
-newkey rsa:2048 \
-keyout /etc/nginx/ssl/nginx.key \
-out /etc/nginx/ssl/nginx.crt \
-subj "/C=NL/ST=Whatever/L=Whatever/O=Whatever/OU=Whatever/CN=whatever.example.com"
mkdir -p /etc/letsencrypt/live/dbogatov.org
cp /etc/nginx/ssl/nginx.key /etc/letsencrypt/live/dbogatov.org/
cp /etc/nginx/ssl/nginx.crt /etc/letsencrypt/live/dbogatov.org/
cd /etc/nginx/sites-available/
for site in *;
do
ln -s /etc/nginx/sites-available/$site /etc/nginx/sites-enabled/$site
mkdir -p /etc/letsencrypt/live/$site
cp /etc/nginx/ssl/nginx.key /etc/letsencrypt/live/$site/
cp /etc/nginx/ssl/nginx.crt /etc/letsencrypt/live/$site/
sed -i 's/fullchain.pem/nginx.crt/g' $site
sed -i 's/privkey.pem/nginx.key/g' $site
done
echo "Setup completed."
}
setup
nginx -t