forked from dbogatov/nginx-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·60 lines (40 loc) · 1.01 KB
/
build.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
56
57
58
59
60
#!/usr/bin/env bash
set -e
function build {
rm -rf dist/
mkdir -p dist/sites-available
mkdir -p dist/snippets
source sites.sh
mkdir -p dist/tmp-erb
for site in "${!SITES[@]}"
do
echo "Generating $site..."
HOST=${site//./-}
if [ -n "${SITES[$site]}" ]; then
HOST=${SITES[$site]}
fi
UPSTREAM=${site//./_}
UPSTREAM=${UPSTREAM//-/_}
cp partials/proxy.erb dist/tmp-erb/$site
sed -i -e "s/__DOMAIN__/$site/g" dist/tmp-erb/$site
sed -i -e "s/__HOST__/$HOST/g" dist/tmp-erb/$site
sed -i -e "s/__UPSTREAM__/$UPSTREAM/g" dist/tmp-erb/$site
cd partials
erb -r ../render.rb ../dist/tmp-erb/$site > ../dist/sites-available/$site
cd ..
done
rm -rf dist/tmp-erb
cd sites
if [ $(ls -1 *.erb 2>/dev/null | wc -l) -gt 0 ]; then
for template in *.erb;
do
echo "Regenerating ${template%.*}..."
erb -r ../render.rb $template > ../dist/sites-available/${template%.*}
done
fi
cd ..
cp snippets/* dist/snippets/
cp nginx.conf mime.types dist/
echo "Build completed."
}
build