From f65010ecb4ad8e70f8fe775979bfe5b20fcf7feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 8 Sep 2021 20:11:36 +0200 Subject: [PATCH 1/4] App from App Store In this branch I demand that INSTALL=force if an App Store app should be replaced. Best example is Slack that will loose all settings if it is replaced. But we can still do it and the log will show what we are doing. --- fragments/functions.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fragments/functions.sh b/fragments/functions.sh index 58da2df..5f7c866 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -173,6 +173,17 @@ 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" + # Is current app from App Store + if [[ -d "$installedAppPath"/Contents/_MASReceipt ]];then + printlog "Installed $appName is from App Store, use INSTALL=force to replace." + # INSTALL="force" + # Maybe we should exit instead + if [[ $INSTALL == "force" ]]; then + printlog "Force is used so continuing" + else + cleanupAndExit 1 "App previously installed from App Store" + fi + fi else printlog "could not determine location of $appName" fi From 0c0977e61f9ca313c9b7d2814b7fb90af9484e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Thu, 9 Sep 2021 17:26:28 +0200 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1dfcca..0bb5250 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v0.7 - pre-release - script is now assembled from fragments. This helps avoid merging conflicts on git and allows the core team to work on the script logic while also accepting new labels. See the "Assemble Script ReadMe" for details. +- We now detect App Store installed apps, and we do not replace them automatically. An example is Slack that will loose all settings if it is suddenly changed from App Store version to the "web" version (they differ in the handling of settings files). If `INSTALL=force` then we will replace the App Store app. We log all this. - Change in finding installed apps. We now look in /Applications and /Applications/Utilities first. If not found there, we use spotligt to find it. (We discovered a problem when a user has Parallels Windows installed with Microsoft Edge in it. Then Installomator wanted to update the app all the time, becaus spotligt found that Windows version of the app that Parallels created.) - Added bunch of new labels - Renamed `buildCaseStatement.sh` to `buildLabel.sh` and improved it a lot. It is a great start when figuring out how to create a new label for an app, or a piece of software. From 2b0cb9dbc0bf91c72bbe84b8fc6f1caa4a7846dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Fri, 17 Sep 2021 22:40:35 +0200 Subject: [PATCH 3/4] IGNORE_APP_STORE_APPS --- fragments/functions.sh | 11 +++++------ fragments/header.sh | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 5f7c866..ebf6e58 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -175,13 +175,12 @@ getAppVersion() { printlog "found app at $installedAppPath, version $appversion" # Is current app from App Store if [[ -d "$installedAppPath"/Contents/_MASReceipt ]];then - printlog "Installed $appName is from App Store, use INSTALL=force to replace." - # INSTALL="force" - # Maybe we should exit instead - if [[ $INSTALL == "force" ]]; then - printlog "Force is used so continuing" + printlog "Installed $appName is from App Store, use “IGNORE_APP_STORE_APPS=yes” to replace." + if [[ $IGNORE_APP_STORE_APPS == "yes" ]]; then + printlog "Replacing App Store apps, no matter the version" + appversion=0 else - cleanupAndExit 1 "App previously installed from App Store" + cleanupAndExit 1 "App previously installed from App Store, and we respect that" fi fi else diff --git a/fragments/header.sh b/fragments/header.sh index 04a2ed1..e17f539 100644 --- a/fragments/header.sh +++ b/fragments/header.sh @@ -68,7 +68,20 @@ LOGO=appstore # - mosyleb Mosyle Business # - mosylem Mosyle Manager (Education) # - addigy Addigy -# path can also be set in the command call, and if file exists, it will be used, like 'LOGO="/System/Applications/App\ Store.app/Contents/Resources/AppIcon.icns"' (spaces are escaped). +# path can also be set in the command call, and if file exists, it will be used. +# Like 'LOGO="/System/Applications/App\ Store.app/Contents/Resources/AppIcon.icns"' +# (spaces have to be escaped). + + +# App Store apps handling +IGNORE_APP_STORE_APPS=no +# options: +# - no If installed app is from App Store (which include VPP installed apps) +# it will not be touched, no matter it's version (default) +# - yes Replace App Store (and VPP) version of app and handle future +# updates using Installomator, even if latest version. +# Shouldn’t give any problems for the user in most cases. +# Known bad example: Slack will loose all settings. # install behavior From bc046cfc07d9dfee77bd5d22c0f9b265946749be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Fri, 17 Sep 2021 22:52:24 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 8bb2b17..3c63a89 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,12 @@ The `LOGO` variable is used for the icon shown in dialog boxes. There are these - `addigy`: Addigy Path can also be set in the command call, and if file exists, it will be used, like `LOGO="/System/Applications/App\ Store.app/Contents/Resources/AppIcon.icns"` (spaces are escaped). +### App Store apps handling +Default is `IGNORE_APP_STORE_APPS=no` +__options:__ +- `no`: If installed app is from App Store (which include VPP installed apps) it will not be touched, no matter it's version (default) +- `yes`: Replace App Store (and VPP) version of app and handle future updates using Installomator, even if latest version. Shouldn’t give any problems for the user in most cases. Known bad example: Slack will loose all settings. + ### Install behavior (force installation) Since we now make a version checking, and only installs the software if the version is different, an `INSTALL` variable can be used to force the installation: