-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·65 lines (52 loc) · 2.36 KB
/
Copy pathbuild
File metadata and controls
executable file
·65 lines (52 loc) · 2.36 KB
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
61
62
63
64
65
#!/bin/bash
if [[ -z "$ENV" ]] ; then
echo "Environment should be set on startup with one of the below values"
echo "ENV must be one of - dev, qa, prod or local"
exit 1
fi
if [[ -z "$ENV_PLATFORM_UI_ORIGIN" && "$PROVIDER" == local ]]; then
ENV_PLATFORM_UI_ORIGIN="platform-ui.topcoder-dev.com"
fi
if [[ -z "$ENV_PLATFORM_UI_RESOLVER" && "$PROVIDER" == local ]]; then
ENV_PLATFORM_UI_RESOLVER="8.8.8.8"
fi
if [[ ! "$ENV_PLATFORM_UI_ORIGIN" =~ ^[A-Za-z0-9.-]+$ ]]; then
echo "ENV_PLATFORM_UI_ORIGIN must be a DNS hostname"
exit 1
fi
if [[ ! "$ENV_PLATFORM_UI_RESOLVER" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] ||
! awk -v ip="$ENV_PLATFORM_UI_RESOLVER" 'BEGIN { count = split(ip, octets, "."); if (count != 4) exit 1; for (i = 1; i <= 4; i++) if (octets[i] < 0 || octets[i] > 255) exit 1 }'
then
echo "ENV_PLATFORM_UI_RESOLVER must be an IPv4 address"
exit 1
fi
rm -rf /data/nginx/dist
mkdir -p /data/nginx/dist/sites-enabled
mkdir -p /data/nginx/dist/includes
cp /data/nginx/src/sites-enabled/*conf /data/nginx/dist/sites-enabled/
cp /data/nginx/src/includes/*conf /data/nginx/dist/includes/
cp /data/nginx/src/*conf /data/nginx/dist/
if [[ "$ENV" == dev ]]; then
cp -rf /data/nginx/src/dev/* /data/nginx/dist/
fi
if [[ "$ENV" == qa ]]; then
cp -rf /data/nginx/src/qa/* /data/nginx/dist/
fi
if [[ "$PROVIDER" == local ]]; then
cp -rf /data/nginx/src/local/includes/*.conf /data/nginx/dist/includes/
echo "8.8.8.8 dns01.topcoder.com" >> /etc/hosts
fi
if [[ "$ENV" != prod ]]; then
perl -pi -e "s/\{\{ENV_TLD\}\}/topcoder-$ENV\.com/g" /data/nginx/dist/sites-enabled/*conf
perl -pi -e "s/\{\{ENV_TLD\}\}/topcoder-$ENV\.com/g" /data/nginx/dist/includes/*conf
perl -pi -e "s/\{\{ENV_WWWTC\}\}/www\.topcoder.com\.com/g" /data/nginx/dist/sites-enabled/*conf
else
perl -pi -e "s/\{\{ENV_TLD\}\}/topcoder\.com/g" /data/nginx/dist/sites-enabled/*conf
perl -pi -e "s/\{\{ENV_TLD\}\}/topcoder\.com/g" /data/nginx/dist/includes/*conf
perl -pi -e "s/\{\{ENV_WWWTC\}\}/www\.topcoder\.com/g" /data/nginx/dist/sites-enabled/*conf
fi
perl -pi -e "s/\{\{ENV\}\}/$ENV/g" /data/nginx/dist/sites-enabled/*conf
perl -pi -e "s/\{\{ENV\}\}/$ENV/g" /data/nginx/dist/includes/*conf
perl -pi -e "s/\{\{ENV_PLATFORM_UI_ORIGIN\}\}/$ENV_PLATFORM_UI_ORIGIN/g" /data/nginx/dist/includes/*conf
perl -pi -e "s/\{\{ENV_PLATFORM_UI_RESOLVER\}\}/$ENV_PLATFORM_UI_RESOLVER/g" /data/nginx/dist/includes/*conf
/root/init_logentries.sh