diff --git a/Software/SPSS Statistics/license_SPSS.sh b/Software/SPSS Statistics/license_SPSS.sh index c5fe47b..3d745b5 100644 --- a/Software/SPSS Statistics/license_SPSS.sh +++ b/Software/SPSS Statistics/license_SPSS.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_SPSS.sh # By: Zack Thompson / Created: 1/3/2018 -# Version: 1.5 / Updated: 1/30/2018 / By: ZT +# Version: 1.6.0 / Updated: 1/12/2019 / By: ZT # # Description: This script applies the license for SPSS applications. # ################################################################################################### -/usr/bin/logger -s "***** License SPSS process: START *****" +echo "***** License SPSS process: START *****" ################################################## # Turn on case-insensitive pattern matching @@ -19,38 +19,38 @@ shopt -s nocasematch case "${4}" in "T&R" | "Teaching and Research" | "Academic" ) licenseType="Academic" - ;; + ;; "Admin" | "Administrative" ) licenseType="Administrative" - ;; + ;; * ) - /usr/bin/logger -s "ERROR: Invalid License Type provided" - /usr/bin/logger -s "***** License SPSS process: FAILED *****" + echo "ERROR: Invalid License Type provided" + echo "***** License SPSS process: FAILED *****" exit 1 - ;; + ;; esac -/usr/bin/logger -s "Licensing Type: ${licenseType}" +echo "Licensing Type: ${licenseType}" # Determine License Mechanism case "${5}" 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 SPSS process: FAILED *****" + echo "ERROR: Invalid License Mechanism provided" + echo "***** License SPSS process: FAILED *****" exit 2 - ;; + ;; esac # Turn off case-insensitive pattern matching shopt -u nocasematch -/usr/bin/logger -s "Licensing Mechanism: ${licenseMechanism}" +echo "Licensing Mechanism: ${licenseMechanism}" ################################################## # Define Functions @@ -64,13 +64,13 @@ function LicenseInfo { case "${versionSPSS}" in "25" ) licenseCode="2512345678910" - ;; + ;; "24" ) licenseCode="2412345678910" - ;; + ;; "23" ) licenseCode="2312345678910" - ;; + ;; esac elif [[ $licenseType == "Administrative" ]]; then licenseManager="server.company.com" @@ -80,13 +80,13 @@ function LicenseInfo { case "${versionSPSS}" in "25" ) licenseCode="2512345678911" - ;; + ;; "24" ) licenseCode="2412345678911" - ;; + ;; "23" ) licenseCode="2312345678911" - ;; + ;; esac fi } @@ -95,27 +95,39 @@ function LicenseInfo { # Bits staged, license software... # Find all install SPSS versions. -appPaths=$(/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?([0-9]{2})?[.]app" -type d -prune) +appPaths=$( /usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?([0-9]{2})?[.]app" -type d -prune ) -# Verify that a Maple version was found. +# Verify that a SPSS version was found. if [[ -z "${appPaths}" ]]; then - /usr/bin/logger -s "A version of SPSS was not found in the expected location!" - /usr/bin/logger -s "***** License SPSS process: FAILED *****" + echo "A version of SPSS was not found in the expected location!" + echo "***** License SPSS process: FAILED *****" exit 3 else # If the machine has multiple SPSS Applications, loop through them... while IFS="\n" read -r appPath; do + ################################################## + # Define Variables + # Get the SPSS version + versionSPSS=$( /usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString | /usr/bin/awk -F "." '{print $1}' ) + # Get the App Bundle name + appName=$( echo "${appPath}" | /usr/bin/awk -F "/" '{print $NF}' ) + # Get only the install path + installPath=$( echo "${appPath}" | /usr/bin/awk -F "/${appName}" '{print $1}' ) # Set the location of bin folder - licensePath="${appPath}/Contents/bin" + licensePath="${appPath}/Contents/bin" # Set the Network License file path - networkLicense="${licensePath}/spssprod.inf" + networkLicense="${licensePath}/spssprod.inf" # Set the Local License Location file path - localLicense="${licensePath}/lservrc" + localLicense="${licensePath}/lservrc" + ################################################## + + # Setting permissions to resolve issues seen in: https://www-01.ibm.com/support/docview.wss?uid=swg21966637 + echo "Setting permissions on SPSS ${majorVersion} files..." + /usr/sbin/chown -R root:admin "${installPath}" if [[ $licenseMechanism == "Network" ]]; then - - /usr/bin/logger -s "Configuring the License Manager Server..." + echo "Configuring the License Manager Server for version: ${versionSPSS}" # Function LicenseInfo LicenseInfo @@ -125,41 +137,42 @@ else /usr/bin/sed -i '' 's/CommuterMaxLife=.*/'"CommuterMaxLife=${commuterDays}"'/' "${networkLicense}" if [[ -e "${localLicense}" ]]; then - /usr/bin/logger -s "Local License file exists; deleting..." + echo "Local License file exists; deleting..." /bin/rm -rf "${localLicense}" fi elif [[ $licenseMechanism == "Local" ]]; then - - # Get the SPSS version - versionSPSS=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString | /usr/bin/awk -F "." '{print $1}') - /usr/bin/logger -s "Apply License Code for version: ${versionSPSS}" + echo "Apply License Code for version: ${versionSPSS}" # Function LicenseInfo LicenseInfo # Apply License Code - exitStatus=$(cd "${licensePath}" && "${licensePath}"/licenseactivator "${licenseCode}") + exitStatus=$( cd "${licensePath}" && "${licensePath}"/licenseactivator "${licenseCode}" ) if [[ $exitStatus == *"Authorization succeeded"* ]]; then - /usr/bin/logger -s "License Code applied successfully!" + echo "License Code applied successfully!" + # If the network license file exists, remove the License Manager server name. if [[ -e "${networkLicense}" ]]; then - /usr/bin/logger -s "Removing Network License Manager info..." - # Remove the License Manager Server Name. + echo "Removing Network License Manager info..." /usr/bin/sed -i '' 's/DaemonHost=.*/DaemonHost=/' "${networkLicense}" fi + # Setting permissions to resolve issues as it relates to (this step is not described, but helps to resolve): https://www-01.ibm.com/support/docview.wss?uid=swg21966637 + echo "Setting permissions on the SPSS ${majorVersion} license file..." + /bin/chmod 644 "${localLicense}" + else - /usr/bin/logger -s "ERROR: Failed to apply License Code" - /usr/bin/logger -s "ERROR Contents: ${exitStatus}" - /usr/bin/logger -s "***** License SPSS process: FAILED *****" + echo "ERROR: Failed to apply License Code" + echo "ERROR Contents: ${exitStatus}" + echo "***** License SPSS process: FAILED *****" exit 4 fi fi - done < <(/bin/echo "${appPaths}") + done < <( echo "${appPaths}" ) fi -/usr/bin/logger -s "SPSS has been activated!" -/usr/bin/logger -s "***** License SPSS process: COMPLETE *****" +echo "SPSS has been activated!" +echo "***** License SPSS process: COMPLETE *****" exit 0 \ No newline at end of file