forked from caraml-dev/xp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·69 lines (58 loc) · 1.48 KB
/
docker-entrypoint.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
#!/bin/bash
set -e
CMD=()
XP_UI_CONFIG_PATH=
XP_UI_DIST_DIR=${XP_UI_DIST_DIR:-}
XP_UI_DIST_CONFIG_FILE=${XP_UI_DIST_DIR}/app.config.js
XP_API_BIN=${XP_API_BIN:?"ERROR: XP_API_BIN is not specified"}
show_help() {
cat <<EOF
Usage: $(basename "$0") <options> <...>
-ui-config JSON file containing configuration of XP UI
EOF
}
main(){
parse_command_line "$@"
if [[ -n "$XP_UI_CONFIG_PATH" ]]; then
echo "XP UI config found at ${XP_UI_CONFIG_PATH}..."
if [[ -n "$XP_UI_DIST_DIR" ]]; then
echo "Overriding UI config at $XP_UI_DIST_CONFIG_FILE"
echo "var xpConfig = $(cat $XP_UI_CONFIG_PATH);" > "$XP_UI_DIST_CONFIG_FILE"
echo "Done."
else
echo "XP_UI_DIST_DIR: XP UI static build directory not provided. Skipping."
fi
else
echo "XP UI config is not provided. Skipping."
fi
}
parse_command_line(){
while [[ $# -gt 0 ]]; do
case "$1" in
-ui-config)
if [[ -n "$2" ]]; then
XP_UI_CONFIG_PATH="$2"
shift
else
echo "ERROR: '-ui-config' cannot be empty." >&2
show_help
exit 1
fi
;;
*)
CMD+=("$1")
;;
esac
shift
done
if [[ -n "$XP_UI_CONFIG_PATH" ]]; then
if [ ! -f "$XP_UI_CONFIG_PATH" ]; then
echo "ERROR: config file $XP_UI_CONFIG_PATH does not exist." >&2
show_help
exit 1
fi
fi
}
main "$@"
echo "Launching xp-management server: " "$XP_API_BIN" "${CMD[@]}"
exec "$XP_API_BIN" "${CMD[@]}"