mirror of
https://github.com/MLBZ521/MacAdmin.git
synced 2026-06-12 20:30:27 +01:00
v1.3 = Reorganized code, improved processes, and fixed a few bugs
+ Changed up the while loop App existence check, as previously couldn't properly report "No versions found" + Fixed Local License install -- was hard coded to 2016 version path + Modified the expect statements as there was something causing this process to fail + Reorganized the output a bit + Moved the chmod section so it is run on all license mechanisms
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
###################################################################################################
|
||||
# Script Name: license_Maple.sh
|
||||
# By: Zack Thompson / Created: 1/8/2018
|
||||
# Version: 1.2 / Updated: 1/24/2018 / By: ZT
|
||||
# Version: 1.3 / Updated: 1/25/2018 / By: ZT
|
||||
#
|
||||
# Description: This script applies the license for Maple applications.
|
||||
#
|
||||
@@ -34,24 +34,31 @@
|
||||
##################################################
|
||||
# Bits staged, license software...
|
||||
|
||||
# If the machine has multiple Maple Applications, loop through them...
|
||||
/usr/bin/find -E /Applications -iregex ".*Maple [0-9]{4}[.]app" -maxdepth 3 -type d -prune | while IFS="\n" read -r appPath; do
|
||||
# Find all install Maple versions.
|
||||
appPaths=$(/usr/bin/find -E /Applications -iregex ".*Maple [0-9]{4}[.]app" -maxdepth 2 -type d -prune)
|
||||
|
||||
# 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}"
|
||||
# Verify that a Maple version was found.
|
||||
if [[ -z "${appPaths}" ]]; then
|
||||
/usr/bin/logger -s "A version of Maple was not located 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
|
||||
|
||||
# Location of the License File
|
||||
licenseFile="/Library/Frameworks/Maple.framework/Versions/${majorVersion}/license/license.dat"
|
||||
# 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}"
|
||||
|
||||
if [[ -d "${appPath}" ]]; then
|
||||
# Location of the License File
|
||||
licenseFile="/Library/Frameworks/Maple.framework/Versions/${majorVersion}/license/license.dat"
|
||||
|
||||
if [[ $licenseMechanism == "Network" ]]; then
|
||||
if [[ -d "${appPath}" ]]; then
|
||||
|
||||
/usr/bin/logger -s "Creating license file..."
|
||||
/usr/bin/logger -s "Setting the License Manager Server..."
|
||||
if [[ $licenseMechanism == "Network" ]]; then
|
||||
/usr/bin/logger -s "Configuring the License Manager Server..."
|
||||
|
||||
/bin/cat > "${licenseFile}" <<licenseContents
|
||||
/bin/cat > "${licenseFile}" <<licenseContents
|
||||
#
|
||||
# License File for network installations
|
||||
#
|
||||
@@ -62,69 +69,64 @@ USE_SERVER
|
||||
# You should not have to edit this file directly.
|
||||
licenseContents
|
||||
|
||||
# Set permissions on the file for everyone to be able to read.
|
||||
/usr/bin/logger -s "Applying permissions to license file..."
|
||||
/bin/chmod 644 "${licenseFile}"
|
||||
elif [[ $licenseMechanism == "Local" ]]; then
|
||||
# Assign the proper license per edition
|
||||
case "${majorVersion}" in
|
||||
"2017" )
|
||||
licenseCode="201712345678910"
|
||||
;;
|
||||
"2016" )
|
||||
licenseCode="201612345678910"
|
||||
;;
|
||||
"2015" )
|
||||
licenseCode="201512345678910"
|
||||
;;
|
||||
esac
|
||||
|
||||
elif [[ $licenseMechanism == "Local" ]]; then
|
||||
|
||||
# Assign the proper license per edition
|
||||
case "${majorVersion}" in
|
||||
"2017" )
|
||||
licenseCode="201712345678910"
|
||||
;;
|
||||
"2016" )
|
||||
licenseCode="201612345678910"
|
||||
;;
|
||||
"2015" )
|
||||
licenseCode="201512345678910"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Apply License Code
|
||||
exitStatus=$(
|
||||
# Apply License Code
|
||||
exitStatus=$(
|
||||
expect - <<activateLicense
|
||||
set timeout 1
|
||||
spawn /Library/Frameworks/Maple.framework/Versions/2016/bin/activation -console
|
||||
spawn /Library/Frameworks/Maple.framework/Versions/$majorVersion/bin/activation -console
|
||||
expect "Do you access the internet through a proxy server?" { send "no\r" }
|
||||
expect "Please enter your purchase code: " { send "${licenseCode}\r" }
|
||||
expect "First Name* []: " { send "First\r" }
|
||||
expect "Middle Initial []: " { send "\r" }
|
||||
expect "Last Name* []: " {send "Last\r" }
|
||||
expect "Email address* []: " { send "email@email.com\r" }
|
||||
expect "Phone Number []: " { send "\r" }
|
||||
expect "Address 1 []: " { send "\r" }
|
||||
expect "Address 2 []: " { send "\r" }
|
||||
expect "City []: " { send "Tempe\r" }
|
||||
expect "Province or State []: " { send "AZ\r" }
|
||||
expect "Country* []: " { send "USA\r" }
|
||||
expect "Postal Code []: " { send "\r" }
|
||||
expect "The Maple Reporter (Professional Edition) []: " { send "\r" }
|
||||
expect "The Maple Reporter (Academic Edition) []: " { send "\r" }
|
||||
expect "Upcoming Events and Seminars []: " { send "\r" }
|
||||
expect "Special Product Announcements []: " { send "\r" }
|
||||
expect "Please enter your purchase code" { send "${licenseCode}\r" }
|
||||
expect "First Name*" { send "First\r" }
|
||||
expect "Middle Initial" { send "\r" }
|
||||
expect "Last Name*" { send "Last\r" }
|
||||
expect "Email address*" { send "email@email.com\r" }
|
||||
expect "Phone Number" { send "\r" }
|
||||
expect "Address 1" { send "\r" }
|
||||
expect "Address 2" { send "\r" }
|
||||
expect "City" { send "Tempe\r" }
|
||||
expect "Province or State" { send "AZ\r" }
|
||||
expect "Country*" { send "USA\r" }
|
||||
expect "Postal Code" { send "\r" }
|
||||
expect "The Maple Reporter (Professional Edition)" { send "\r" }
|
||||
expect "The Maple Reporter (Academic Edition)" { send "\r" }
|
||||
expect "Upcoming Events and Seminars" { send "\r" }
|
||||
expect "Special Product Announcements" { send "\r" }
|
||||
interact
|
||||
activateLicense
|
||||
)
|
||||
|
||||
if [[ $exitStatus == *"Activation successful!"* ]]; then
|
||||
/usr/bin/logger -s "License Code applied successfully!"
|
||||
else
|
||||
/usr/bin/logger -s "ERROR: Failed to apply License Code"
|
||||
/usr/bin/logger -s "ERROR Contents: ${exitStatus}"
|
||||
/usr/bin/logger -s "***** License Maple process: FAILED *****"
|
||||
exit 3
|
||||
if [[ $exitStatus == *"Activation successful!"* ]]; then
|
||||
/usr/bin/logger -s "License Code applied successfully!"
|
||||
/usr/bin/logger -s "Maple ${majorVersion} has been activated!"
|
||||
else
|
||||
/usr/bin/logger -s "ERROR: Failed to apply License Code for: Maple ${majorVersion}"
|
||||
/usr/bin/logger -s "ERROR Contents: $(/bin/echo ${exitStatus} | /usr/bin/xargs)"
|
||||
/usr/bin/logger -s "***** License Maple process: FAILED *****"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
/usr/bin/logger -s "A version of Maple was not located in the expected location!"
|
||||
/usr/bin/logger -s "***** License Maple process: FAILED *****"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
if [[ $(/usr/bin/stat -f "%OLp" "${licenseFile}") != "666" ]]; then
|
||||
# Set permissions on default permissions on the file.
|
||||
/usr/bin/logger -s "Applying permissions to license file..."
|
||||
/bin/chmod 666 "${licenseFile}"
|
||||
fi
|
||||
done < <(/bin/echo "${appPaths}")
|
||||
fi
|
||||
|
||||
/usr/bin/logger -s "Maple has been activated!"
|
||||
/usr/bin/logger -s "***** License Maple process: COMPLETE *****"
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
Reference in New Issue
Block a user