forked from bitfinexcom/bfx-reports-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·121 lines (101 loc) · 2.84 KB
/
init.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
set -x
ROOT="$PWD"
frontendFolder="$ROOT/bfx-report-ui"
expressFolder="$frontendFolder/bfx-report-express"
dbDriver=better-sqlite
programname=$0
isDevEnv=0
ip=0
function usage {
echo "Usage: $programname [-d] | [-i] | [-u] | [-h]"
echo " -d turn on developer environment"
echo " -i=XX.XX.XX.XX adds ip as to run on an external network"
echo " -u=URL adds URL as to run on an external network"
echo " -h display help"
exit 1
}
function installDeps {
local path="$PWD"
if [ $# -ge 1 ]
then
cd "$1"
else
exit 1
fi
rm -rf ./node_modules
npm i
cd "$path"
}
while [ "$1" != "" ]; do
case $1 in
-d | --dev ) isDevEnv=1
;;
-i | --ip ) shift
ip=$1
;;
-u | --url ) shift
ip=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
if [ "$CI_ENVIRONMENT_NAME" == "" ]
then
export CI_ENVIRONMENT_NAME=development
fi
if [ $isDevEnv != 0 ]; then
echo "Developer environment is turned on"
fi
if [ $ip != 0 ]; then
echo "Ip is set to: $ip"
fi
git submodule foreach --recursive git clean -fdx
git submodule foreach --recursive git reset --hard HEAD
git submodule sync --recursive
git submodule update --init --recursive
git config url."https://github.com/".insteadOf git@github.com:
git pull --recurse-submodules
git submodule update --remote --recursive
git config --unset url."https://github.com/".insteadOf
if [ $isDevEnv != 0 ]; then
sed -i -e \
"s/KEY_URL: .*,/KEY_URL: \'https:\/\/api.staging.bitfinex.com\/api\',/g" \
$frontendFolder/src/config.js
fi
if [ $ip != 0 ]; then
sed -i -e \
"s/API_URL: .*,/API_URL: \'http:\/\/$ip:31339\/api\',/g" \
$frontendFolder/src/config.js
sed -i -e \
"s/WS_ADDRESS: .*,/WS_ADDRESS: \'ws:\/\/$ip:31339\/ws\',/g" \
$frontendFolder/src/config.js
sed -i -e \
"s/HOME_URL: .*,/HOME_URL: \'http:\/\/$ip:3000\',/g" \
$frontendFolder/src/config.js
fi
cp $expressFolder/config/default.json.example \
$expressFolder/config/default.json
cp config/schedule.json.example config/schedule.json
cp config/common.json.example config/common.json
cp config/service.report.json.example config/service.report.json
cp config/facs/grc.config.json.example config/facs/grc.config.json
sed -i -e \
"s/\"syncMode\": false/\"syncMode\": true/g" \
$ROOT/config/service.report.json
sed -i -e \
"s/\"dbDriver\": \".*\"/\"dbDriver\": \"$dbDriver\"/g" \
$ROOT/config/service.report.json
if [ $isDevEnv != 0 ]; then
sed -i -e \
"s/\"restUrl\": \".*\"/\"restUrl\": \"https:\/\/api.staging.bitfinex.com\"/g" \
$ROOT/config/service.report.json
fi
installDeps $ROOT
installDeps $expressFolder
installDeps $frontendFolder