From 4cee224d176c87a662dff03ddf7316dd5f195a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Tue, 8 Feb 2022 13:46:05 +0100 Subject: [PATCH] Variable `SKIP_UNINSTALLED` introduced Fixes #321. --- CHANGELOG.md | 1 + fragments/functions.sh | 6 +++++- fragments/header.sh | 7 +++++++ fragments/main.sh | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fd54d4..4f79658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## v10 +- Introducing variable `SKIP_UNINSTALLED` that normally will be `0` and the script will run and install the software label if other conditions align with this. Use `SKIP_UNINSTALLED=1` to have the script stop if a current installation of the app is not found. - ## v9 diff --git a/fragments/functions.sh b/fragments/functions.sh index a851077..7c3a87e 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -228,8 +228,12 @@ getAppVersion() { else applist=$(mdfind "kind:application $appName" -0 ) fi - if [[ -z applist ]]; then + if [[ -z $applist ]]; then + if [[ $SKIP_UNINSTALLED -eq 1 ]]; then + cleanupAndExit 0 "No previous app found, and SKIP_UNINSTALLED=1." REQ + else printlog "No previous app found" DEBUG + fi else printlog "App(s) found: ${applist}" DEBUG fi diff --git a/fragments/header.sh b/fragments/header.sh index cc19927..dc71545 100644 --- a/fragments/header.sh +++ b/fragments/header.sh @@ -110,6 +110,13 @@ INSTALL="" # if it is newer/different in version # - force Install even if it’s the same version +# skip if app is not currently installed +SKIP_UNINSTALLED=0 +# options: +# - 0 Run normally and install the app if other conditions are met. +# - 1 If app is not currently installed we will not install anything. +# This is mostly done in the getAppVersion function, and if it cannot +# locate the app, the script will exit. # Re-opening of closed app REOPEN="yes" diff --git a/fragments/main.sh b/fragments/main.sh index 1de095f..053f20e 100644 --- a/fragments/main.sh +++ b/fragments/main.sh @@ -93,6 +93,7 @@ if [ -z "$appName" ]; then # when not given derive from name appName="$name.app" fi +printlog "appName: $appName" INFO if [ -z "$targetDir" ]; then case $type in