v1.4.0 = Added loop to support finding multiple versions

This commit is contained in:
Zack T
2024-06-06 15:05:27 -07:00
parent db4eb91923
commit 69a8534ef2

View File

@@ -3,7 +3,7 @@
####################################################################################################
# Script Name: Install-AutoCAD.sh
# By: Zack Thompson / Created: 9/2/2020
# Version: 1.3.0 / Updated: 5/20/2024 / By: ZT
# Version: 1.4.0 / Updated: 6/6/2024 / By: ZT
#
# Description: This script silently installs AutoCAD 2023 and newer.
# Probably works for AutoCAD 2021+ as well.
@@ -15,24 +15,60 @@
echo -e "***** Install AutoCAD Process: START *****\n"
##################################################
# Helper Functions
status_code_check() {
# Check the exit code of a process
# Arguments
# $1 = (int) exit code of a process
local exit_code="${1}"
local installed_what="${2}"
if [[ $exit_code != 0 ]]; then
echo -e "[Error] Failed to install!\nExit Code: ${exit_code}"
script_exit_code=2
else
echo -e "Successfully installed: ${installed_what}"
fi
}
exit_script() {
# This function handles the exit process of the script.
# Arguments
# $1 = (int) exit code to exit the script with
local exit_code="${1}"
if [[ $exit_code -eq 0 ]]; then
exist_status="COMPLETE"
else
exist_status="FAILED"
fi
echo -e "\n***** Install AutoCAD Process: ${exist_status} *****"
exit "${exit_code}"
}
##################################################
# Bits staged...
script_exit_code=0
echo "Searching for the Installer App..."
installer_app=$( /usr/bin/find -E "/private/tmp" -iregex \
installer_apps=$( /usr/bin/find -E "/private/tmp" -iregex \
".*/Install Autodesk AutoCAD [[:digit:]]{4} for Mac[.]app" -type d -maxdepth 1 -prune )
echo "Installing: ${installer_app}"
"${installer_app}/Contents/Helper/Setup.app/Contents/MacOS/Setup" --silent
exit_code=$?
# If multiple were found, loop through them...
while IFS=$'\n' read -r installer_app; do
/bin/rm -Rf "${installer_app}"
echo "Installing: ${installer_app}"
"${installer_app}/Contents/Helper/Setup.app/Contents/MacOS/Setup" --silent
exit_code=$?
if [[ $exit_code != 0 ]]; then
echo -e "[Error] Failed to install!\nExit Code: ${exit_code}"
echo -e "\n***** Install AutoCAD process: FAILED *****"
exit $exit_code
fi
status_code_check $exit_code "${installer_app}"
/bin/rm -Rf "${installer_app}"
echo -e "AutoCAD has been installed!\n\n***** Install AutoCAD Process: COMPLETE *****"
exit 0
done < <( echo "${installer_apps}" )
exit_script $script_exit_code