Permalink
Browse files

a working patch script

  • Loading branch information...
1 parent 7da9894 commit c433e967c86d71d72a3eba8a3c44063dc9a6ac42 @danielrobbins danielrobbins committed Aug 24, 2012
Showing with 52 additions and 3 deletions.
  1. +52 −3 4.2.0-SP1/apply.sh
  2. 0 4.2.0-SP1/scripts/buildjs.sh
View
55 4.2.0-SP1/apply.sh 100644 → 100755
@@ -18,14 +18,22 @@ if [ "$USER" != "zenoss" ]; then
die "Current user is $USER. Please execute as the zenoss user."
fi
+TARGET_VERSION=4.2.0
+SP=4.2.0-SP1
+BACKUPDIR=$ZENHOME/ServicePacks/$SP
+install -d $BACKUPDIR || die "Could not create backup directory $BACKUPDIR. Aborting."
+export SIMPLE_BACKUP_SUFFIX=""
patch_apply() {
+ local errval=$1
+ shift
local fail=""
extra_args="$@"
for x in `cat patches/series`; do
- cat patches/$x | ( cd $ZENHOME; try patch -p3 -b -B ServicePacks/ $extra_args )
- if [ $? -ne 0 ]; then
+ cat patches/$x | ( cd $ZENHOME; try patch -p3 -b -B $BACKUPDIR $extra_args )
+ if [ $? -gt $errval ]; then
fail=$x
+ break
fi
done
@@ -37,4 +45,45 @@ patch_apply() {
return 0
}
-patch_apply --dry-run
+revert() {
+ echo
+ echo "There was a problem applying patches. Reverting..."
+ echo
+ cd $BACKUPDIR || die "Couldn't change directories to $BACKUPDIR to revert patches."
+ rsync -av $BACKUPDIR/ $ZENHOME/ || die "Revert failed."
+ rm -rf "$BACKUPDIR"
+ echo
+ echo "Revert successful."
+ exit 1
+}
+
+dry_run_patch_apply() {
+ echo
+ echo "Doing a dry-run patch application..."
+ echo
+ patch_apply 2 --dry-run || die "Dry-run failed. Maybe you are not running Zenoss ${TARGET_VERSION}?"
+}
+
+real_patch_apply() {
+ echo
+ echo "Applying $SP..."
+ echo
+ patch_apply 1
+ if [ $? -ne 0 ]; then
+ revert
+ else
+ echo "$SP" > $ZENHOME/ServicePacks/INSTALLED
+ fi
+}
+echo "Stopping Zenoss..."
+echo
+try zenoss stop
+dry_run_patch_apply
+real_patch_apply
+scripts/buildjs.sh || echo "Warning: Couldn't rebuild JavaScript."
+cat << EOF
+
+Service pack $SP applied successfully. Please type 'zenoss start' to restart Zenoss.
+
+EOF
+exit 0
View
0 4.2.0-SP1/scripts/buildjs.sh 100644 → 100755
No changes.

0 comments on commit c433e96

Please sign in to comment.