├── Computer_Enrollment_LaunchAgent.sh ├── Computer_Enrollment_PromptForName.sh ├── Install_FirefoxESR.sh ├── Install_GoogleChrome.sh ├── Install_Unity_Hub.sh ├── Install_VLC.sh ├── Install_Zoom.sh └── README.md /Computer_Enrollment_LaunchAgent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # You will want to customize this script for your environment starting at line 132. 4 | # Everything from 132 down is just an example from my environment. 5 | 6 | # Variables 7 | 8 | # Set these for your environment 9 | jamfHelperHeading='My Org' 10 | jamfHelperIconPath='/Library/Application\ Support/MyOrg/Logo.png' 11 | launchAgentName='org.my.jamfHelperSplashScreen' 12 | 13 | # You probably don't need to change these 14 | launchAgentPath="/Library/LaunchAgents/${launchAgentName}.plist" 15 | jamfHelperPath='/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper' 16 | 17 | # Functions 18 | 19 | startSplashScreen () { 20 | 21 | # Check for user not logged in 22 | if [[ -z "$loggedInUser" ]]; then 23 | 24 | # Remove existing LaunchAgent 25 | if [[ -f ${launchAgentPath} ]]; then 26 | rm ${launchAgentPath} 27 | fi 28 | 29 | # Write LaunchAgent to load jamfHelper script 30 | defaults write ${launchAgentPath} KeepAlive -bool true 31 | defaults write ${launchAgentPath} Label ${launchAgentName} 32 | defaults write ${launchAgentPath} LimitLoadToSessionType "LoginWindow" 33 | defaults write ${launchAgentPath} ProgramArguments -array-add "$jamfHelperPath" 34 | defaults write ${launchAgentPath} ProgramArguments -array-add "-windowType" 35 | defaults write ${launchAgentPath} ProgramArguments -array-add "fs" 36 | defaults write ${launchAgentPath} ProgramArguments -array-add "-heading" 37 | defaults write ${launchAgentPath} ProgramArguments -array-add "$jamfHelperHeading" 38 | defaults write ${launchAgentPath} ProgramArguments -array-add "-description" 39 | defaults write ${launchAgentPath} ProgramArguments -array-add "$message" 40 | defaults write ${launchAgentPath} ProgramArguments -array-add "-icon" 41 | defaults write ${launchAgentPath} ProgramArguments -array-add "$jamfHelperIconPath" 42 | defaults write ${launchAgentPath} RunAtLoad -bool true 43 | chown root:wheel ${launchAgentPath} 44 | chmod 644 ${launchAgentPath} 45 | echo "Created Launch Agent to run jamfHelper" 46 | 47 | # Kill/restart the loginwindow process to load the LaunchAgent 48 | echo "Ready to lock screen. Restarting loginwindow..." 49 | if [[ ${osversMajor} -eq 10 && ${osversMinor} -le 14 ]]; then 50 | killall -HUP loginwindow 51 | fi 52 | if [[ ${osversMajor} -eq 10 && ${osversMinor} -ge 15 ]]; then 53 | launchctl kickstart -k system/com.apple.loginwindow # kickstarting the login window works but is slower and results in a runaway SecurityAgent process in macOS 10.15 54 | sleep 0.5 55 | killall -HUP SecurityAgent # kill the runaway SecurityAgent process 56 | fi 57 | if [[ ${osversMajor} -ge 11 ]]; then 58 | launchctl kickstart -k system/com.apple.loginwindow 59 | fi 60 | fi 61 | } 62 | 63 | killSplashScreen () { 64 | # Remove existing LaunchAgent and restart login window 65 | if [[ -f ${launchAgentPath} ]]; then 66 | echo "Removing LaunchAgent located at ${launchAgentPath}" 67 | rm ${launchAgentPath} 68 | fi 69 | 70 | echo "Restarting loginwindow..." 71 | killall loginwindow 72 | } 73 | 74 | removeLaunchAgentAtReboot () { 75 | # Create a self-destructing LaunchDaemon to remove our LaunchAgent at next startup 76 | if [[ -f ${launchAgentPath} ]]; then 77 | launchDaemonName="${launchAgentName}.remove" 78 | launchDaemonPath="/Library/LaunchDaemons/${launchDaemonName}.plist" 79 | defaults write ${launchDaemonPath} Label "${launchDaemonName}" 80 | defaults write ${launchDaemonPath} ProgramArguments -array-add "rm" 81 | defaults write ${launchDaemonPath} ProgramArguments -array-add "${launchAgentPath}" 82 | defaults write ${launchDaemonPath} ProgramArguments -array-add "${launchDaemonPath}" 83 | defaults write ${launchDaemonPath} RunAtLoad -bool true 84 | chown root:wheel ${launchDaemonPath} 85 | chmod 644 ${launchDaemonPath} 86 | echo "Created Launch Daemon to remove ${launchAgentPath}" 87 | fi 88 | } 89 | 90 | # Start script 91 | 92 | osversMajor=$(sw_vers -productVersion | awk -F. '{print $1}') 93 | osversMinor=$(sw_vers -productVersion | awk -F. '{print $2}') 94 | 95 | # Only proceed if macOS version is 10.13 or higer 96 | if [[ ${osversMajor} -eq 10 && ${osversMinor} -le 12 ]]; then 97 | echo "macOS version ${osversMajor}.${osversMinor} not supported." 98 | exit 0 99 | fi 100 | 101 | # Get currently logged in user 102 | loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) 103 | 104 | # Wait for _mbsetupuser to not be logged in (used by Apple for setup screens) 105 | while [[ $loggedInUser = "_mbsetupuser" ]] 106 | do 107 | sleep 5 108 | loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) 109 | #echo "Waiting for _mbsetupuser" 110 | done 111 | 112 | # Check for logged in user and exit if true 113 | if [[ -n "$loggedInUser" ]]; then 114 | echo "$loggedInUser is logged in. Exiting..." 115 | exit 0 116 | fi 117 | 118 | message="Starting Final Setup..." 119 | startSplashScreen 120 | 121 | # Keep this Mac from dozing off 122 | caffeinate -d -i -s -t 7200 & 123 | 124 | # Prevent Jamf check-in policies from running until next reboot 125 | launchctl unload /Library/LaunchDaemons/com.jamfsoftware.task.1.plist 126 | launchctl unload /Library/LaunchDaemons/com.jamfsoftware.jamf.daemon.plist 127 | 128 | # Run Jamf enrollment policies (custom these as needed for your environment) 129 | # When you want to change the jamfHeper message, set the message variable and run startSplashScreen 130 | # Either run killSplashScreen at the end of your script or use removeLaunchAgentAtReboot if you will be restarting the computer 131 | 132 | # Set computer name / join AD 133 | jamf policy -event enrollment_02 134 | 135 | # Enable SSH 136 | jamf policy -event enrollment_03 137 | 138 | # Set Energy Saver 139 | jamf policy -event enrollment_04 140 | 141 | message="Installing Canon Print Drivers..." 142 | startSplashScreen 143 | jamf policy -event enrollment_05 144 | 145 | message="Installing HP Print Drivers..." 146 | startSplashScreen 147 | jamf policy -event enrollment_06 148 | 149 | message="Installing Microsoft Office..." 150 | startSplashScreen 151 | jamf policy -event enrollment_07 152 | 153 | # Update inventory to avoid running unneccessary startup policies 154 | message="Updating Inventory..." 155 | startSplashScreen 156 | jamf recon 157 | 158 | # Run Jamf startup policies 159 | message="Checking Policies..." 160 | startSplashScreen 161 | jamf policy -event startup 162 | 163 | # Cleanup (anything you might want to do before starting software updates and/or restarting the computer) 164 | jamf policy -event enrollment_15 165 | removeLaunchAgentAtReboot 166 | 167 | # Check for software updates and reboot 168 | message="Checking Software Updates..." 169 | startSplashScreen 170 | jamf policy -event enrollment_20 171 | -------------------------------------------------------------------------------- /Computer_Enrollment_PromptForName.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | # Get serial number 4 | serialNumber=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}') 5 | 6 | # Set name to serial number (in case name is not set by user) 7 | scutil --set ComputerName "$serialNumber" 8 | sleep 1 9 | scutil --set LocalHostName "$serialNumber" 10 | sleep 1 11 | scutil --set HostName "$serialNumber" 12 | sleep 1 13 | 14 | # Get currently logged in user 15 | loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) 16 | 17 | # Only proceed if _mbsetupuser is logged in (used by Apple for setup screens) 18 | if [[ ! $loggedInUser = "_mbsetupuser" ]]; then 19 | echo "Logged in user is not _mbsetupuser. Exiting..." 20 | exit 0 21 | fi 22 | 23 | # Get the logged in UID 24 | loggedInUID=$(id -u $loggedInUser) 25 | 26 | # Prompt for Computer Name as the user 27 | /bin/launchctl asuser "${loggedInUID}" sudo -iu "${loggedInUser}" whoami 28 | computerName=$(/bin/launchctl asuser "${loggedInUID}" sudo -iu "${loggedInUser}" /usr/bin/osascript< /dev/null; then 38 | echo "${appProcessName} is currently running" 39 | echo "Aborting install" 40 | exit 0 41 | else 42 | echo "${appProcessName} not currently running" 43 | fi 44 | } 45 | 46 | tryDownload () { 47 | if curl -LSs "${downloadUrl}" -o "${tmpDir}/${pkgName}"; then 48 | echo "Download successful" 49 | tryDownloadState=1 50 | else 51 | echo "Download unsuccessful" 52 | tryDownloadCounter=$((tryDownloadCounter+1)) 53 | fi 54 | } 55 | 56 | versionCheck () { 57 | if [[ -d "${appPath}" ]]; then 58 | echo "${appName} version is $(defaults read "${appPath}"/Contents/Info.plist CFBundleShortVersionString)" 59 | versionCheckStatus=1 60 | else 61 | echo "${appName} not installed" 62 | versionCheckStatus=0 63 | fi 64 | } 65 | 66 | # Start 67 | 68 | # List version 69 | versionCheck 70 | 71 | # Download pkg file into tmp dir (60 second timeouet) 72 | tryDownloadState=0 73 | tryDownloadCounter=0 74 | while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do 75 | processCheck 76 | createTmpDir 77 | tryDownload 78 | sleep 1 79 | done 80 | 81 | # Check for successful download 82 | if [[ ! -f "${tmpDir}/${pkgName}" ]]; then 83 | echo "Download failed" 84 | cleanup 85 | exit 1 86 | fi 87 | 88 | # Install package 89 | echo "Starting install" 90 | installer -pkg "${tmpDir}/${pkgName}" -target / 91 | 92 | # Remove tmp dir and downloaded pkg package 93 | cleanup 94 | 95 | # List version and exit with error code if not found 96 | versionCheck 97 | if [[ ${versionCheckStatus} -eq 0 ]]; then 98 | exit 1 99 | fi 100 | -------------------------------------------------------------------------------- /Install_GoogleChrome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | # Automatically download and install the latest Google Chrome 4 | 5 | # https://support.google.com/chrome/a/answer/9915669?hl=en 6 | 7 | # Variables 8 | appName="Google Chrome.app" 9 | appPath="/Applications/${appName}" 10 | appProcessName="Google Chrome" 11 | downloadUrl="https://dl.google.com/chrome/mac/stable" 12 | #downloadUrl="https://dl.google.com/chrome/mac/universal/stable/gcem" 13 | pkgName="GoogleChrome.pkg" 14 | acceptTerms="accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms" 15 | 16 | cleanup () { 17 | if [[ -f "${tmpDir}/${pkgName}" ]]; then 18 | if rm -f "${tmpDir}/${pkgName}"; then 19 | echo "Removed file ${tmpDir}/${pkgName}" 20 | fi 21 | fi 22 | if [[ -d "${tmpDir}" ]]; then 23 | if rm -R "${tmpDir}"; then 24 | echo "Removed directory ${tmpDir}" 25 | fi 26 | fi 27 | } 28 | 29 | createTmpDir () { 30 | if [ -z ${tmpDir+x} ]; then 31 | tmpDir=$(mktemp -d) 32 | echo "Temp dir set to ${tmpDir}" 33 | fi 34 | } 35 | 36 | processCheck () { 37 | if pgrep -x "${appProcessName}" > /dev/null; then 38 | echo "${appProcessName} is currently running" 39 | echo "Aborting install" 40 | exit 0 41 | else 42 | echo "${appProcessName} not currently running" 43 | fi 44 | } 45 | 46 | tryDownload () { 47 | if curl -LSs "${downloadUrl}/${acceptTerms}/${pkgName}" -o "${tmpDir}/${pkgName}"; then 48 | echo "Download successful" 49 | tryDownloadState=1 50 | else 51 | echo "Download unsuccessful" 52 | tryDownloadCounter=$((tryDownloadCounter+1)) 53 | fi 54 | } 55 | 56 | versionCheck () { 57 | if [[ -d "${appPath}" ]]; then 58 | echo "${appName} version is $(defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString)" 59 | versionCheckStatus=1 60 | else 61 | echo "${appName} not installed" 62 | versionCheckStatus=0 63 | fi 64 | } 65 | 66 | # Start 67 | 68 | # List version 69 | versionCheck 70 | 71 | # Download pkg file into tmpDir (60 second timeout) 72 | tryDownloadState=0 73 | tryDownloadCounter=0 74 | while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do 75 | processCheck 76 | createTmpDir 77 | tryDownload 78 | sleep 1 79 | done 80 | 81 | # Check for successful download 82 | if [[ ! -f "${tmpDir}/${pkgName}" ]]; then 83 | echo "Download failed" 84 | cleanup 85 | exit 1 86 | fi 87 | 88 | # Install package 89 | echo "Starting install" 90 | installer -pkg "${tmpDir}/${pkgName}" -target / 91 | 92 | # Remove tmp dir and downloaded pkg file 93 | cleanup 94 | 95 | # List version and exit with error code if not found 96 | versionCheck 97 | if [[ ${versionCheckStatus} -eq 0 ]]; then 98 | exit 1 99 | fi 100 | -------------------------------------------------------------------------------- /Install_Unity_Hub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | # Automatically download and Unity Hub 4 | 5 | if [[ -z $4 ]]; then 6 | echo "Version not specified" 7 | exit 1 8 | fi 9 | 10 | # Variables 11 | appName="Unity Hub.app" 12 | appPath="/Applications/${appName}" 13 | appProcessName="Unity Hub" 14 | dmgName="UnityHubSetup.dmg" 15 | dmgVolumePath="/Volumes/Unity Hub $4" 16 | downloadUrl="https://public-cdn.cloud.unity3d.com/hub/prod" 17 | 18 | cleanup () { 19 | if [[ -f "${tmpDir}/${dmgName}" ]]; then 20 | if rm -f "${tmpDir}/${dmgName}"; then 21 | echo "Removed file ${tmpDir}/${dmgName}" 22 | fi 23 | fi 24 | if [[ -d "${tmpDir}" ]]; then 25 | if rm -R "${tmpDir}"; then 26 | echo "Removed directory ${tmpDir}" 27 | fi 28 | fi 29 | if [[ -d "${dmgVolumePath}" ]]; then 30 | if hdiutil detach "${dmgVolumePath}" -quiet; then 31 | echo "Unmounted DMG" 32 | fi 33 | fi 34 | } 35 | 36 | createTmpDir () { 37 | if [ -z ${tmpDir+x} ]; then 38 | tmpDir=$(mktemp -d) 39 | echo "Temp dir set to ${tmpDir}" 40 | fi 41 | } 42 | 43 | processCheck () { 44 | if pgrep -x "${appProcessName}" > /dev/null; then 45 | echo "${appProcessName} is currently running" 46 | echo "Aborting install" 47 | cleanup 48 | exit 0 49 | else 50 | echo "${appProcessName} not currently running" 51 | fi 52 | } 53 | 54 | tryDownload () { 55 | if curl -LSs "${downloadUrl}/${dmgName}" -o "${tmpDir}/${dmgName}"; then 56 | echo "Download successful" 57 | tryDownloadState=1 58 | else 59 | echo "Download unsuccessful" 60 | tryDownloadCounter=$((tryDownloadCounter+1)) 61 | fi 62 | } 63 | 64 | versionCheck () { 65 | if [[ -d "${appPath}" ]]; then 66 | echo "${appName} version is $(defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString)" 67 | versionCheckStatus=1 68 | else 69 | echo "${appName} not installed" 70 | versionCheckStatus=0 71 | fi 72 | } 73 | 74 | # Start 75 | 76 | # List version 77 | versionCheck 78 | 79 | # Make sure volume is not already mounted and unmount if needed 80 | if [[ -d "${dmgVolumePath}" ]]; then 81 | echo "${dmgVolumePath} already in use. Attempting to unmount" 82 | hdiutil detach "${dmgVolumePath}" 83 | fi 84 | 85 | # Download dmg file into tmp dir (60 second timeout) 86 | tryDownloadState=0 87 | tryDownloadCounter=0 88 | while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do 89 | processCheck 90 | createTmpDir 91 | tryDownload 92 | sleep 1 93 | done 94 | 95 | # Check for successful download 96 | if [[ ! -f "${tmpDir}/${dmgName}" ]]; then 97 | echo "Download unsuccessful" 98 | cleanup 99 | exit 1 100 | fi 101 | 102 | # Mount dmg file 103 | if hdiutil attach "${tmpDir}/${dmgName}" -nobrowse -quiet; then 104 | echo "Mounted DMG" 105 | else 106 | echo "Failed to mount DMG" 107 | cleanup 108 | exit 1 109 | fi 110 | 111 | # Check for expected dmg path 112 | if [[ ! -d "${dmgVolumePath}" ]]; then 113 | echo "Could not locate ${dmgVolumePath}" 114 | cleanup 115 | exit 1 116 | fi 117 | 118 | # Remove app if already installed 119 | if [[ -d "${appPath}" ]]; then 120 | if rm -R "${appPath}"; then 121 | echo "Removed existing ${appName} from /Applications directory" 122 | else 123 | echo "Failed to remove existing ${appName} from /Applications directory" 124 | cleanup 125 | exit 1 126 | fi 127 | fi 128 | 129 | # Copy application to /Applications 130 | if cp -R "${dmgVolumePath}/${appName}" /Applications/; then 131 | echo "Copied ${appName} to /Applications directory" 132 | else 133 | echo "Failed to copy ${appName} to /Applications directory" 134 | fi 135 | 136 | # Remove tmp dir and downloaded dmg file 137 | cleanup 138 | 139 | # List version and exit with error code if not found 140 | versionCheck 141 | if [[ ${versionCheckStatus} -eq 0 ]]; then 142 | exit 1 143 | fi 144 | -------------------------------------------------------------------------------- /Install_VLC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | # Automatically download and install VLC 4 | 5 | if [[ -z $4 ]]; then 6 | echo "Version not specified" 7 | exit 1 8 | fi 9 | 10 | if [[ -z $5 ]]; then 11 | echo "Checksum not specified" 12 | exit 1 13 | fi 14 | 15 | # Variables 16 | appName="VLC.app" 17 | appPath="/Applications/${appName}" 18 | appProcessName="VLC" 19 | dmgName="vlc-$4-universal.dmg" 20 | dmgVolumePath="/Volumes/VLC media player" 21 | #downloadUrl="https://download.videolan.org/pub/videolan/vlc/$4/macosx" 22 | downloadUrl="https://get.videolan.org/vlc/$4/macosx" 23 | 24 | checksum="$5" 25 | 26 | cleanup () { 27 | if [[ -f "${tmpDir}/${dmgName}" ]]; then 28 | if rm -f "${tmpDir}/${dmgName}"; then 29 | echo "Removed file ${tmpDir}/${dmgName}" 30 | fi 31 | fi 32 | if [[ -d "${tmpDir}" ]]; then 33 | if rm -R "${tmpDir}"; then 34 | echo "Removed directory ${tmpDir}" 35 | fi 36 | fi 37 | if [[ -d "${dmgVolumePath}" ]]; then 38 | if hdiutil detach "${dmgVolumePath}" -quiet; then 39 | echo "Unmounted DMG" 40 | fi 41 | fi 42 | } 43 | 44 | createTmpDir () { 45 | if [ -z ${tmpDir+x} ]; then 46 | tmpDir=$(mktemp -d) 47 | echo "Temp dir set to ${tmpDir}" 48 | fi 49 | } 50 | 51 | processCheck () { 52 | if pgrep -x "${appProcessName}" > /dev/null; then 53 | echo "${appProcessName} is currently running" 54 | echo "Aborting install" 55 | cleanup 56 | exit 0 57 | else 58 | echo "${appProcessName} not currently running" 59 | fi 60 | } 61 | 62 | tryDownload () { 63 | if curl -LSs "${downloadUrl}/${dmgName}" -o "${tmpDir}/${dmgName}"; then 64 | echo "Download successful" 65 | tryDownloadState=1 66 | else 67 | echo "Download unsuccessful" 68 | tryDownloadCounter=$((tryDownloadCounter+1)) 69 | fi 70 | } 71 | 72 | verifyChecksum () { 73 | if [[ $(shasum -a 256 "${tmpDir}/${dmgName}" | awk '{print $1}') == "${checksum}" ]]; then 74 | echo "Checksum verified" 75 | else 76 | echo "Checksum verification failed" 77 | echo "Failed checksum is $(shasum -a 256 "${tmpDir}/${dmgName}" | awk '{print $1}')" 78 | cleanup 79 | exit 1 80 | fi 81 | } 82 | 83 | versionCheck () { 84 | if [[ -d "${appPath}" ]]; then 85 | echo "${appName} version is $(defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString)" 86 | versionCheckStatus=1 87 | else 88 | echo "${appName} not installed" 89 | versionCheckStatus=0 90 | fi 91 | } 92 | 93 | # Start 94 | 95 | # List version 96 | versionCheck 97 | 98 | # Make sure volume is not already mounted and unmount if needed 99 | if [[ -d "${dmgVolumePath}" ]]; then 100 | echo "${dmgVolumePath} already in use. Attempting to unmount" 101 | hdiutil detach "${dmgVolumePath}" 102 | fi 103 | 104 | # Download dmg file into tmp dir (60 second timeout) 105 | tryDownloadState=0 106 | tryDownloadCounter=0 107 | while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do 108 | processCheck 109 | createTmpDir 110 | tryDownload 111 | sleep 1 112 | done 113 | 114 | # Check for successful download 115 | if [[ ! -f "${tmpDir}/${dmgName}" ]]; then 116 | echo "Download unsuccessful" 117 | cleanup 118 | exit 1 119 | fi 120 | 121 | # Verify SHA256 checksum 122 | verifyChecksum 123 | 124 | # Mount dmg file 125 | if hdiutil attach "${tmpDir}/${dmgName}" -nobrowse -quiet; then 126 | echo "Mounted DMG" 127 | else 128 | echo "Failed to mount DMG" 129 | cleanup 130 | exit 1 131 | fi 132 | 133 | # Check for expected dmg path 134 | if [[ ! -d "${dmgVolumePath}" ]]; then 135 | echo "Could not locate ${dmgVolumePath}" 136 | cleanup 137 | exit 1 138 | fi 139 | 140 | # Remove app if already installed 141 | if [[ -d "${appPath}" ]]; then 142 | if rm -R "${appPath}"; then 143 | echo "Removed existing ${appName} from /Applications directory" 144 | else 145 | echo "Failed to remove existing ${appName} from /Applications directory" 146 | cleanup 147 | exit 1 148 | fi 149 | fi 150 | 151 | # Copy application to /Applications 152 | if cp -R "${dmgVolumePath}/${appName}" /Applications/; then 153 | echo "Copied ${appName} to /Applications directory" 154 | else 155 | echo "Failed to copy ${appName} to /Applications directory" 156 | fi 157 | 158 | # Remove tmp dir and downloaded dmg file 159 | cleanup 160 | 161 | # List version and exit with error code if not found 162 | versionCheck 163 | if [[ ${versionCheckStatus} -eq 0 ]]; then 164 | exit 1 165 | fi 166 | -------------------------------------------------------------------------------- /Install_Zoom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | # Automatically download and install the latest zoom.us 4 | 5 | # Variables 6 | appName="zoom.us.app" 7 | appPath="/Applications/${appName}" 8 | appProcessName="zoom.us" 9 | downloadUrl="https://zoom.us/client/latest" 10 | pkgName="ZoomInstallerIT.pkg" 11 | 12 | cleanup () { 13 | if [[ -f "${tmpDir}/${pkgName}" ]]; then 14 | if rm -f "${tmpDir}/${pkgName}"; then 15 | echo "Removed file ${tmpDir}/${pkgName}" 16 | fi 17 | fi 18 | if [[ -d "${tmpDir}" ]]; then 19 | if rm -R "${tmpDir}"; then 20 | echo "Removed directory ${tmpDir}" 21 | fi 22 | fi 23 | } 24 | 25 | createTmpDir () { 26 | if [ -z ${tmpDir+x} ]; then 27 | tmpDir=$(mktemp -d) 28 | echo "Temp dir set to ${tmpDir}" 29 | fi 30 | } 31 | 32 | processCheck () { 33 | if pgrep -x "${appProcessName}" > /dev/null; then 34 | echo "${appProcessName} is currently running" 35 | echo "Aborting install" 36 | cleanup 37 | exit 0 38 | else 39 | echo "${appProcessName} not currently running" 40 | fi 41 | } 42 | 43 | tryDownload () { 44 | if curl -LSs "${downloadUrl}/${pkgName}" -o "${tmpDir}/${pkgName}"; then 45 | echo "Download successful" 46 | tryDownloadState=1 47 | else 48 | echo "Download unsuccessful" 49 | tryDownloadCounter=$((tryDownloadCounter+1)) 50 | fi 51 | } 52 | 53 | versionCheck () { 54 | if [[ -d "${appPath}" ]]; then 55 | echo "${appName} version is $(defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString)" 56 | versionCheckStatus=1 57 | else 58 | echo "${appName} not installed" 59 | versionCheckStatus=0 60 | fi 61 | } 62 | 63 | # Start 64 | 65 | # List version 66 | versionCheck 67 | 68 | # Download PKG file into ${tmpDir} (60 second timeout) 69 | tryDownloadState=0 70 | tryDownloadCounter=0 71 | while [[ ${tryDownloadState} -eq 0 && ${tryDownloadCounter} -le 60 ]]; do 72 | processCheck 73 | createTmpDir 74 | tryDownload 75 | sleep 1 76 | done 77 | 78 | # Check for successful download 79 | if [[ ! -f "${tmpDir}/${pkgName}" ]]; then 80 | echo "Download unsuccessful" 81 | cleanup 82 | exit 1 83 | fi 84 | 85 | # Install package 86 | echo "Starting install" 87 | installer -pkg "${tmpDir}/${pkgName}" -target / 88 | 89 | # Remove tmp dir and downloaded pkg file 90 | cleanup 91 | 92 | # List version and exit with error code if not found 93 | versionCheck 94 | if [[ ${versionCheckStatus} -eq 0 ]]; then 95 | exit 1 96 | fi 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Jamf Pro scripts 2 | --------------------------------------------------------------------------------