From b7a2372ebcfbf240b7c9c8b4675c9efdcc52b009 Mon Sep 17 00:00:00 2001 From: Zack T Date: Tue, 17 Apr 2018 16:45:08 -0700 Subject: [PATCH] v3.0 = Updated to handle multiple versions + Updated to handle multiple versions, including v14 --- Software/license_JMP.sh | 155 +++++++++++++++++++++++++++++----------- 1 file changed, 112 insertions(+), 43 deletions(-) diff --git a/Software/license_JMP.sh b/Software/license_JMP.sh index 039a96a..fddad05 100755 --- a/Software/license_JMP.sh +++ b/Software/license_JMP.sh @@ -3,34 +3,49 @@ ################################################################################################### # Script Name: license_JMP.sh # By: Zack Thompson / Created: 3/3/2017 -# Version: 2.1 / Updated: 1/17/2018 / By: ZT +# Version: 3.0 / Updated: 4/13/2018 / By: ZT # # Description: This script applies the license for JMP applications. # ################################################################################################### -/usr/bin/logger -s "***** License JMP process: START *****" +echo "***** License JMP process: START *****" ################################################## # Define Variables -licenseFile="/Library/Application Support/JMP/13/JMP.per" # Get the current user currentUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");') -# Get the install JMP.app edition (standard vs Pro) - appPath=$(/usr/bin/find /Applications -iname "JMP*.app" -maxdepth 1 -type d) - /usr/bin/logger -s "Applying license for: ${appPath}" +# Find all installed JMP versions. + appPaths=$(/usr/bin/find /Applications -iname "JMP*.app" -maxdepth 1 -type d) ################################################## -# Create the license file. +# Define Functions -# Assign the proper license per edition - /usr/bin/logger -s "Creating license file..." +LicenseInfo() { -if [[ $appPath == *"JMP 13.app"* ]]; then - /bin/cat > "${licenseFile}" < "${licenseFile}" < /dev/null - # Mark as 'registration requested' so it doesn't ask the user. - /usr/bin/defaults write "/Users/${currentUser}/Library/Application Support/JMP/13/License.plist" RegistrationRequested Y - # Set permissions on the plist file. - /bin/chmod 644 "/Users/${currentUser}/Library/Application Support/JMP/13/License.plist" + # Get the App Bundle name + appName=$(echo "${appPath}" | /usr/bin/awk -F "/" '{print $NF}') + echo "Version found: ${appName}" -/usr/bin/logger -s "JMP has been activated!" -/usr/bin/logger -s "***** License JMP process: COMPLETE *****" + # Function LicenseInfo + LicenseInfo "${appName}" + + # Create the license file. + echo "Creating license file..." + /usr/bin/printf "${licenseContents}" > "${licenseFile}" + + # Set permissions on the file for everyone to be able to read. + echo "Applying permissions to license file..." + /bin/chmod 644 "${licenseFile}" + + # Set the location of the license file in the System Library folder plist. + echo "Setting location of the license file..." + /usr/bin/defaults write /Library/Preferences/com.sas.jmp.plist "Setinit_${version}_Path" "${licenseFile}" + + echo "Configuring user space..." + # Remove the location from the users preference file (if it's configured there). + /usr/bin/defaults delete "/Users/${currentUser}/Library/Preferences/com.sas.jmp.plist" "Setinit_${version}_Path" &> /dev/null + + # Mark as 'registration requested' so it doesn't ask the user. + /usr/bin/defaults write "/Users/${currentUser}/Library/Application Support/JMP/${version}/License.plist" RegistrationRequested Y + + # Set permissions on the plist file. + /bin/chmod 644 "/Users/${currentUser}/Library/Application Support/JMP/${version}/License.plist" + + done < <(echo "${appPaths}") +fi + +echo "JMP has been activated!" +echo "***** License JMP process: COMPLETE *****" exit 0 \ No newline at end of file