v1.2.0 = Version Independent; Dynamically find .pkgs to be installed

Improved script to dynamically find all the .pkgs that can be installed so script is no longer version dependent.
This commit is contained in:
Zack T
2024-05-22 19:49:06 -07:00
parent e4cee0894b
commit 177749553f

View File

@@ -3,7 +3,7 @@
################################################################################################### ###################################################################################################
# Script Name: install_AutoCAD.sh # Script Name: install_AutoCAD.sh
# By: Zack Thompson / Created: 9/2/2020 # By: Zack Thompson / Created: 9/2/2020
# Version: 1.1.0 / Updated: 11/24/2020 / By: ZT # Version: 1.2.0 / Updated: 8/24/2021 / By: ZT
# #
# Description: This script silently installs AutoCAD 2021 and newer. # Description: This script silently installs AutoCAD 2021 and newer.
# #
@@ -49,30 +49,33 @@ exitCheck() {
################################################## ##################################################
# Bits staged... # Bits staged...
# "New" silent install method...that does not work when run in cli installed .pkg (but does seem to work when installing that .pkg via GUI...) # "New" silent install method...that does not work when run in a cli installed .pkg (but does seem to work when installing that .pkg via GUI...)
# installResult=$( "${pkgDir}/${AutoCADinstaller}/Contents/Helper/Setup.app/Contents/MacOS/Setup" --silent --install_mode install --hide_eula ) # installResult=$( "${pkgDir}/${AutoCADinstaller}/Contents/Helper/Setup.app/Contents/MacOS/Setup" --silent --install_mode install --hide_eula )
# Create an array of .pkg's to install
# Credit to Onkston for this install method. # Credit to Onkston for this install method.
# https://www.jamf.com/jamf-nation/discussions/35944/autocad-2021-deployment-with-network-server # https://www.jamf.com/jamf-nation/discussions/35944/autocad-2021-deployment-with-network-server
declare -a pkgArray pkgArray=$( /usr/bin/find -E "${pkgDir}/${AutoCADinstaller}/Contents/Helper" -iregex ".*[/].*[.]pkg" -prune )
pkgArray+=( "${pkgDir}/${AutoCADinstaller}/Contents/Helper/ObjToInstall/lib.pkg" )
pkgArray+=( "${pkgDir}/${AutoCADinstaller}/Contents/Helper/Packages/AdSSO/AdSSO-v2.pkg" )
pkgArray+=( "${pkgDir}/${AutoCADinstaller}/Contents/Helper/Packages/Licensing/$( /bin/ls "${pkgDir}/${AutoCADinstaller}/Contents/Helper/Packages/Licensing/" | /usr/bin/grep .pkg )" )
pkgArray+=( "${pkgDir}/${AutoCADinstaller}/Contents/Helper/ObjToInstall/licreg.pkg" )
pkgArray+=( "${pkgDir}/${AutoCADinstaller}/Contents/Helper/ObjToInstall/autocad2021.pkg" )
# Loop through each .pkg in the array. # Verify at least one version of SPSS was found.
for pkg in "${pkgArray[@]}"; do if [[ -z "${pkgArray}" ]]; then
echo "Installing ${pkg}..." exitCheck 3 "ERROR: Unable to locate .pkgs in the expected location!"
installResult=$( /usr/sbin/installer -dumplog -verbose -pkg "${pkg}" -allowUntrusted -target / )
exitCode=$?
# Function exitCheck else
exitCheck $exitCode "${pkg}" "${installResult}"
done # Loop through each .pkg in the array.
while IFS=$'\n' read -r pkg; do
echo "Installing ${pkg}..."
installResult=$( /usr/sbin/installer -dumplog -verbose -pkg "${pkg}" -allowUntrusted -target / )
exitCode=$?
# Function exitCheck
exitCheck $exitCode "${pkg}" "${installResult}"
done < <( echo "${pkgArray}" )
fi
echo "All components have been installed." echo "All components have been installed."
echo "AutoCAD has been installed!" echo "AutoCAD has been installed!"