#!/bin/bash ################################################################################################### # Script Name: license_Maple.sh # By: Zack Thompson / Created: 1/8/2018 # Version: 1.5.1 / Updated: 2/7/2018 / By: ZT # # Description: This script applies the license for Maple applications. # ################################################################################################### /usr/bin/logger -s "***** 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" ;; * ) /usr/bin/logger -s "ERROR: Invalid License Mechanism provided" /usr/bin/logger -s "***** License Maple process: FAILED *****" exit 1 ;; esac # Turn off case-insensitive pattern matching shopt -u nocasematch /usr/bin/logger -s "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 /usr/bin/logger -s "A version of Maple was not found in the expected location!" /usr/bin/logger -s "***** 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}') /usr/bin/logger -s "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 /usr/bin/logger -s "Configuring the License Manager Server..." /bin/cat > "${licenseFile}" <