#!/bin/bash set -e -o pipefail errhandler() { echo >&2 echo "Uninstallation encountered error on line $1. Aborting. Please contact Groundwork Support for assistance." >&2 echo >&2 } trap 'errhandler $LINENO' ERR GWVER="7.1.1" PATCH="TB$GWVER-2" GWDIR="/usr/local/groundwork" OUTDIR="$GWDIR/common/var/patches" LOGFILE="$OUTDIR/$PATCH.log" OUTFILE="$OUTDIR/$PATCH.installed" echo "===== Groundwork Patch $PATCH uninstaller =====" echo echo "This patch will allow you to have Groundwork use a" echo "custom installed JDK7 instead of the included Oracle JDK7." echo echo "Please note that this script will stop/start Groundwork which" echo "will result in a few minutes of downtime. This script will also" echo "modify various portions of your Groundwork installation." echo echo -n "Ok to proceed? [y/N] " read -r proceed echo case "$proceed" in [yY][eE][sS]|[yY]) ;; *) echo "Installation aborted" exit 0 ;; esac if [[ $EUID -ne 0 ]]; then echo "ERROR: This script must be run as root" >&2 exit 1 fi if [ ! -f $OUTFILE ]; then echo "ERROR: Patch not installed. Please contact Groundwork Support for assistance." >&2 exit 1 fi if ! grep -Exq "version= 7.1.0|version= $GWVER" $GWDIR/Info.txt; then echo "ERROR: Version 7.1.0 or $GWVER required" >&2 exit 1 fi exec &> >(tee -a "$LOGFILE") echo "PATCH: $PATCH" echo "USER: $USER" echo "HOST: `hostname -f`" echo "UNINSTALL START: `date`" echo "==================================================" echo "Stopping gwservices..." /etc/init.d/groundwork stop gwservices echo "Restoring original JDK..." mv $GWDIR/java.original $GWDIR/java echo "Restoring original $GWDIR/scripts/setenv.sh..." mv $GWDIR/scripts/setenv.sh.original $GWDIR/scripts/setenv.sh echo "Restoring original $GWDIR/nagios/libexec/check_jvm.pl..." mv $GWDIR/nagios/libexec/check_jvm.pl.original $GWDIR/nagios/libexec/check_jvm.pl echo "Restoring original $GWDIR/foundation/container/rstools/php/bsmCheck/protected/components/ConsoleCommand.php..." mv $GWDIR/foundation/container/rstools/php/bsmCheck/protected/components/ConsoleCommand.php.original $GWDIR/foundation/container/rstools/php/bsmCheck/protected/components/ConsoleCommand.php echo "Starting gwservices..." /etc/init.d/groundwork start gwservices echo "==================================================" echo "UNINSTALL COMPLETE: `date`" rm $OUTFILE