diff --git a/bin/newExtent b/bin/newExtent index 4490b161..2bd32d8b 100755 --- a/bin/newExtent +++ b/bin/newExtent @@ -147,7 +147,8 @@ if [ "${noRestart}" = "false" ] ; then case "$filetype" in backup) - "$GS_HOME/bin/devKitCommandLine" newExtent $stoneName "$stonePath/product/bin/extent0.dbf" + # "$GS_HOME/bin/devKitCommandLine" newExtent $stoneName "$stonePath/product/bin/extent0.dbf" + "$GS_HOME/superdoit_devkit/bin/newExtent.solo" $stoneName "$stonePath/product/bin/extent0.dbf" # -N option used to ignore tranlog files during restart echo "Restarting stone and netldi" "$GS_HOME/bin/startStone" -b -N $stoneName @@ -160,9 +161,11 @@ if [ "${noRestart}" = "false" ] ; then fi if [ "${snapshotFile}x" != "x" ] ; then mimeType=`file -b --mime-type $snapshotFile | cut -d / -f 2` - "$GS_HOME/bin/devKitCommandLine" newExtent $stoneName "${snapshotFile}" $mimeType + # "$GS_HOME/bin/devKitCommandLine" newExtent $stoneName "${snapshotFile}" $mimeType + "$GS_HOME/superdoit_devkit/bin/newExtent.solo" -D $stoneName "${snapshotFile}" $mimeType else - "$GS_HOME/bin/devKitCommandLine" newExtent $stoneName + # "$GS_HOME/bin/devKitCommandLine" newExtent $stoneName + "$GS_HOME/superdoit_devkit/bin/newExtent.solo" $stoneName fi # -N option used to ignore tranlog files during restart echo "Restarting stone and netldi" @@ -191,7 +194,8 @@ else usage; exit_1_banner "snapshot file type ('${filetype}') must be 'extent' if -n option specified" fi mimeType=`file -b --mime-type $snapshotFile | cut -d / -f 2` - "$GS_HOME/bin/devKitCommandLine" newExtentForRecovery $stoneName "${snapshotFile}" $mimeType + # "$GS_HOME/bin/devKitCommandLine" newExtentForRecovery $stoneName "${snapshotFile}" $mimeType + "$GS_HOME/superdoit_devkit/bin/newExtent.solo" -R $stoneName "${snapshotFile}" $mimeType echo "Stone is now ready for recovery. Please read the How to Restore from Backup" echo "section of the manual (http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/GS64-SysAdmin-3.2.htm?http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/9-BackupAndRestore.htm#pgfId-999128)" diff --git a/superdoit_devkit/bin/newextent b/superdoit_devkit/bin/newextent deleted file mode 100755 index 5366a331..00000000 --- a/superdoit_devkit/bin/newextent +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env superdoit_solo -instvars - gsListResult -% -usage ------ -USAGE $basename stone-name [snapshot-file] [mime-type] - -DESCRIPTION - Copy a new extent to the stones extent directory - -OPTIONS - -h, --help display usage message - -EXAMPLES - $basename --help - $basename myStone - $basename myStone /opt/snapshots/mySnapshop.dbf - $basename myStone /opt/snapshots/mySnapshot.dbf.gz x-gzip ------ -% -method -newExtent - | stream stoneDirectory extentFile | - stream := self stderr. - self positionalArgs size == 0 ifTrue: [ - ^ Error signal: 'Wrong number of arguments (' , self positionalArgs size printString , ')' ]. - stoneDirectory := self gs_stoneDirectory. - extentFile := stoneDirectory / 'extents' / 'extent0.dbf'. - extentFile exists - ifTrue: [ extentFile delete ]. - self mediaType = 'x-gzip' - ifTrue: [ self gunzipSnapshotExtent: stoneDirectory ] - ifFalse: [ self copySnapshotExtent: stoneDirectory ]. - - ^ self noResult -% -method -mediaType - self positionalArgs size < 3 ifTrue: [ ^ 'octet-stream' ]. - ^ self positionalArgs at: 3 -% -method -copySnapshotExtent: stoneDirectory - "use copydbf, so that any corruption in the extent file can be found at the outset" - - self copySnapshotExtent: self snapshotFile to: stoneDirectory for: self gsVers -% -method -copySnapshotExtent: snapshotExtentFile to: stoneDirectory for: aGsVersionString - "use copydbf, so that any corruption in the extent file can be found at the outset" - - | extentFile argsArray cmdPath | - self stderr nextPutAll: ('Copying extent file: ' , snapshotExtentFile pathString printString); cr. - extentFile := stoneDirectory / 'extents' / 'extent0.dbf'. - cmdPath := (aGsVersionString beginsWith: '2.4') - ifTrue: [ - "cannot use copydbf to copy extent from product tree, so unconditionally use `cp`" - '/bin/cp' ] - ifFalse: [ (self gemstoneBin / 'copydbf') pathString ]. - argsArray := {(snapshotExtentFile pathString). (extentFile pathString)}. - self stderr nextPutAll: (self runShellCommand: cmdPath args: argsArray); cr. - OSProcess command: 'chmod +w "' , extentFile pathString, '"' -% -method -gs_stonesDirectory - ^ ((System gemEnvironmentVariable: 'GS_HOME'), '/server/stones') asFileReference -% -method -gs_stoneDirectory - ^ self gs_stonesDirectory / self stoneName -% -method -stoneName - ^ self positionalArgs at: 1 -% -method -stoneInfoFilename - ^ 'info.ston' -% -method -gs_binDirectory - ^ (System gemEnvironmentVariable: 'GEMSTONE'), '/bin/' -% -method -gsListResult - ^ gsListResult ifNil: [ gsListResult := GsHostProcess execute: self gs_binDirectory, 'gslist -lc' ] -% -method -doit - "override doit method, because ChildError does not exist in 3.6.0" - [ - self getAndVerifyOptions == self noResult - ifTrue: [ ^ self noResult ]. - ^ self theDoit - ] - on: Error - do: [ :ex | - ((self respondsTo: #'debug') and: [ self debug ]) - ifTrue: [ ex pass ]. - self - exit: ((ex respondsTo: #stderr) - ifTrue: [ ex stderr asString trimBoth ] - ifFalse: [ ex messageText ]) - withStatus: 1 "does not return" ]. -% -doit - self newExtent -% diff --git a/superdoit_devkit/bin/newextent.solo b/superdoit_devkit/bin/newextent.solo new file mode 100755 index 00000000..0cdb24fd --- /dev/null +++ b/superdoit_devkit/bin/newextent.solo @@ -0,0 +1,182 @@ +#!/usr/bin/env superdoit_solo +instvars +% +options +{ + SuperDoitOptionalOptionWithNoArg long: 'recovery' short: 'R'. +} +% +usage +----- +USAGE $basename [--help] [-R] stone-name [snapshot-file-path] [file-media-type] + +DESCRIPTION + Copy a fresh extent file to the given stone's extent directory. + +OPTIONS + -h, --help display usage message + -R, --recovery Copy a fresh extent file to the given stones extent directory, in preparation for a restore from backup. + Tranlog files are not removed, so that they can be used for recovery. + See http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/GS64-SysAdmin-3.2.htm for more info. + +EXAMPLES + $basename --help + $basename myStone + $basename myStone /opt/snapshots/mySnapshop.dbf + $basename myStone /opt/snapshots/mySnapshot.dbf.gz x-gzip + %basename -R myStone /opt/snapshots/mySnapshot.dbf +----- +% +method +newExtent + | stoneDirectory extentFile tempenvvalue | + (self positionalArgs size == 0 or:[ self recovery & (self positionalArgs size < 2) ]) ifTrue: [ + ^ Error signal: 'Wrong number of arguments (' , self positionalArgs size printString , ')' ]. + tempenvvalue := System gemEnvironmentVariable: 'GEMSTONE'. + System gemEnvironmentVariable: 'GEMSTONE' put: (System gemEnvironmentVariable: 'TARGET_GEMSTONE'). + stoneDirectory := self gs_stoneDirectory. + self stderr + nextPutAll: 'New extent for '; + nextPutAll: self stoneName; + cr. + extentFile := stoneDirectory / 'extents' / 'extent0.dbf'. + extentFile exists + ifTrue: [ extentFile delete ]. + self mediaType = 'x-gzip' + ifTrue: [ self gunzipSnapshotExtent: stoneDirectory ] + ifFalse: [ self copySnapshotExtent: stoneDirectory ]. + self stderr + nextPutAll: 'Finished copying new extent for '; + nextPutAll: self stoneName; + cr. + self recovery + ifFalse:[ self removeTranlogs ]. + System gemEnvironmentVariable: 'GEMSTONE' put: tempenvvalue. +^ self noResult +% +method +snapshotFile + self positionalArgs size < 2 ifTrue: [ ^ self gs_binDirectory / 'extent0.seaside.dbf' ]. + ^ (self positionalArgs at: 2) asFileReference +% +method +mediaType + self positionalArgs size < 3 ifTrue: [ ^ 'octet-stream' ]. + ^ self positionalArgs at: 3 +% +method +copySnapshotExtent: stoneDirectory + "use copydbf, so that any corruption in the extent file can be found at the outset" + + self copySnapshotExtent: self snapshotFile to: stoneDirectory for: self stoneInfo gsVers +% +method +copySnapshotExtent: snapshotExtentFile to: stoneDirectory for: aGsVersionString + "use copydbf, so that any corruption in the extent file can be found at the outset" + + | extentFile cmdPath | + self stderr + nextPutAll: 'Copying extent file: '; + nextPutAll: snapshotExtentFile pathString printString; + cr. + extentFile := stoneDirectory / 'extents' / 'extent0.dbf'. + cmdPath := (aGsVersionString beginsWith: '2.4') + ifTrue: [ + "cannot use copydbf to copy extent from product tree, so unconditionally use `cp`" + '/bin/cp' ] + ifFalse: [ (self gs_binDirectory / 'copydbf') pathString ]. + self stderr + nextPutAll: (GsHostProcess execute: cmdPath, ' "',(snapshotExtentFile pathString),'" "', (extentFile pathString), '"'); + cr. + cmdPath := (GsHostProcess execute: '/usr/bin/which chmod') trimBoth. + GsHostProcess execute: cmdPath, ' +w "' , extentFile pathString, '"' +% +method +gunzipSnapshotExtent: stoneDirectory + | extentDir cmdPath | + extentDir := stoneDirectory / 'extents'. + self stderr + nextPutAll: 'Gunzipping extent file: '; + nextPutAll: self snapshotFile pathString printString; + nextPutAll: ' (copying to '; + nextPutAll: extentDir pathString printString; + nextPutAll: ' first)'; + cr. + cmdPath := '/bin/cp'. + self stderr + nextPutAll: (GsHostProcess execute: cmdPath,' "',(self snapshotFile pathString), '" "',((extentDir / 'extent0.dbf.gz') pathString), '"'); + cr. + cmdPath := (GsHostProcess execute: '/usr/bin/which gunzip') trimBoth. + self stderr + nextPutAll: (GsHostProcess execute: cmdPath,' "', ((extentDir / 'extent0.dbf.gz') pathString), '"'); + cr +% +method +removeTranlogs + self stderr + nextPutAll: 'Removing tranlogs for '; + nextPutAll: self stoneName; + cr. + self removeTranlogs: self tranlogsHome. + self stderr + nextPutAll: 'Finished removing tranlogs for '; + nextPutAll: self stoneName; + cr. +% +method +removeTranlogs: tranlogDirectory + tranlogDirectory deleteAllChildren +% +method +tranlogsHome + ^ self gs_stoneDirectory / 'tranlogs' +% +method +gs_stonesDirectory + ^ ((System gemEnvironmentVariable: 'GS_HOME'), '/server/stones') asFileReference +% +method +gs_stoneDirectory + ^ self gs_stonesDirectory / self stoneName +% +method +stoneName + ^ self positionalArgs at: 1 +% +method +stoneInfoClass + ^ GsDevKitStoneInfo +% +method +stoneInfoFilename + ^ 'info.ston' +% +method +stoneInfo + ^ self stoneInfoClass importFrom: self gs_stoneDirectory / self stoneInfoFilename +% +method +gs_binDirectory + ^ (self gs_stoneDirectory / 'product' / 'bin') asFileReference +% +method +doit + "override doit method, because ChildError does not exist in 3.6.0" + [ + self getAndVerifyOptions == self noResult + ifTrue: [ ^ self noResult ]. + ^ self theDoit + ] + on: Error + do: [ :ex | + ((self respondsTo: #'debug') and: [ self debug ]) + ifTrue: [ ex pass ]. + self + exit: ((ex respondsTo: #stderr) + ifTrue: [ ex stderr asString trimBoth ] + ifFalse: [ ex messageText ]) + withStatus: 1 "does not return" ]. +% +doit + self newExtent +%