forked from fabric8-ui/fabric8-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-planner.sh
executable file
·121 lines (104 loc) · 3.23 KB
/
run-planner.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
#!/bin/bash
# This script runs the Planner-Platform integration in one go.
# It has the following commandline options:
#
# -r reinstalls all needed components before launching
# -s runs in standalone (non-Plaform mode) with inmemory mock data
# -p <planner_home_dir> sets the Planner home, defaults to current directory
# -f <platform_home_dir> sets the Platform home, defaults to <current directory>/../fabric8-ui
#
# NOTE: this does not set any run mode or api url environment for non-standalone mode. If you
# need that, set it as usual before launching this script.
# get the script's absolute path
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd -P`
popd > /dev/null
echo $SCRIPTPATH
# defaults to script's parent dir and the common git name in parent
PLANNER_HOME="$SCRIPTPATH/.."
PLATFORM_HOME="$PLANNER_HOME/../fabric8-ui"
REINSTALL=0
STANDALONE=0
NODE_ENV=production
# fire up getopt
TEMP=`getopt -o rsp:f: --long reinstall,standalone,plannerhome:,platformhome: -n 'run-planner.sh' -- "$@"`
eval set -- "$TEMP"
# reinstall Planner and Platform
function reinstallPlatformIntegrated {
echo "Reinstalling Planner in $PLANNER_HOME"
cd $PLANNER_HOME && npm run clean -- --cache --modules && npm install &
echo "Reinstalling Platform in $PLATFORM_HOME"
cd $PLATFORM_HOME && npm run reinstall &
wait
}
# reinstall Planner and Runtime
function reinstallStandalone {
echo "Reinstalling Planner in $PLANNER_HOME"
cd $PLANNER_HOME && npm run clean -- --cache --modules && npm install &
echo "Reinstalling Runtime in $PLANNER_HOME/runtime"
cd $PLANNER_HOME/runtime && npm run reinstall &
wait
}
# links planner to platform
function linkPlannerToPlatform {
echo "Linking Planner to Platform in $PLATFORM_HOME"
cd $PLATFORM_HOME && npm link $PLANNER_HOME/dist
}
# links planner to runtime
function linkPlannerToRuntime {
echo "Linking Planner to Runtime in $PLANNER_HOME/runtime"
cd $PLANNER_HOME/runtime && npm link $PLANNER_HOME/dist
}
# runs the platform
function runPlatform {
echo "Running Platform in $PLATFORM_HOME"
cd $PLATFORM_HOME && npm start
}
# runs the standalone Runtime
function runStandalone {
echo "Running Runtime in $PLANNER_HOME/runtime"
cd $PLANNER_HOME/runtime && npm start
}
# runs the planner in watch mode
function runPlanner {
echo "Running Planner in $PLANNER_HOME"
cd $PLANNER_HOME && npm run build -- --watch &
}
# extract options and their arguments into variables.
while true ; do
case "$1" in
-r|--reinstall) REINSTALL=1 ; shift ;;
-s|--standalone) STANDALONE=1 ; shift ;;
-p|--plannerhome)
case "$2" in
"") shift 2 ;;
*) PLANNER_HOME=$2 ; shift 2 ;;
esac ;;
-f|--platformhome)
case "$2" in
"") shift 2 ;;
*) PLATFORM_HOME=$2 ; shift 2 ;;
esac ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
if [ $REINSTALL -eq 1 ]
then
if [ $STANDALONE -eq 1 ]
then
reinstallStandalone
else
reinstallPlatformIntegrated
fi
fi
runPlanner
if [ $STANDALONE -eq 1 ]
then
export NODE_ENV=inmemory
linkPlannerToRuntime
runStandalone
else
linkPlannerToPlatform
runPlatform
fi