-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiminstallhelper.sh
executable file
·414 lines (365 loc) · 11.6 KB
/
iminstallhelper.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
#!/bin/bash
# covener's script to list/install/patch whatever is found
# in an IM repository with an global or unzipped IIM.
ACTION="help"
usage() {
echo "$0 list|install|uninstall|update|install-im|install-local-im [-l] -r some-repo [-i install-root] -p offering|\"list\""
printf "\nList available packages to install:"
printf "\n\t$0 list -r /path/to/driverdownload|URL to repository"
printf "\n\nInstall package:"
printf "\n\t$0 install -r /path/to/driverdownload|URL -p com.ibm.... -i /opt/InstallRoot"
printf "\n\nInstall fixpack (same as full install):"
printf "\n\t$0 install -r /path/to/driverdownload|URL -p com.ibm.... -i /opt/InstallRoot"
printf "\n\nUninstall package :"
printf "\n\t$0 uninstall -i /opt/InstallRoot"
printf "\n\nRollback FP:"
printf "\n\t$0 rollback -i /opt/InstallRoot"
printf "\n\nApply IFIX:"
printf "\n\t$0 update -r /path/to/ifix.zip -i /opt/InstallRoot"
printf "\n\nRemove IFIX:"
printf "\n\t$0 uninstall-ifix -i /opt/InstallRoot"
printf "\n\nInstall global IIM:"
printf "\n\t$0 install-im"
printf "\n\nAdd Credentials:"
printf "\n\t$0 addpass -U ... -P ... [-r ...]"
printf "\n\nOptions:\n"
printf "\t -r specifies a repo -- zip or http/https\n"
printf "\t -U/P are user/pass for online repos. You should be prompted w/o these\n"
printf "\t -t forces a temporary IIM in the -i dir\n"
exit 1
}
if [ $# -lt 1 ]; then
usage
fi
ACTION=$1;
shift
# Look for a global IIM install by default.
GLOBAL=1
# No configuration below!
IIMDL=${IIMDL:-$HOME/iim}
IMCL=$IIMDL/tools/imcl
IMUTILSC=$IIMDL/tools/imutilsc
OS=`uname`
if [ -x /opt/csw/bin/wget ]; then
PATH=$PATH:/opt/csw/bin
fi
PKGS=list
NEED_AUTH=0
while getopts "lti:r:p:U:P:x:" flag
do
case $flag in
i) INSTDIR=$OPTARG ;;
r) PKGDL=$OPTARG ;;
p) PKGS=$OPTARG ;;
U) REPOUSER=$OPTARG ; NEED_AUTH=1 ;;
P) PASS=$OPTARG ;;
l) GLOBAL=0;;
esac
done
if [ $ACTION = "install" -o $ACTION = "update" -o $ACTION = "uninstall" -o $ACTION = "rollback" ]; then
if [ -z "$INSTDIR" ]; then
echo "$0: -i install-path is required for install, update, or uninstall"
exit 1
fi
fi
# use entitled repo by default
if [ -z "$PKGDL" ]; then
PKGDL="https://www.ibm.com/software/repositorymanager/entitled"
echo "Using default repo $PKGDL, use -r to override"
fi
NEEDPASS=1
if echo $PKGDL|grep http >/dev/null; then
NEEDPASS=1
else
NEEDPASS=0
fi
# Find the global IM unless -l was forced
if [ x"$GLOBAL" = "x1" ]; then
POSSIBLE_GLOBAL_IMS="/c/opt/Moonstone/IM /opt/IM /opt/IBM/InstallationManager /opt/Moonstone/InstallationManager /opt/Moonstone/IM"
for PIM in $POSSIBLE_GLOBAL_IMS; do
if [ -x $PIM/eclipse/tools/imcl.exe ]; then
IIMDL=$PIM
IMCL=$PIM/eclipse/tools/imcl.exe
IMUTILSC=$PIM/eclipse/tools/imutilsc.exe
GLOBAL=1
fi
if [ -x $PIM/eclipse/tools/imcl ]; then
IIMDL=$PIM
IMCL=$PIM/eclipse/tools/imcl
IMUTILSC=$PIM/eclipse/tools/imutilsc
GLOBAL=1
fi
done
fi
STORAGE=$HOME/iim.storage
MASTER=$HOME/iim.password
# Override these for the local IM scenario
IMDATA=""
IMSHARED=""
if [ $GLOBAL -eq 0 ]; then
IMDATA="$IIMDL/IM-data"
IMSHARED=$"IIMDL/IM-shared"
fi
# Setup parameters for real command-line IM invocations
if [ -d /cygdrive ]; then
if [ $GLOBAL -eq 0 ]; then
IMDATA_NATIVE=`cygpath -m $IMDATA`
IMSHARED_NATIVE=`cygpath -m $IMSHARED`
else
IMDATA_NATIVE=""
IMSHARED_NATIVE=""
fi
STORAGE_NATIVE=`cygpath -m $STORAGE`
MASTER_NATIVE=`cygpath -m $MASTER`
else
STORAGE_NATIVE=$STORAGE
MASTER_NATIVE=$MASTER
IMDATA_NATIVE=$IMDATA
IMSHARED_NATIVE=$IMSHARED
fi
IMDATA_ARG=""
IMSHARED_ARG=""
# Auth method
if [ ! -f "$MASTER_NATIVE" ]; then
echo "Unable to find master password file: $MASTER_NATIVE. It can be created with:"
printf "\techo \"<your-master-pass>\" > $MASTER_NATIVE\n"
exit 1
fi
if [ $NEEDPASS -eq "1" ]; then
if [ ! -f "$STORAGE_NATIVE" -a ! "$ACTION" = "addpass" -a ! "$ACTION" = "install-im" ]; then
echo "Unable to find secure storage file: $STORAGE_NATIVE. Use addpass command to create it."
exit 1
fi
AUTH_ARG="-secureStorageFile $STORAGE_NATIVE -masterPasswordFile $MASTER_NATIVE"
fi
if [ $GLOBAL -eq 0 ]; then
IMDATA_ARG="-dataLocation $IMDATA_NATIVE"
# XXX: Not used?
IMSHARED_ARG="-sharedDataLocation $IMDATA_NATIVE"
fi
# IM functions
listAvailablePackages() {
echo " Determing available packages in $PKGDL..."
# One time w/o backticks to potentially prompt
set -x
$IMCL listAvailablePackages -repositories $PKGDL $IMDATA_ARG $AUTH_ARG -prompt
set +x
PKGS=`$IMCL listAvailablePackages -repositories $PKGDL $IMDATA_ARG $AUTH_ARG -prompt`
}
lisInstalledPackages() {
echo " Determing installed packages in $INSTDIR..."
set -x
PACKAGE=`$IMCL listInstalledPackages -installationDirectory $INSTDIR $IMDATA_ARG | grep com.ibm`
set +x
}
listAvailableFixes() {
FIXES=""
echo " Determing available fixes in $PKGDL..."
set -x
for PKG in $PACKAGE; do
FIX=`$IMCL listAvailableFixes $PKG -repositories $PKGDL \
$IMDATA_ARG $AUTH_ARG`
FIXES="$FIXES $FIX"
done
set +x
}
installFix() {
echo " Installing $PKGS from $PKGDL into $INSTDIR ..."
if [ -d /cygdrive ]; then
$INSTDIR/bin/versionInfo.bat -ifixes
else
if [ -x $INSTDIR/bin/versionInfo.sh ]; then
$INSTDIR/bin/versionInfo.sh -ifixes
fi
fi
set -x
$IMCL install $PKGS -repositories $PKGDL \
$IMDATA_ARG \
-installationDirectory "$INSTDIR" \
-acceptLicense \
$AUTH_ARG
set +x
if [ -d /cygdrive ]; then
$INSTDIR/bin/versionInfo.bat -ifixes
else
if [ -x $INSTDIR/bin/versionInfo.sh ]; then
$INSTDIR/bin/versionInfo.sh -ifixes
fi
fi
}
checkRepoAuth() {
if [ ! -d "$PKGDL" -a ! -f "$PKGDL" ]; then
OUT=`wget --method=HEAD --no-check-certificate "$PKGDL" 2>&1`
# modern wget
if [ $? -eq 6 ]; then
NEED_AUTH=1
fi
# ancient wget
if echo "$OUT" | grep "401" >/dev/null; then
NEED_AUTH=1
fi
else
# IIM wont take a relative path.
FC=`echo $PKGDL|sed -e 's/^\(.\).*/\1/'`
if [ ! $FC = "/" ]; then
PKGDL=$PWD/$PKGDL
fi
fi
if [ $NEED_AUTH -eq 1 -a ! -f "$STORAGE" ]; then
echo "No $STORAGE if your repo is GSA, stash a PW in ~/iim.password and run e.g. \n\n"
echo "\t $IMUTILSC saveCredential -url $PKGDL $AUTH_ARG -userName youruser -userPassword yourpass"
exit 1
fi
if [ $NEED_AUTH -eq 1 -a ! -w "$STORAGE_NATIVE" ]; then
echo "Warning, $STORAGE_NATIVE is not writable. Passwords provided interactively will not be saved"
fi
if [ $NEED_AUTH -eq 1 -a -n "$REPOUSER" ]; then
$IMUTILSC saveCredential -url $PKGDL $AUTH_ARG -userName $REPOUSER
fi
}
if [ $ACTION = "addpass" ] ; then
$IMUTILSC saveCredential -url $PKGDL $AUTH_ARG -userName $REPOUSER -userPassword $PASS
exit $?
fi
if [ $ACTION = "list" ] ; then
listAvailablePackages
exit 0
fi
if [ $ACTION = "install-im" ]; then
echo "Trying to install global IIM"
if [ -d "/opt/IBM/InstallationManager" ]; then
echo "/opt/IBM/InstallationManager exists"
exit 1
fi
# We need a global IIM. Grab the 1.6.0 full agent and use the raw kit to install 1.8.5
OS=`uname -s`
rm -f /tmp/iimold.zip
if [ ! -f /tmp/iimold.zip ]; then
echo "Downloading old IIM to boostrap..."
ARCH=`uname -m|sed -e s/s390x/s390/g`
case $OS in
AIX) wget -q ftp://public.dhe.ibm.com/software/rationalsdp/v7/im/16/zips/agent.installer.aix.motif.ppc_1.6.0.20120831_1216.zip -O /tmp/iimold.zip
;;
Linux) wget -q ftp://public.dhe.ibm.com/software/rationalsdp/v7/im/16/zips/agent.installer.linux.gtk.${ARCH}_1.6.0.20120831_1216.zip -O /tmp/iimold.zip
;;
esac
fi
mkdir /tmp/iimold
(cd /tmp/iimold && unzip /tmp/iimold.zip)
# Use the unpacked IIM zip to install 1.8.5 from the repo.
/tmp/iimold/tools/imcl install com.ibm.cic.agent -acceptLicense -repositories ftp://public.dhe.ibm.com/software/rationalsdp/v7/im/185/repository/
IIMDL=/opt/IBM/InstallationManager
IMCL=$IIMDL/eclipse/tools/imcl
IMUTILSC=$IIMDL/eclipse/tools/imutilsc
exit 0
fi
if [ $ACTION = "install-local-im" ]; then
echo "install-local-im not yet implemented"
exit 1
fi
if [ -d /cygdrive ]; then
INSTPREFIX=c:/inst
else
INSTPREFIX=$HOME/inst
fi
if [ -z "$PKGS" ]; then
echo "Assuming -p list"
PKGS=list
fi
checkRepoAuth
ARCH=`uname -m`
OPKGS=$PKGS
if [ $ACTION = "uninstall" ]; then
set -x
lisInstalledPackages
if [ -z "$PACKAGE" ]; then
exit 0
fi
$IMCL $IMDATA_ARG uninstall $PACKAGE -installationDirectory $INSTDIR
set +x
exit 0
fi
if [ $ACTION = "rollback" ]; then
set -x
lisInstalledPackages
$IMCL $IMDATA_ARG rollback $PACKAGE -installationDirectory $INSTDIR
set +x
exit 0
fi
if [ $ACTION = "uninstall-ifix" ]; then
set -x
lisInstalledFixes
if [ ! $PKGS = "list" ]; then
$IMCL $IMDATA_ARG uninstall $PKGS -installationDirectory $INSTDIR
else
echo "Pick an ifix and and re-run with -p: $FIXES"
fi
set +x
exit 0
fi
if [ $ACTION = "update" ]; then
# Return value in PACKAGES
lisInstalledPackages
# Return value in FIXES
listAvailableFixes
if [ x"${OPKGS}" = x"list" ]; then
echo "Found Fixes: "
echo " $FIXES"
echo "Hint: $0 update $@ -p $FIXES"
exit 0
fi
if [ x"${OPKGS}" = x"all" ]; then
echo "Installing fix with: $0 $@ -p $FIXES"
exec $0 update "$@" -p $FIXES
fi
installFix
exit $?
fi
if [ $ACTION = "install" ]; then
if echo $PKGS | grep v9 ; then
# first package to install
SUB=`echo $PKGS|awk '{print $1}'`
if echo $PKGS | grep EDGE >/dev/null; then
$IMCL install $PKGS -repositories $PKGDL \
$IMDATA_ARG \
-acceptLicense $AUTH_ARG \
-showProgress
else
$IMCL install $PKGS \
-repositories $PKGDL \
-installationDirectory "$INSTDIR" \
-acceptLicense $AUTH_ARG \
$IMDATA_ARG \
-showProgress
fi
else
# 8.0/8.5
for PKG in $PKGS; do
PROPS=""
case $PKG in
*APPCLIENT*) PROPS="user.wasjava=java8,user.appclient.serverHostname=localhost,user.appclient.serverPort=2809";;
*IHS*) PROPS="user.wasjava=java6,user.ihs.httpPort=80,user.ihs.allowNonRootSilentInstall=true";;
*WAS*) PROPS="user.wasjava=java8;;"
esac
if echo $PKG | grep EDGE >/dev/null; then
$IMCL install $PKG -repositories $PKGDL \
$IMDATA_ARG \
-acceptLicense $AUTH_ARG \
-showProgress
elif [ -n "$PROPS" ]; then
$IMCL install $PKG -repositories $PKGDL \
$IMDATA_ARG \
-installationDirectory "$INSTDIR" \
-properties "$PROPS" \
-acceptLicense $AUTH_ARG \
-showProgress
else
$IMCL install $PKG -repositories $PKGDL \
$IMDATA_ARG \
-installationDirectory "$INSTDIR" \
-acceptLicense $AUTH_ARG \
-showProgress
fi
done
fi
fi