This repository was archived by the owner on Apr 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathset_environment.sh
46 lines (36 loc) · 1.55 KB
/
set_environment.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
#!/bin/bash
#set -x
set -e
ENV=$1
# Rewrite hardcoded URLs in code to target environment. Script takes one single argument which defines the target env.
##########################################################################################
##########################################################################################
##########################################################################################
# IMPORTANT don't run this on MACOS (find/sed commands don't work same as on linux) !!!
##########################################################################################
##########################################################################################
##########################################################################################
uri_to_staging() {
echo "Adjusting URIs to $ENV environment"
# IMPORTANT adjust URLs for each environment and make sure to add new ones !!!
# ./assets
# https://{s}.tiles.openaip.net/data/openaip/{z}/{x}/{y}.pbf
find dist/maps/styles -type f -exec sed -i -e 's/tiles\.openaip\.net/staging\.tiles\.openaip\.net/g' {} \;
find dist/maps/styles -type f -exec sed -i -e 's/static\.openaip\.net/staging\.static\.openaip\.net/g' {} \;
echo "Adjusting URIs to $ENV environment done"
};
uri_to_default() {
echo "$ENV environment does not require adjusting URIs"
};
case $ENV in
staging)
uri_to_staging
;;
development|production)
uri_to_default
break
;;
*)
echo "Unknown environment $ENV"
;;
esac