-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·55 lines (41 loc) · 1.04 KB
/
bootstrap.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
51
52
53
54
55
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Default Host not given"
echo "usage: bootstrap.sh DEFAULT_HOST"
exit 1
fi
PREFIX="$(pwd | sed 's/\//\\\//g')"
DEFAULT_HOST="$1"
echo "Copying scripts"
if [ ! -d scripts ]; then
mkdir scripts
fi
cp -a templates/scripts/* scripts/
sed -i "s/{{ PREFIX }}/${PREFIX}/g" scripts/nginx_genconf
sed -i "s/{{ PREFIX }}/${PREFIX}/g" scripts/nginx_enable
sed -i "s/{{ PREFIX }}/${PREFIX}/g" scripts/nginx_disable
sed -i "s/{{ PREFIX }}/${PREFIX}/g" scripts/nginx_list
if [ ! -f dhparam ]; then
echo "Creating dhparam"
openssl dhparam -out dhparam 4096
else
echo "Using existing dhparam"
fi
echo "Creating default host"
if [ ! -d snippets/ssl ]; then
mkdir snippets/ssl
fi
scripts/nginx_genconf ssl "${DEFAULT_HOST}"
cp templates/nginx.conf nginx.conf
sed -i "s/{{ DEFAULT_HOST }}/${DEFAULT_HOST}/g" nginx.conf
if [ ! -d sites-available ]; then
mkdir sites-available
fi
if [ ! -d sites-enabled ]; then
mkdir sites-enabled
fi
# Clean
rm -r templates/scripts
rm templates/nginx.conf
rm -rf .git
rm bootstrap.sh