-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.argenv.sh
executable file
·465 lines (448 loc) · 10.8 KB
/
.argenv.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
#!/usr/bin/env bash
# ========================================================================
# Copyright (c) 2020 Netcrest Technologies, LLC. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========================================================================
if [ "$1" == "-script_dir" ]; then
SCRIPT_DIR=$2
else
SCRIPT_DIR="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
fi
# OS_NAME in uppercase
OS_NAME=`uname`
OS_NAME=`echo "$OS_NAME"|awk '{print toupper($0)}'`
#
# .argenv.sh parses input arguments of individual scripts
# and assign appropriate parameters.
#
#
# Determine arguments
#
PRODUCT_ARG=
ENV_ARG=
RWE_ARG=
RWE_SPECIFIED=false
WORKSPACE_ARG=
WORKSPACE_SPECIFIED=false
JAVA_HOME_ARG=
COHERENCE_ARG=
GEODE_ARG=
HAZELCAST_ARG=
PATH_ARG=
JAR_ARG=
CLASSPATH_ARG=
JET_ARG=
NAME_ARG=
PORT_ARG=
CREATE_SCRIPT=false
POD_SPECIFIED=false
POD_TYPE=
TYPE_ARG=
REFID=
K8S=
K8S_SPECIFIED=false
DOCKER=
DOCKER_SPECIFIED=false
HOST=
COUNT=
VERSION_SPECIFIED=false
MAN_SPECIFIED=false
CLUSTER_SPECIFIED=false
FG_SPECIFIED=false
MEMBER_NUM=1
MEMBER_NUM_SPECIFIED=false
REMOTE=
REMOTE_SPECIFIED=false
MIRROR_SPECIFIED=false
VM_SPECIFIED=false
VM_HOSTS_ARG=
VM_JAVA_HOME_ARG=
VM_COHERENCE_HOME_ARG=
VM_GEODE_HOME_ARG=
VM_HAZELCAST_HOME_ARG=
VM_JET_HOME_ARG=
VM_PADOGRID_HOME_ARG=
VM_PADOGRID_WORKSPACES_HOME_ARG=
VM_USER_ARG=
VM_PRIVATE_KEY_FILE_ARG=
KEY=
APP=
APP_SPECIFIED=false
GRID_SPECIFIED=false
SITE_SPECIFIED=false
LOCATOR=
LOCATOR_SPECIFIED=false
MC=
MC_SPECIFIED=false
MEMBER=
MEMBER_SPECIFIED=false
PASSWORD=
GROUP=
CLUSTER_GROUP=
CP_GROUP=
UUID==
START=false
LOG=
FULL=false
HELP=
OPTIONS=false
SIMULATE=false
PREVIEW=false
DOWNLOAD=false
CONSOLE=false
USER=
GITHOST=github
BRANCH=
CONNECT=https
LIST=false
HEADER=false
CATALOG=false
TREE=false
OVERWRITE=false
ALL=false
OSS=false
RHEL=false
WAN=false
WAN_ARG=
PID=
PIDONLY=
BEGIN_NUM=1
END_NUM=
KILL=
DEBUG=
DIR=
CLEAN=
LOCAL=false
QUIET=false
LONG=false
DATASOURCE=
FOLDER=
PRIMARY=
BOX=
DIR=
PREFIX=
OCTET=
PM=
NM=
PREV=
for i in "$@"
do
if [ "$PREV" == "-product" ]; then
PRODUCT_ARG=$i
PRODUCT_HOME_ARG=$i
elif [ "$PREV" == "-rwe" ]; then
RWE_ARG=$i
elif [ "$PREV" == "-env" ]; then
ENV_ARG=$i
elif [ "$PREV" == "-workspace" ]; then
WORKSPACE_ARG=$i
elif [ "$PREV" == "-java" ]; then
JAVA_HOME_ARG=$i
elif [ "$PREV" == "-coherence" ]; then
COHERENCE_ARG=$i
elif [ "$PREV" == "-geode" ]; then
GEODE_ARG=$i
elif [ "$PREV" == "-hazelcast" ]; then
HAZELCAST_ARG=$i
elif [ "$PREV" == "-path" ]; then
PATH_ARG=$i
elif [ "$PREV" == "-jar" ]; then
JAR_ARG=$i
elif [ "$PREV" == "-classpath" ]; then
CLASSPATH_ARG=$i
elif [ "$PREV" == "-jet" ]; then
JET_ARG=$i
elif [ "$PREV" == "-name" ]; then
NAME_ARG=$i
elif [ "$PREV" == "-pod" ]; then
POD=$i
elif [ "$PREV" == "-port" ]; then
PORT_ARG=$i
elif [ "$PREV" == "-type" ]; then
POD_TYPE=$i
TYPE_ARG=$i
elif [ "$PREV" == "-refid" ]; then
REFID=$i
elif [ "$PREV" == "-primary" ]; then
PRIMARY=$i
elif [ "$PREV" == "-box" ]; then
BOX=$i
elif [ "$PREV" == "-octet" ]; then
OCTET=$i
elif [ "$PREV" == "-pm" ]; then
PM=$i
elif [ "$PREV" == "-nm" ]; then
NM=$i
elif [ "$PREV" == "-dir" ]; then
DIR=$i
elif [ "$PREV" == "-count" ]; then
COUNT=$i
elif [ "$PREV" == "-cluster" ]; then
CLUSTER=$i
elif [ "$PREV" == "-num" ]; then
MEMBER_NUM=$i
elif [ "$PREV" == "-password" ]; then
PASSWORD=$i
elif [ "$PREV" == "-k8s" ]; then
K8S=$i
elif [ "$PREV" == "-docker" ]; then
DOCKER=$i
elif [ "$PREV" == "-host" ]; then
HOST=$i
elif [ "$PREV" == "-group" ]; then
GROUP=$i
elif [ "$PREV" == "-clustergroup" ]; then
CLUSTER_GROUP=$i
elif [ "$PREV" == "-cpgroup" ]; then
CP_GROUP=$i
elif [ "$PREV" == "-uuid" ]; then
UUID=$i
elif [ "$PREV" == "-id" ]; then
ID=$i
elif [ "$PREV" == "-remote" ]; then
REMOTE=$i
elif [ "$PREV" == "-user" ]; then
USER=$i
elif [ "$PREV" == "-githost" ]; then
GITHOST=$i
elif [ "$PREV" == "-branch" ]; then
BRANCH=$i
elif [ "$PREV" == "-connect" ]; then
CONNECT=$i
elif [ "$PREV" == "-wan" ]; then
WAN_ARG=$i
WAN=true
elif [ "$PREV" == "-vm" ]; then
if [[ "$i" != "-"* ]]; then
VM_HOSTS_ARG=$i
fi
elif [ "$PREV" == "-vm-java" ]; then
VM_JAVA_HOME_ARG=$i
elif [ "$PREV" == "-vm-product" ]; then
VM_PRODUCT_HOME_ARG=$i
elif [ "$PREV" == "-vm-padogrid" ]; then
VM_PADOGRID_HOME_ARG=$i
elif [ "$PREV" == "-vm-workspaces" ]; then
VM_PADOGRID_WORKSPACES_HOME_ARG=$i
elif [ "$PREV" == "-vm-user" ]; then
VM_USER_ARG=$i
elif [ "$PREV" == "-vm-key" ]; then
VM_PRIVATE_KEY_FILE_ARG=$i
elif [ "$PREV" == "-key" ]; then
KEY=$i
elif [ "$PREV" == "-app" ]; then
APP=$i
elif [ "$PREV" == "-grid" ]; then
GRID=$i
elif [ "$PREV" == "-site" ]; then
SITE=$i
elif [ "$PREV" == "-locator" ]; then
LOCATOR=$i
elif [ "$PREV" == "-mc" ]; then
MC=$i
elif [ "$PREV" == "-member" ]; then
MEMBER=$i
elif [ "$PREV" == "-log" ]; then
LOG=$i
elif [ "$PREV" == "-begin" ]; then
BEGIN_NUM=$i
elif [ "$PREV" == "-end" ]; then
END_NUM=$i
elif [ "$PREV" == "-dir" ]; then
DIR=$i
elif [ "$PREV" == "-prefix" ]; then
PREFIX=$i
elif [ "$PREV" == "-folder" ]; then
FOLDER=$i
elif [ "$PREV" == "-datasource" ]; then
DATASOURCE=$i
# options with no value
elif [ "$i" == "-version" ]; then
VERSION_SPECIFIED=true
elif [ "$i" == "-man" ]; then
MAN_SPECIFIED=true
elif [ "$i" == "-fg" ]; then
FG_SPECIFIED=true
elif [ "$i" == "-simulate" ]; then
SIMULATE=true
elif [ "$i" == "-preview" ]; then
PREVIEW=true
elif [ "$i" == "-download" ]; then
DOWNLOAD=true
elif [ "$i" == "-workspace" ]; then
WORKSPACE_SPECIFIED=true
elif [ "$i" == "-list" ]; then
LIST=true
elif [ "$i" == "-header" ]; then
HEADER=true
elif [ "$i" == "-catalog" ]; then
CATALOG=true
elif [ "$i" == "-console" ]; then
CONSOLE=true
elif [ "$i" == "-create-script" ]; then
CREATE_SCRIPT=true
elif [ "$i" == "-full" ]; then
FULL=true
elif [ "$i" == "-start" ]; then
START=true
elif [ "$i" == "-?" ]; then
HELP=true
elif [ "$i" == "-options" ]; then
OPTIONS=true
elif [ "$i" == "-all" ]; then
ALL=true
elif [ "$i" == "-oss" ]; then
OSS=true
elif [ "$i" == "-rhel" ]; then
RHEL=true
elif [ "$i" == "-wan" ]; then
WAN=true
elif [ "$i" == "-kill" ]; then
KILL=true
elif [ "$i" == "-debug" ]; then
DEBUG=true
elif [ "$i" == "-pid" ]; then
PID=true
elif [ "$i" == "-pidonly" ]; then
PIDONLY=true
elif [ "$i" == "-clean" ]; then
CLEAN=true
elif [ "$i" == "-local" ]; then
LOCAL=true
elif [ "$i" == "-quiet" ]; then
QUIET=true
elif [ "$i" == "-long" ]; then
LONG=true
elif [ "$i" == "-num" ]; then
MEMBER_NUM_SPECIFIED=true
elif [ "$i" == "-pod" ]; then
POD_SPECIFIED=true
elif [ "$i" == "-cluster" ]; then
CLUSTER_SPECIFIED=true
elif [ "$i" == "-k8s" ]; then
K8S_SPECIFIED=true
elif [ "$i" == "-docker" ]; then
DOCKER_SPECIFIED=true
elif [ "$i" == "-app" ]; then
APP_SPECIFIED=true
elif [ "$i" == "-grid" ]; then
GRID_SPECIFIED=true
elif [ "$i" == "-site" ]; then
SITE_SPECIFIED=true
elif [ "$i" == "-mc" ]; then
MC_SPECIFIED=true
elif [ "$i" == "-member" ]; then
MEMBER_SPECIFIED=true
elif [ "$i" == "-locator" ]; then
LOCATOR_SPECIFIED=true
elif [ "$i" == "-vm" ]; then
VM_SPECIFIED=true
elif [ "$i" == "-rwe" ]; then
RWE_SPECIFIED=true
elif [ "$i" == "-mirror" ]; then
MIRROR_SPECIFIED=true
elif [ "$i" == "-remote" ]; then
REMOTE_SPECIFIED=true
elif [ "$i" == "-tree" ]; then
TREE=true
elif [ "$i" == "-overwrite" ]; then
OVERWRITE=true
# this must be the last check
elif [ "$PREV" == "-gateway" ]; then
GATEWAY_XML_FILE=$i
fi
PREV=$i
done
# Set MEMBER_NUM_NO_LEADING_ZERO
MEMBER_NUM_NO_LEADING_ZERO=$MEMBER_NUM
while [[ $MEMBER_NUM_NO_LEADING_ZERO == 0* ]]; do
MEMBER_NUM_NO_LEADING_ZERO=${MEMBER_NUM_NO_LEADING_ZERO:1};
done
MEMBER_NUM=$MEMBER_NUM_NO_LEADING_ZERO
LOCATOR_NUM_NO_LEADING_ZERO=$MEMBER_NUM_NO_LEADING_ZERO
let LAST_LOCATOR_NUM=MAX_LOCATOR_COUNT-1
let LAST_MEMBER_NUM=MAX_MEMBER_COUNT-1
# Determine the member number
re='^[0-9]+$'
if ! [[ $MEMBER_NUM =~ $re ]] ; then
echo "ERROR: Member number must be a positive number the range [1, 99]: $MEMBER_NUM. Command aborted." >&2; exit 1
fi
if [ $MEMBER_NUM -lt 1 ]; then
echo "ERROR: Member number must be greater than 0: $MEMBER_NUM. Command aborated." >&2; exit 1
fi
if [ $MEMBER_NUM -gt 99 ]; then
echo "ERROR: Member number must be less than 99: $MEMBER_NUM. Command aborated." >&2; exit 1
fi
if [ $CONNECT != "https" ] && [ "$CONNECT" != "ssh" ]; then
echo "ERROR: Invalid -connect type: [$CONNECT]. Valid values are https or ssh. Command aborted." >&2; exit 1
fi
if [ $MEMBER_NUM -lt 10 ]; then
MEMBER_NUM=0$MEMBER_NUM
fi
# If the end member number is not defined then
# assign it to the beginning member number.
if [ "$END_NUM" == "" ]; then
END_NUM=$BEGIN_NUM
fi
# Set the grid options to display in the command usage.
GRID_DEFAULT=
GRIDS_OPT=
ALL_SITES=
for i in $GRIDS
do
if [ "$GRIDS_OPT" == "" ]; then
GRIDS_OPT=$i
GRID_DEFAULT=$i
else
GRIDS_OPT=${GRIDS_OPT}"|"$i
fi
. grids/$i/grid_env.sh
ALL_SITES="$ALL_SITES $SITES"
done
# Set the site options to display in the command usage.
SITE_DEFAULT=
SITES_OPT=
for i in $SITES
do
if [ "$SITES_OPT" == "" ]; then
SITES_OPT=$i
SITE_DEFAULT=$i
else
SITES_OPT=${SITES_OPT}"|"$i
fi
done
# Set the site to the default site if undefined.
if [ "$SITE" == "" ]; then
SITE=$SITE_DEFAULT
fi
if [ "$SSH_USER" == "" ]; then
# SSH_USER=`id -un`
SSH_USER=vagrant
fi
if [ "$REMOTE_BASE_DIR" == "" ]; then
if [ "$BASE_DIR" != "" ]; then
REMOTE_BASE_DIR="$PADOGRID_HOME"
fi
fi
# SED backup prefix
if [[ ${OS_NAME} == DARWIN* ]]; then
# Mac - space required
__SED_BACKUP=" 0"
else
__SED_BACKUP="0"
fi
# If -env file present, then source it in.
if [ "$ENV_ARG" != "" ]; then
. $ENV_ARG
fi