v1.5 = Improved and added additional logic into script

+ Added check to make sure a previous major version existed to upgrade
 + Improved `sed` line to insert the USER_INSTALL_DIR into the installer.properties file
 + Transposed a the '+' in the chmod line
 + Redefined the "successful" check
 + Improved `sed` line to insert the updated version into the info.plist
This commit is contained in:
Zack T
2018-01-29 22:26:46 -07:00
parent f175fb86dc
commit 21f7224ab0

View File

@@ -3,7 +3,7 @@
###################################################################################################
# Script Name: update_SPSS.sh
# By: Zack Thompson / Created: 11/22//2017
# Version: 1.4 / Updated: 1/18/2018 / By: ZT
# Version: 1.5 / Updated: 1/29/2018 / By: ZT
#
# Description: This script grabs the current location of the SPSSStatistics.app and injects it into the installer.properties file and then will upgrade an SPSS Installation.
#
@@ -31,26 +31,36 @@
##################################################
# Bits staged...
if [[ -z "${appPath}" ]]; then
/usr/bin/logger -s "A previous version SPSS was not found in the expected location!"
/usr/bin/logger -s "***** Upgrade SPSS process: FAILED *****"
exit 1
fi
/bin/echo "Upgrading SPSS Version: ${currentVersion} at path: ${appPath}"
# Inject the location to the installer.properties file
LANG=C /usr/bin/sed -i '' 's,USER_INSTALL_DIR=,&'"${installPath}"',' "${pkgDir}/installer.properties"
LANG=C /usr/bin/sed -Ei '' 's,(#)?USER_INSTALL_DIR=.*,'"USER_INSTALL_DIR=${installPath}"',' "${pkgDir}/installer.properties"
# Make sure the Patch.bin file is executable
/bin/chmod x+ "${pkgDir}/SPSS_Statistics_Installer_Mac_Patch.bin"
/bin/chmod +x "${pkgDir}/SPSS_Statistics_Installer_Mac_Patch.bin"
# Silent upgrade using information in the installer.properties file
/bin/echo "Upgrading SPSS..."
"${pkgDir}/SPSS_Statistics_Installer_Mac_Patch.bin" -f "${pkgDir}/installer.properties"
exitStatus=$?
/bin/echo "Exit Status: ${exitStatus}"
exitStatus=$("${pkgDir}/SPSS_Statistics_Installer_Mac_Patch.bin" -f "${pkgDir}/installer.properties")
exitCode=$?
if [[ $exitStatus != 0 ]]; then
# Check for the expected exit code.
if [[ "${exitCode}" != "208" ]]; then
/bin/echo "ERROR: Upgrade failed!"
/bin/echo "Exit Code: ${exitCode}"
/bin/echo "Exit Status: ${exitStatus}"
/bin/echo "***** Upgrade SPSS process: FAILED *****"
exit 1
exit 2
elif [[ $(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString) != "${version}" ]]; then
/bin/echo "Injecting the proper version string into SPSS's Info.plist"
# Inject the proper version into the Info.plist file -- this may not be required for every version; specifically v24.0.0.2, it was needed
/usr/bin/sed -i '' 's/${currentVersion}/${version}/' "${appPath}/Contents/Info.plist"
# Inject the proper version into the Info.plist file -- this may not be required for every version; specifically for v24.0.0.2, it was needed
/usr/bin/sed -Ei '' 's/'"${majorVersion}.0.0.[0-9]"'/'"${version}"'/g' "${appPath}/Contents/Info.plist"
fi
/bin/echo "Upgrade complete!"