forked from illacloud/illa-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathilla-builder-frontend-config-init.sh
63 lines (42 loc) · 1.3 KB
/
illa-builder-frontend-config-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
#!/usr/bin/env bash
set -Eeo pipefail
# check to see if this file is being run or sourced from another script
_is_sourced() {
# https://unix.stackexchange.com/a/215279
[ "${#FUNCNAME[@]}" -ge 2 ] \
&& [ "${FUNCNAME[0]}" = '_is_sourced' ] \
&& [ "${FUNCNAME[1]}" = 'source' ]
}
_main() {
echo
echo 'config init.'
echo
echo "CLOUD_PATH = $CLOUD_PATH"
# replace frontend repo
if [ ! -n "$RELEASE_VERSION" ]; then
echo "RELEASE_VERSION not defined, skip."
else
sed -i "s#<head>#<head><meta release-version=\"$RELEASE_VERSION\" />#g" /opt/illa/illa-builder-frontend/index.html
fi
if [ ! -n "$CLOUD_PATH" ]; then
echo "CLOUD_API_PATH not defined, skip."
else
sed -i "s#CLOUD_PATH#$CLOUD_PATH#g" /opt/illa/illa-builder-frontend/assets/*.js
fi
if [ ! -n "$CLOUD_API_PATH" ]; then
echo "CLOUD_API_PATH not defined, skip."
else
sed -i "s/CLOUD_API_PATH/$CLOUD_API_PATH/g" /opt/illa/illa-builder-frontend/assets/*.js
fi
if [ ! -n "$BUILDER_PATH" ]; then
echo "BUILDER_PATH not defined, skip."
else
sed -i "s/BUILDER_PATH/$BUILDER_PATH/g" /opt/illa/illa-builder-frontend/assets/*.js
fi
echo
echo 'config init done.'
echo
}
if ! _is_sourced; then
_main "$@"
fi