-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathupgradeStone
executable file
·344 lines (299 loc) · 11.5 KB
/
upgradeStone
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
#! /usr/bin/env bash
#=========================================================================
# Copyright (c) 2015, 2016 GemTalk Systems, LLC <[email protected]>.
#
# MIT license: https://github.com/GsDevKit/GsDevKit_home/blob/master/license.txt
#=========================================================================
theArgs="$*"
source "${GS_HOME}/bin/private/shFeedback"
start_banner
usage() {
cat <<HELP
usage: $0 [-c] [-f] [-u] [-s <source-stone-extent-file-path>] [-l <post-load-tode-script>]
[-m <tempObjCacheSize>] [-U <gemstone-user-id>] [-P <gemstone-password>] [-W]
<source-stone-name> <target-stone-name> <gemstone-version>
OPTIONS
-h
display help
-c
Create <target-stone-name> and exit script. Do not perform upgrade.
-f
Force creation of new stone by deleting
\$GS_HOME/gemstone/stone/<target-stone-name> directory if it exists
-g
Do not install tODE in upgraded stone. Allow for upgrading a stone that
does not have tODE installed in the original stone and that should not
have installed post upgrade.
-l <post-load-tode-script>
tODE path to the tODE script that loads your application code
-m <tempObjCacheSize>
size of temp obj cache to use in KB.
Default: 100000
-s <source-stone-extent-file-path>
Path to <source-stone-name> extent file used as starting point for
upgrade. Path may be a relative file path. The snapshot file may be
an extent file (raw or gzipped (.gz)).
If the file is compressed, it will be uncompressed into the target
extents directory.
-u
Skip creation of <target-stone-name> and only run the upgrade step.
-U <gemstone-user-name>
Use <gemstone-user-id> in session description. If the user does not exist in GemStone,
then create the user after the stone has been started.
-P <gemstone-password>
Use <gemstone-password> as the password for the user specified in -U option. Default
password is swordfish. If -U not specified the -P option has no effect.
-W
enable TOPAZWAITFORDEBUG, to allow remote debugging via DEBUGGEM (3.6.x upgrades only)
EXAMPLES
$(basename $0) -h
$(basename $0) -l /home/loadMyApplication gs_3106 gs_329 3.2.9
$(basename $0) -U bozo -P theClown gs_3106 gs_329 3.2.9
$(basename $0) gs_3106 gs_329 3.2.9
HELP
}
PLATFORM="`uname -sm | tr ' ' '-'`"
if [[ "$PLATFORM" == MINGW32_NT* || "$PLATFORM" == MSYS_NT* ]] ; then
exit_1_banner "This script is a server-only script and cannot be used on Windows"
fi
if [ "${GS_HOME}x" = "x" ] ; then
exit_1_banner "The GS_HOME environment variable needs to be defined"
fi
source "${GS_HOME}/bin/defGsDevKit.env"
if [ "$GS_SERVER{}x" = "x" ] ; then
exit_1_banner "The \$GS_SERVER environment variable needs to be defined. Perhaps a stone has not been created yet?"
fi
forceArg=""
createStone="true"
runUpgrade="true"
hasSnapshotFile="false"
tempObjCacheSize="100000"
gemstoneUserId="DataCurator"
gemstonePassword="swordfish"
topazWaitForDebug=""
skipInstallTode="false"
while getopts "cfhl:s:um:U:P:Wg" OPT ; do
case "$OPT" in
h) usage; exit 0;;
c) runUpgrade="false";;
f) forceArg="-f";;
g) skipInstallTode="true";;
l) postUpgradeLoadScriptPath="${OPTARG}";;
m) tempObjCacheSize="${OPTARG}" ;;
s)
snapshotFile="${OPTARG}"
hasSnapshotFile="true"
;;
u) createStone="false";;
U) gemstoneUserId="${OPTARG}";;
P) gemstonePassword="${OPTARG}";;
W) topazWaitForDebug=" -W ";;
*) usage; exit_1_banner "Uknown option";;
esac
done
shift $(($OPTIND - 1))
if [ $# -ne 3 ]; then
usage; exit_1_banner "Three positional arguments are required"
fi
sourceStoneName="$1"
targetStoneName="$2"
gsvers="$3"
sourceStonePath="$GS_SERVER_STONES/$sourceStoneName"
targetStonePath="$GS_SERVER_STONES/$targetStoneName"
if [ ! -d "$sourceStonePath" ] ; then
exit_1_banner "The stone $sourceStoneName does not exist"
fi
sourceStoneVersion="$(sed -n '2{p;q;}' $sourceStonePath/product/version.txt| awk '{print $1;}')"
majorMinorVersion="${sourceStoneVersion:0:3}"
if [ "${hasSnapshotFile}" = "false" ] ; then
snapshotFile="$GS_SERVER_STONES/$sourceStoneName/extents/extent0.dbf"
fi
cat <<EOF
Performing the GsDevKitHome upgrade from the stone "$sourceStoneName" to the
stone "$targetStoneName":
1. executes the \$GS_HOME/bin/downloadGemStone to install GemStone $gsvers
2. executes the \$GS_HOME/bin/createStone to create the $targetStoneName stone
3. copy the extent0.dbf file from "$sourceStoneName to $targetStoneName
4. create $targetStonePath/upgradeLog
5. perform pre-upgrade tasks
6. executes the \$GEMSTONE/bin/upgradeImage script
7. executes the \$GEMSTONE/seaside/bin/upgradeSeasideImage script
8. executes the \$GS_SERVER/bin/todeLoad in $targetStoneName stone
to complete the upgrade process, unless -g option specified.
9. executes the <post-load-tode-script> (-l option), unless -g option specified.
10. perform post-upgrade tasks, unless -g option specified.
If an error occurs during execution of this script, the details of the error are
available in the topazerrors.log file in the
"$targetStonePath/upgradeLog"
directory or on stdout.
Press the return key to continue...
EOF
read prompt
"$GS_HOME/bin/stopStone" $sourceStoneName
if [ "${createStone}" = "true" ] ; then
"$GS_HOME/bin/downloadGemStone" $gsvers
"$GS_HOME/bin/createStone" $forceArg -g -U $gemstoneUserId -P $gemstonePassword $targetStoneName $gsvers
"$GS_HOME/bin/stopStone" $targetStoneName
fi
if [ "$majorMinorVersion" = "2.4" ] ; then
#Cannot use copydbf to copy a 2.4 extent to 3.x
cp "${snapshotFile}" "$targetStonePath/extents/extent0.dbf"
chmod +w "$targetStonePath/extents/extent0.dbf"
else
rm -rf "$GS_SERVER_STONES/${targetStoneName}/extents/extent0.dbf"
$GS_HOME/bin/newExtent -n -s "${snapshotFile}" $targetStoneName
fi
rm -rf $targetStonePath/tranlogs/tranlog*.dbf
"$GS_HOME/bin/private/preUpgradeStone" $sourceStoneName $targetStoneName $gsvers
pushd "${targetStonePath}" >& /dev/null
source stone.env
if [ ! -d "upgradeLog" ] ; then
mkdir upgradeLog
fi
cd upgradeLog
export upgradeLogDir="$(pwd)"
popd >& /dev/null
if [ "$runUpgrade" = "false" ] ; then
exit_0_banner "$targetStoneName created"
fi
"$GS_HOME/bin/stopNetldi" $targetStoneName
"$GS_HOME/bin/startNetldi" $targetStoneName # pick up $upgradeLogDir
startStoneArg=""
if [ "$majorMinorVersion" = "2.4" ] ; then
startStoneArg="-C"
fi
"$GS_HOME/bin/startStone" $startStoneArg -b -w 5 $targetStoneName
pushd "${upgradeLogDir}" >& /dev/null
# start standard upgrade
echo "STARTING standard upgradeImage "
set +e
"$GEMSTONE/bin/upgradeImage" -c $tempObjCacheSize -s $GEMSTONE_NAME << EOF
EOF
status=$?
set -e
echo "================== START of tail -100 of $upgradeLogDir/upgradeImage.out"
tail -100 $upgradeLogDir/upgradeImage.out
echo "================== END of tail -100 of $upgradeLogDir/upgradeImage.out"
if [ "$status" != "0" ] ; then
echo "STANDARD UPGRADE FINISHED UNSUCCESSFULLY WITH $status exit status"
exit $status
fi
echo "STANDARD UPGRADE FINISHED SUCCESSFULLY WITH $status exit status"
# use default Bootstrap globals for Seaside upgrade
# start "seaside" upgrade to upgrade GLASS to 1.0-beta.9.1
echo "STARTING upgradeSeasideImage"
case "$gsvers" in
3.2.16|3.2.17|3.3.[1-9]*|3.4.*)
"$GS_HOME/bin/private/preUpgradeSeasideImage" $targetStoneName "$upgradeLogDir"
export upgradeDir=$GEMSTONE/upgrade
$GS_HOME/bin/startTopaz $targetStoneName -l -T ${tempObjCacheSize} >> $upgradeLogDir/topaz.out 2>&1 << EOF
set user SystemUser p swordfish
display resultcheck
level 0
login
display oops
iferr 1 stk
iferr 2 stack
status
time
! comment out following for debugging
iferr 4 exit
run
UserGlobals at: #SeasideUpgradeUser put: '$gemstoneUserId'.
System commitTransaction.
%
input $GEMSTONE/upgrade/prepareSeasideImage.topaz
exit 0
EOF
"$GS_HOME/bin/startTopaz" $targetStoneName -l -T ${tempObjCacheSize} >> $upgradeLogDir/topaz.out 2>&1 << EOF
input $GEMSTONE/upgrade/bootstrapSeasideImage.topaz
exit 0
EOF
"$GS_HOME/bin/private/postUpgradeSeasideImage" $targetStoneName "$upgradeLogDir"
echo "Seaside Upgrade completed. No errors detected."
;;
3.5.*|3.6.*|3.7.*|3.8.*|3.9.*)
case "$gsvers" in
3.5.*) remoteDebugFlag="";; # remote debugging flag is not available in 3.5.x
*) remoteDebugFlag="$topazWaitForDebug" ;;
esac
set +e
upgradeScript=$GEMSTONE/upgrade/createGsDevKit_upgrade.topaz
"$GEMSTONE/seaside/bin/upgradeSeasideImage" -c $tempObjCacheSize -s $targetStoneName -u $gemstoneUserId -p $gemstonePassword -P $upgradeScript $remoteDebugFlag 2>&1 << EOF
EOF
status=$?
set -e
echo "================== START of tail -100 of $upgradeLogDir/upgradeSeasideImage.out"
tail -100 $upgradeLogDir/upgradeSeasideImage.out
echo "================== END of tail -100 of $upgradeLogDir/upgradeSeasideImage.out"
if [ "$status" != "0" ] ; then
echo "UPGRADE FINISHED UNSUCCESSFULLY WITH $status exit status"
else
echo "UPGRADE FINISHED SUCCESSFULLY WITH $status exit status"
case "$gsvers" in
3.5.*)
# patch https://github.com/GsDevKit/GsDevKit/issues/129
echo "PATCHING https://github.com/GsDevKit/GsDevKit/issues/129"
$GS_HOME/bin/startTopaz $targetStoneName -l 2>&1 << EOF
login
display oops
iferr 1 stk
iferr 2 stack
iferr 3 exit
run
SessionMethodTransactionBoundaryPolicy install.
System commitTransaction
%
logout
exit 0
EOF
echo "PATCHED https://github.com/GsDevKit/GsDevKit/issues/129"
;;
esac
if [ "${postUpgradeLoadScriptPath}x" != "x" ] ; then
#install application code
echo "Running ${postUpgradeLoadScriptPath} tODE script"
"$GS_HOME/bin/private/gsDevKitTodeCommandLine" todeIt $targetStoneName << TODE
project upgrade --install=${postUpgradeLoadScriptPath}
TODE
echo "Finished ${postUpgradeLoadScriptPath} tODE script"
fi
fi
exit $status # all necessary processing has been completed
;;
*)
"$GS_HOME/bin/private/preUpgradeSeasideImage" $targetStoneName "$upgradeLogDir"
"$GEMSTONE/seaside/bin/upgradeSeasideImage" -c $tempObjCacheSize -s $targetStoneName >> $upgradeLogDir/topaz.out 2>&1 << EOF
EOF
"$GS_HOME/bin/private/postUpgradeSeasideImage" $targetStoneName "$upgradeLogDir"
;;
esac
popd >& /dev/null
if [ "${skipInstallTode}" = "true" ] ; then
echo "Installation of tODE SKIPPED"
echo " Post upgrade load script SKIPPED"
echo " postUpgradeStone tasks SKIPPED"
else
echo "Installing tODE"
"$GS_HOME/bin/todeLoad" $targetStoneName
if [ "${createStone}" = "true" ] ; then
if [ -d "$GS_SYS_STONES/$sourceStoneName/projects" ] ; then
cp -r $GS_SYS_STONES/$sourceStoneName/projects/. \
$GS_SYS_STONES/$targetStoneName/projects/
fi
if [ -d "$GS_SYS_STONES/$sourceStoneName/home" ] ; then
cp -r $GS_SYS_STONES/$sourceStoneName/home/. \
$GS_SYS_STONES/$targetStoneName/home/
fi
fi
if [ "${postUpgradeLoadScriptPath}x" != "x" ] ; then
#install application code
echo "Running ${postUpgradeLoadScriptPath} tODE script"
"$GS_HOME/bin/private/gsDevKitTodeCommandLine" todeIt $targetStoneName << TODE
project upgrade --install=${postUpgradeLoadScriptPath}
TODE
fi
echo "Performing post upgrade tasks"
"$GS_HOME/bin/devKitCommandLine" postUpgradeStone $sourceStoneName $targetStoneName $gsvers
fi
exit_0_banner "...finished"