From b2de3f48af4f3630e1b79b9b1be69b0e8b84b139 Mon Sep 17 00:00:00 2001 From: Zack T Date: Tue, 30 Jan 2018 17:04:51 -0700 Subject: [PATCH] v1.1 = Improved search for Existing App Bundles + Changed up the while loop App existence check, as previously couldn't properly report "No versions found" + Updated method used to aquire App Bundle Version --- Software/Matlab/license_Matlab.sh | 57 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/Software/Matlab/license_Matlab.sh b/Software/Matlab/license_Matlab.sh index 3a4c3bd..b609bdf 100755 --- a/Software/Matlab/license_Matlab.sh +++ b/Software/Matlab/license_Matlab.sh @@ -3,7 +3,7 @@ ################################################################################################### # Script Name: license_Matlab.sh # By: Zack Thompson / Created: 1/10/2018 -# Version: 1.0.1 / Updated: 1/17/2018 / By: ZT +# Version: 1.1 / Updated: 1/30/2018 / By: ZT # # Description: This script applies the license for Matlab applications. # @@ -14,38 +14,47 @@ ################################################## # Define Variables -# If the machine has multiple Matlab Applications, loop through them... -/usr/bin/find /Applications -iname "Matlab*.app" -maxdepth 1 -type d | while IFS="\n" read -r appPath; do +# Find all instances of Matlab +appPaths=$(/usr/bin/find /Applications -iname "Matlab*.app" -maxdepth 1 -type d) - # Get the Matlab version - appVersion=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString) - /usr/bin/logger -s "Applying License for Version: ${appVersion}" +# Verify that a Matlab version was found. +if [[ -z "${appPaths}" ]]; then + /usr/bin/logger -s "A version of Matlab was not found in the expected location!" + /usr/bin/logger -s "***** License Matlab process: FAILED *****" + exit 1 +else + # If the machine has multiple Matlab Applications, loop through them... + while IFS="\n" read -r appPath; do - # Build the license file location - licenseFile="${appPath}/licenses/network.lic" + # Get the Matlab version + appVersion=$(/bin/cat "${appPath}/VersionInfo.xml" | /usr/bin/grep release | /usr/bin/awk -F "<(/)?release>" '{print $2}') + /usr/bin/logger -s "Applying License for Version: ${appVersion}" - ################################################## - # Create the license file. + # Build the license file location + licenseFile="${appPath}/licenses/network.lic" - /usr/bin/logger -s "Creating license file..." + ################################################## + # Create the license file. - /bin/cat > "${licenseFile}" < "${licenseFile}" <