mirror of
https://github.com/MLBZ521/MacAdmin.git
synced 2026-03-20 16:00:25 +00:00
v1.2 = Improved search for Existing App Bundles
+ Changed the interpreter to bash (was causing issues) + Changed up the while loop App existence check, as previously couldn't properly report "No versions found"
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
#! /bin/bash
|
||||
|
||||
###################################################################################################
|
||||
# Script Name: uninstall_SPSS.sh
|
||||
# By: Zack Thompson / Created: 11/1/2017
|
||||
# Version: 1.1 / Updated: 1/18/2018 / By: ZT
|
||||
# Version: 1.2 / Updated: 1/25/2018 / By: ZT
|
||||
#
|
||||
# Description: Remove previous version(s) of SPSS from /Applications
|
||||
#
|
||||
@@ -11,18 +11,24 @@
|
||||
|
||||
/bin/echo "***** Uninstall SPSS process: START *****"
|
||||
|
||||
# If the machine has multiple SPSS Applications, loop through them...
|
||||
/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?(\d\d)?[.]app" -type d -prune | while IFS="\n" read -r appPath; do
|
||||
/bin/echo "Searching for existing SPSS instances..."
|
||||
appPaths=$(/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?([0-9]{2})?[.]app" -type d -prune)
|
||||
|
||||
# Get the App Bundle name
|
||||
appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}')
|
||||
# Get only the install path
|
||||
installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}')
|
||||
# Delete the old version
|
||||
/bin/echo "Uninstalling: ${appPath}"
|
||||
/bin/rm -rf "${installPath}"
|
||||
|
||||
done
|
||||
# Verify that a SPSS version was found.
|
||||
if [[ -z "${appPaths}" ]]; then
|
||||
/bin/echo "Did not find an instance SPSS!"
|
||||
else
|
||||
# If the machine has multiple SPSS Applications, loop through them...
|
||||
while IFS="\n" read -r appPath; do
|
||||
# Get the App Bundle name
|
||||
appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}')
|
||||
# Get only the install path
|
||||
installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}')
|
||||
# Delete the old version
|
||||
/bin/echo "Uninstalling: ${appPath}"
|
||||
/bin/rm -rf "${installPath}"
|
||||
done < <(/bin/echo "${appPaths}")
|
||||
fi
|
||||
|
||||
/bin/echo "***** Uninstall SPSS process: COMPLETE *****"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user