-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon-functions.sh
executable file
·197 lines (158 loc) · 5.57 KB
/
common-functions.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
#!/bin/bash -v
set -o errexit
# Note :: absolute dir needed for derby creation
export USER="/Users/donal"
# should point to where you want Liberty to go
# OR where the wlp directory is
export LIBERTY_TARGET="$USER/Documents/LibertyProfile"
# should point to the file wlp-developers-runtime-8.5.5.1.jar
# if unpacking is needed uncomment unpackLibertyJar below
export LIBERTY_SOURCE=$LIBERTY_TARGET
# note the configure-liberty-derby.xml file adds the /WorklightServer dir to this export
export WORKLIGHT_INSTALL_DIR="/Applications/IBM/MobileFirst_Platform_Server"
export DERBY_ADMIN_DB="WLADMIN"
export WORKLIGHT_DB="WORKLIGHT"
export WORKLIGHT_REP="WLREPORTS"
export CONSOLE_WAR="$WORKLIGHT_INSTALL_DIR/worklightconsole.war"
export SERVICE_WAR="$WORKLIGHT_INSTALL_DIR/worklightadmin.war"
export DERBY_DIR="$LIBERTY_TARGET/derby"
export MY_PATH=$(dirname $(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/`basename "${BASH_SOURCE[0]}"`)
export ANT_TASK=$MY_PATH/configure-liberty-derby.xml
# setEnvironment - idea here is you would have one of these for each MFP Enviornment you have eg DEV, TEST, UAT, SAGING, PROD
setEnvironment() {
export RECENT_WAR="$USER/Documents/mobfirst/devworks/devworks/bin/devworks.war"
export MFP_PORT="9080"
export HOSTNAME="localhost"
export PROJECT_NAME="devworks"
export SERVER_NAME="mfp-devworks"
export MFP_CONTEXT_ROOT="/$PROJECT_NAME"
export MFP_SERVER_URL="http://$HOSTNAME:$MFP_PORT$MFP_CONTEXT_ROOT"
export MFP_EXTERNAL_SERVER_URL=$MFP_SERVER_URL # configured as needed
export MFP_USERNAME="admin"
export MFP_PASSWORD="admin"
export ADMIN_CONTEXT="/worklightadmin"
export ADMIN_URL="http://$HOSTNAME:$MFP_PORT$ADMIN_CONTEXT"
}
buildAdapters()
{
${LOCAL_ANT} -f ${ANTFILE} build-Adapters \
-Dbasedir="${MFP_PROJECT}" \
-Dworklight.ant.tools.dir=${ANT_DIR} \
-Dworklight.jars.dir=${ANT_DIR} \
-Dpath.to.project=${MFP_PROJECT} \
-DProjectName=${PROJECT_NAME}
}
buildApps()
{
${LOCAL_ANT} -f ${ANTFILE} build-Apps \
-Dbasedir="${MFP_PROJECT}" \
-Dworklight.server.host=${MFP_EXTERNAL_SERVER_URL} \
-Dworklight.ant.tools.dir=${ANT_DIR} \
-Dworklight.jars.dir=${ANT_DIR} \
-DProjectName=${PROJECT_NAME} \
-Dpath.to.project=${MFP_PROJECT}
}
deployAdapters()
{
${LOCAL_ANT} -f ${ANTFILE} deploy-Adapters \
-Dbasedir="${MFP_PROJECT}" \
-Dworklight.username="${MFP_USERNAME}" \
-Dworklight.password="${MFP_PASSWORD}" \
-Dworklight.admin.url="${ADMIN_URL}" \
-Dworklight.ant.tools.dir=${ANT_DIR} \
-Dworklight.jars.dir=${ANT_DIR} \
-DProjectName=${PROJECT_NAME} \
-Dpath.to.project=${MFP_PROJECT}
}
deployApps()
{
${LOCAL_ANT} -f ${ANTFILE} deploy-Apps \
-Dbasedir="${MFP_PROJECT}" \
-Dworklight.username="${MFP_USERNAME}" \
-Dworklight.password="${MFP_PASSWORD}" \
-Dworklight.admin.url="${ADMIN_URL}" \
-Dworklight.ant.tools.dir=${ANT_DIR} \
-Dworklight.jars.dir=${ANT_DIR} \
-DProjectName=${PROJECT_NAME} \
-Dpath.to.project=${MFP_PROJECT}
}
buildWar()
{
${LOCAL_ANT} -f ${ANTFILE} build-WAR \
-Dbasedir="${MFP_PROJECT}" \
-Dworklight.ant.tools.dir=${ANT_DIR} \
-Dworklight.jars.dir=${ANT_DIR} \
-Dpath.to.project=${MFP_PROJECT} \
-DProjectName=${PROJECT_NAME}
}
unpackLibertyJar()
{
mkdir -p $1
cd $1
jar xvf $LIBERTY_SOURCE
chmod +x $LIBERTY_TARGET/wlp/bin/server
}
createLibertyServer()
{
echo "creating Liberty server $SERVER_NAME in $LIBERTY_TARGET"
$LIBERTY_TARGET/wlp/bin/server create $SERVER_NAME
}
deleteLibertyServer()
{
echo "deleting Liberty server $SERVER_NAME in $LIBERTY_TARGET"
rm -r $LIBERTY_TARGET/wlp/usr/servers/$SERVER_NAME && rc=$? || rc=$?
echo "Error code was $rc"
# grab error code incase server does not exist - won't stop script execution
}
deleteDerbyDb()
{
echo "deleting derby db at $DERBY_DIR"
rm -r $DERBY_DIR && rc=$? || rc=$?
echo "Error code was $rc"
}
install()
{
ant -f $ANT_TASK -Dworklight.server.install.dir=${WORKLIGHT_INSTALL_DIR} \
-Dworklight.contextroot=$MFP_CONTEXT_ROOT \
-Dworklight.project.war.file=$RECENT_WAR \
-Dappserver.was.installdir=$LIBERTY_TARGET \
-Dappserver.was85liberty.serverInstance=$SERVER_NAME \
-Ddatabase.derby.datadir=$DERBY_DIR \
-Ddatabase.derby.wladmin.dbname=$DERBY_ADMIN_DB \
-Ddatabase.derby.worklight.dbname=$WORKLIGHT_DB \
-Ddatabase.derby.worklightreports.dbname=$WORKLIGHT_REP \
-Dwladmin.console.war=$CONSOLE_WAR \
-Dwladmin.service.war=$SERVICE_WAR \
$1
}
libStart()
{
echo "start $SERVER_NAME"
$LIBERTY_TARGET/wlp/bin/server start $SERVER_NAME
}
libStop()
{
echo "stop $SERVER_NAME"
$LIBERTY_TARGET/wlp/bin/server stop $SERVER_NAME && rc=$? || rc=$?
echo "Error code was $rc"
}
deployWar()
{
# When running the lib server stop it then remove it to clean house each time
libStop
deleteLibertyServer
deleteDerbyDb
# unpack a liberty server from the jar file then create a server for MFP to live
#unpackLibertyJar
createLibertyServer
# install the db used by the admin services
install "admdatabases"
# install the db used by the MFP runtime
install "databases"
# install the admin services and console war files
install "adminstall"
# install the db used by the admin services
install "install"
#start the liberty server
libStart
}