#!/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-3" 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 unistaller will remove the final NeDi Patch 3 files" echo "and replace the alpha files." 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 the NeDi portion 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 mv $GWDIR/nedi.alpha/System-Files.php $GWDIR/nedi/html/ mv $GWDIR/nedi.alpha/System-Policy.php $GWDIR/nedi/html/ mv $GWDIR/nedi.alpha/Topology-Networks.php $GWDIR/nedi/html/ mv $GWDIR/nedi.alpha/libmon.php $GWDIR/nedi/html/inc/ mv $GWDIR/nedi.alpha/libdb.pm $GWDIR/nedi/inc/ mv $GWDIR/nedi.alpha/libsnmp.pm $GWDIR/nedi/inc/ rm -rf $GWDIR/nedi.alpha echo "Starting gwservices..." /etc/init.d/groundwork start gwservices echo "==================================================" echo "UNINSTALL COMPLETE: `date`" rm $OUTFILE