From 800c356b0135e5a887c4449101f73b7cb077a813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 10 Nov 2021 15:29:59 +0100 Subject: [PATCH 1/2] updae/installation detection --- fragments/functions.sh | 14 ++++++++++++-- fragments/main.sh | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 446bbd5..4e30ed7 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -148,6 +148,7 @@ getAppVersion() { appversion="$(pkgutil --pkg-info-plist ${packageID} 2>/dev/null | grep -A 1 pkg-version | tail -1 | sed -E 's/.*>([0-9.]*)<.*/\1/g')" if [[ $appversion != "" ]]; then printlog "found packageID $packageID installed, version $appversion" + updateDetected="YES" return else printlog "No version found using packageID $packageID" @@ -162,7 +163,11 @@ getAppVersion() { else applist=$(mdfind "kind:application $appName" -0 ) fi - printlog "App(s) found: ${applist}" + if [[ -z applist ]]; then + printlog "No previous app found" + else + printlog "App(s) found: ${applist}" + fi appPathArray=( ${(0)applist} ) @@ -173,6 +178,7 @@ getAppVersion() { #appversion=$(mdls -name kMDItemVersion -raw $installedAppPath ) appversion=$(defaults read $installedAppPath/Contents/Info.plist $versionKey) #Not dependant on Spotlight indexing printlog "found app at $installedAppPath, version $appversion" + updateDetected="YES" # Is current app from App Store if [[ -d "$installedAppPath"/Contents/_MASReceipt ]];then printlog "Installed $appName is from App Store, use “IGNORE_APP_STORE_APPS=yes” to replace." @@ -612,7 +618,11 @@ finishing() { if [[ $currentUser != "loginwindow" && ( $NOTIFY == "success" || $NOTIFY == "all" ) ]]; then printlog "notifying" - displaynotification "$message" "$name update/installation complete!" + if [[ $updateDetected == "YES" ]]; then + displaynotification "$message" "$name update complete!" + else + displaynotification "$message" "$name installation complete!" + fi fi } diff --git a/fragments/main.sh b/fragments/main.sh index dfba2c9..e7708ee 100644 --- a/fragments/main.sh +++ b/fragments/main.sh @@ -169,14 +169,22 @@ else printlog "Downloading $downloadURL to $archiveName" if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then printlog "notifying" - displaynotification "Downloading $name update" "Download in progress …" + if [[ $updateDetected == "YES" ]]; then + displaynotification "Downloading $name update" "Download in progress …" + else + displaynotification "Downloading new $name" "Download in progress …" + fi fi if ! curl --location --fail --silent "$downloadURL" -o "$archiveName"; then printlog "error downloading $downloadURL" message="$name update/installation failed. This will be logged, so IT can follow up." if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then printlog "notifying" - displaynotification "$message" "Error installing/updating $name" + if [[ $updateDetected == "YES" ]]; then + displaynotification "$message" "Error updating $name" + else + displaynotification "$message" "Error installing $name" + fi fi cleanupAndExit 2 fi @@ -199,7 +207,11 @@ fi printlog "Installing $name" if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then printlog "notifying" - displaynotification "Installing $name" "Installation in progress …" + if [[ $updateDetected == "YES" ]]; then + displaynotification "Updating $name" "Installation in progress …" + else + displaynotification "Installing $name" "Installation in progress …" + fi fi case $type in From 9f34df0b4e5191a13853728523a3406f6d38b989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Thu, 11 Nov 2021 08:46:13 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f2685f..a7d5231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.8 + +- Installomator now detects when an app is already installed, and will display notifications correctly the user based on if the app was updated or installed for the first time. + ## v0.7 - default for `BLOCKING_PROCESS_ACTION`is now `BLOCKING_PROCESS_ACTION=tell_user` and not `prompt_user`. It will demand the user to quit the app to get it updated, and not present any option to skip it. In considering various use cases in different MDM solutions this is the best option going forward. Users usually choose to update, and is most often not bothered much with this information. If it's absoultely a bad time, then they can move the dialog box to the side, and click it when ready.