-
Notifications
You must be signed in to change notification settings - Fork 7
/
init.sh
executable file
·236 lines (208 loc) · 9.6 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/bin/sh
. ./init-properties.sh
# Additional properties
PROJECT_GIT_BRANCH=master
PROJECT_GIT_DIR=./support/demo_project_git
OFFLINE_MODE=false
# wipe screen.
clear
function usage {
echo "Usage: init.sh [args...]"
echo "where args include:"
echo " -o run this script in offline mode. The project's Git repo will not be downloaded. Instead a cached version will be used if available."
echo " -h prints this help."
}
#Parse the params
while getopts "oh" opt; do
case $opt in
o)
OFFLINE_MODE=true
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
echo
echo "#################################################################"
echo "## ##"
echo "## Setting up the ${DEMO} ##"
echo "## ##"
echo "## ##"
echo "## #### # # #### # # ##### # # ##"
echo "## # # # # # # # # # # # # # ##"
echo "## #### ##### # # # # # ### # ##"
echo "## # # # # # # # # # # # ##"
echo "## # # # # #### # # # # # # ##"
echo "## ##"
echo "## brought to you by, ##"
echo "## ${AUTHORS} ##"
echo "## ##"
echo "## ##"
echo "## ${PROJECT} ##"
echo "## ##"
echo "#################################################################"
echo
# make some checks first before proceeding.
command -v npm -q >/dev/null 2>&1 || { echo >&2 "npm is required but not installed yet... aborting."; exit 1; }
if [ -r $SRC_DIR/$EAP ] || [ -L $SRC_DIR/$EAP ]; then
echo Product sources are present...
echo
else
echo Need to download $EAP package from http://developers.redhat.com
echo and place it in the $SRC_DIR directory to proceed...
echo
exit
fi
#if [ -r $SRC_DIR/$EAP_PATCH ] || [ -L $SRC_DIR/$EAP_PATCH ]; then
# echo Product patches are present...
# echo
#else
# echo Need to download $EAP_PATCH package from the Customer Portal
# echo and place it in the $SRC_DIR directory to proceed...
# echo
# exit
#fi
if [ -r $SRC_DIR/$DM_DECISION_CENTRAL ] || [ -L $SRC_DIR/$DM_DECISION_CENTRAL ]; then
echo Product sources are present...
echo
else
echo Need to download $DM_DECISION_CENTRAL zip from http://developers.redhat.com
echo and place it in the $SRC_DIR directory to proceed...
echo
exit
fi
if [ -r $SRC_DIR/$DM_KIE_SERVER ] || [ -L $SRC_DIR/$DM_KIE_SERVER ]; then
echo Product sources are present...
echo
else
echo Need to download $DM_KIE_SERVER zip from http://developers.redhat.com
echo and place it in the $SRC_DIR directory to proceed...
echo
exit
fi
# Remove the old JBoss instance, if it exists.
if [ -x $JBOSS_HOME ]; then
echo " - removing existing JBoss product..."
echo
rm -rf $JBOSS_HOME
fi
# Run installers.
echo "Provisioning JBoss EAP now..."
echo
unzip -qo $SRC_DIR/$EAP -d $TARGET
if [ $? -ne 0 ]; then
echo
echo Error occurred during JBoss EAP installation!
exit
fi
#echo
#echo "Applying JBoss EAP 6.4.7 patch now..."
#echo
#$JBOSS_HOME/bin/jboss-cli.sh --command="patch apply $SRC_DIR/$EAP_PATCH"
#
#if [ $? -ne 0 ]; then
# echo
# echo Error occurred during JBoss EAP patching!
# exit
#fi
echo
echo "Deploying Red Hat Decision Manager: Decision Central now..."
echo
unzip -qo $SRC_DIR/$DM_DECISION_CENTRAL -d $TARGET
if [ $? -ne 0 ]; then
echo Error occurred during $PRODUCT installation
exit
fi
echo
echo "Deploying Red Hat Decision Manager: Decision Server now..."
echo
unzip -qo $SRC_DIR/$DM_KIE_SERVER -d $SERVER_DIR
if [ $? -ne 0 ]; then
echo Error occurred during $PRODUCT installation
exit
fi
touch $SERVER_DIR/kie-server.war.dodeploy
echo
echo " - enabling demo accounts setup..."
echo
$JBOSS_HOME/bin/add-user.sh -a -r ApplicationRealm -u dmAdmin -p redhatdm1! -ro analyst,admin,manager,user,kie-server,kiemgmt,rest-all --silent
$JBOSS_HOME/bin/add-user.sh -a -r ApplicationRealm -u kieserver -p kieserver1! -ro kie-server,rest-all --silent
echo " - setting up demo projects..."
echo
# Copy the default (internal) Decision Manager repo's.
rm -rf $SERVER_BIN/.niogit && mkdir -p $SERVER_BIN/.niogit && cp -r $SUPPORT_DIR/rhdm7-demo-niogit/* $SERVER_BIN/.niogit
# Copy the demo project repo.
if ! $OFFLINE_MODE
then
# Not in offline mode, so downloading the latest repo. We first download the repo in a temp dir and we only delete the old, cached repo, when the download is succesful.
echo " - cloning the project's Git repo from: $PROJECT_GIT_REPO"
echo
# rm -rf ./target/temp && git clone --bare $PROJECT_GIT_REPO ./target/temp/bpms-specialtripsagency.git || { echo; echo >&2 "Error cloning the project's Git repo. If there is no Internet connection available, please run this script in 'offline-mode' ('-o') to use a previously downloaded and cached version of the project's Git repo... Aborting"; echo; exit 1; }
rm -rf ./target/temp && git clone -b $PROJECT_GIT_BRANCH --single-branch $PROJECT_GIT_REPO ./target/temp/$PROJECT_GIT_REPO_NAME || { echo; echo >&2 "Error cloning the project's Git repo. If there is no Internet connection available, please run this script in 'offline-mode' ('-o') to use a previously downloaded and cached version of the project's Git repo... Aborting"; echo; exit 1; }
pushd ./target/temp/$PROJECT_GIT_REPO_NAME
# rename the checked-out branch to master.
echo "Renaming cloned branch '$PROJECT_GIT_BRANCH' to 'master'."
git branch -m $PROJECT_GIT_BRANCH master
popd
echo " - replacing cached project git repo: $PROJECT_GIT_DIR/$PROJECT_GIT_REPO_NAME"
echo
# rm -rf $PROJECT_GIT_DIR/bpms-specialtripsagency.git && mkdir -p $PROJECT_GIT_DIR && cp -R target/temp/bpms-specialtripsagency.git $PROJECT_GIT_DIR/bpms-specialtripsagency.git && rm -rf ./target/temp
# Make a bare clone of the Git repo.
rm -rf $PROJECT_GIT_DIR/$PROJECT_GIT_REPO_NAME && mkdir -p $PROJECT_GIT_DIR && git clone --bare target/temp/$PROJECT_GIT_REPO_NAME $PROJECT_GIT_DIR/$PROJECT_GIT_REPO_NAME && rm -rf ./target/temp
else
echo " - running in offline-mode, using cached project's Git repo."
echo
if [ ! -d "$PROJECT_GIT_DIR" ]
then
echo "No project Git repo found. Please run the script without the 'offline' ('-o') option to automatically download the required Git repository!"
echo
exit 1
fi
fi
# Copy the repo to the JBoss BPMSuite installation directory.
rm -rf $SERVER_BIN/.niogit/$NIOGIT_PROJECT_GIT_REPO && cp -R $PROJECT_GIT_DIR/$PROJECT_GIT_REPO_NAME $SERVER_BIN/.niogit/$NIOGIT_PROJECT_GIT_REPO
echo " - setting up standalone.xml configuration adjustments..."
echo
cp $SUPPORT_DIR/standalone-full.xml $SERVER_CONF/standalone.xml
echo " - setup email notification users..."
echo
cp $SUPPORT_DIR/userinfo.properties $SERVER_DIR/decision-central.war/WEB-INF/classes/
# Add execute permissions to the standalone.sh script.
echo " - making sure standalone.sh for server is executable..."
echo
chmod u+x $JBOSS_HOME/bin/standalone.sh
echo
echo "======================================================================================="
echo "= ="
echo "= You can now start the $PRODUCT with: ="
echo "= ="
echo "= $SERVER_BIN/standalone.sh ="
echo "= ="
echo "= To start the AngularJS UI interface, navigate to 'support/application_ui' and run: ="
echo "= ="
echo "= npm install ="
echo "= npm start ="
echo "= ="
echo "= Login into Decision Central at: ="
echo "= ="
echo "= http://localhost:8080/decision-central (u:dmAdmin / p:redhatdm1!) ="
echo "= ="
echo "= Login into the client Application at: ="
echo "= ="
echo "= http://localhost:3000 ="
echo "= ="
echo "= See README.md for general details to run the various demo cases. ="
echo "= ="
echo "= $PRODUCT $VERSION $DEMO Setup Complete. ="
echo "= ="
echo "======================================================================================="