#!/bin/bash ################################################################################################### # Script Name: license_Maple.sh # By: Zack Thompson / Created: 1/8/2018 # Version: 1.5.2 / Updated: 3/30/2018 / By: ZT # # Description: This script applies the license for Maple applications. # ################################################################################################### echo "***** License Maple process: START *****" ################################################## # Turn on case-insensitive pattern matching shopt -s nocasematch # Determine License Mechanism case "${4}" in "LM" | "License Manager" | "Network" ) licenseMechanism="Network" ;; "Stand Alone" | "Local" ) licenseMechanism="Local" ;; * ) echo "ERROR: Invalid License Mechanism provided" echo "***** License Maple process: FAILED *****" exit 1 ;; esac # Turn off case-insensitive pattern matching shopt -u nocasematch echo "Licensing Mechanism: ${licenseMechanism}" ################################################## # Bits staged, license software... # Find all install Maple versions. appPaths=$(/usr/bin/find -E /Applications -iregex ".*Maple [0-9]{4}[.]app" -maxdepth 2 -type d -prune) # Verify that a Maple version was found. if [[ -z "${appPaths}" ]]; then echo "A version of Maple was not found in the expected location!" echo "***** License Maple process: FAILED *****" exit 2 else # If the machine has multiple Maple Applications, loop through them... while IFS="\n" read -r appPath; do # Get the Maple version majorVersion=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString | /usr/bin/awk -F "." '{print $1}') echo "Applying License for Major Version: ${majorVersion}" # Location of the License File licenseFile="/Library/Frameworks/Maple.framework/Versions/${majorVersion}/license/license.dat" if [[ -d "${appPath}" ]]; then if [[ $licenseMechanism == "Network" ]]; then echo "Configuring the License Manager Server..." /bin/cat > "${licenseFile}" <