From 4fe2c926f4fdfb6d5a3550d52a3739ed902b9ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Mon, 12 Apr 2021 20:16:47 +0200 Subject: [PATCH] v0.5 updateTool now working. Improved log for this, as well as creating a finishing function so that we can call this when updateTool was used. --- CHANGELOG.md | 1 + Installomator.sh | 49 ++++++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9246034..29b7d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - If your MDM cannot call a script with parameters, the label can be set in the top of the script. - If your MDM is not Jamf Pro, and you need the script to be installed locally on your managed machines, then take a look at [Theiles fork](https://github.com/Theile/Installomator/). This fork can be called from the MDM using a small script. - Script `buildCaseStatement.sh` to help with creating labels have been improved. +- Fixed a bug in a variable name that prevented updateTool to be used ## v0.4 - 2020-10-19 diff --git a/Installomator.sh b/Installomator.sh index 6bec37c..9700199 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -693,6 +693,7 @@ installAppInDmgInZip() { } runUpdateTool() { + printlog "Function called: runUpdateTool" if [[ -x $updateTool ]]; then printlog "running $updateTool $updateToolArguments" if [[ -n $updateToolRunAsCurrentUser ]]; then @@ -710,6 +711,25 @@ runUpdateTool() { return 0 } +finishing() { + printlog "Finishing…" + sleep 10 # wait a moment to let spotlight catch up + getAppVersion + + if [[ -z $appversion ]]; then + message="Installed $name" + else + message="Installed $name, version $appversion" + fi + + printlog "$message" + + if [[ $currentUser != "loginwindow" && ( $NOTIFY == "success" || $NOTIFY == "all" ) ]]; then + printlog "notifying" + displaynotification "$message" "$name update/installation complete!" + fi +} + # MARK: check minimal macOS requirement autoload is-at-least @@ -2932,8 +2952,8 @@ microsoftteams) # Still using macadmin.software for version, as the path does not contain the version in a matching format. packageID can be used, but version is the same. expectedTeamID="UBF8T346G9" blockingProcesses=( Teams "Microsoft Teams Helper" ) - #updateTool="/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/MacOS/msupdate" - #updateToolArguments=( --install --apps TEAM01 ) + updateTool="/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/MacOS/msupdate" + updateToolArguments=( --install --apps TEAM01 ) ;; microsoftvisualstudiocode|\ visualstudiocode) @@ -3117,11 +3137,14 @@ if ! cd "$tmpDir"; then cleanupAndExit 1 fi -# MARK: check if this is an Update +# MARK: check if this is an Update and we can use updateTool getAppVersion -if [[ -n $appVersion ]]; then +printlog "appversion: $appversion" +if [[ -n $appversion && -n "$updateTool" ]]; then + printlog "appversion & updateTool" if [[ $DEBUG -eq 0 ]]; then if runUpdateTool; then + finishing cleanupAndExit 0 fi # otherwise continue else @@ -3223,22 +3246,8 @@ case $type in ;; esac -# MARK: print installed application location and version -sleep 10 # wait a moment to let spotlight catch up -getAppVersion - -if [[ -z $appversion ]]; then - message="Installed $name" -else - message="Installed $name, version $appversion" -fi - -printlog "$message" - -if [[ $currentUser != "loginwindow" && ( $NOTIFY == "success" || $NOTIFY == "all" ) ]]; then - printlog "notifying" - displaynotification "$message" "$name update/installation complete!" -fi +# MARK: Finishing — print installed application location and version +finishing # all done! cleanupAndExit 0