From 0432eb62d3581bf43f4d3dbfdd164d627f3bb2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Tue, 8 Feb 2022 12:36:16 +0100 Subject: [PATCH 01/18] Improved logging levels Also fixes #340 --- CHANGELOG.md | 1 + fragments/arguments.sh | 18 +++++++++--------- fragments/functions.sh | 26 ++++++++++++++------------ fragments/main.sh | 35 ++++++++++++++++------------------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fd54d4..681e39c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## v10 +- Changed and improved logging levels on many messages throughout the script. Should be more polished. - ## v9 diff --git a/fragments/arguments.sh b/fragments/arguments.sh index 45a933c..c669ee1 100644 --- a/fragments/arguments.sh +++ b/fragments/arguments.sh @@ -10,21 +10,21 @@ fi # MARK: argument parsing if [[ $# -eq 0 ]]; then if [[ -z $label ]]; then # check if label is set inside script - printlog "no label provided, printing labels" + printlog "no label provided, printing labels" REQ grep -E '^[a-z0-9\_-]*(\)|\|\\)$' "$0" | tr -d ')|\' | grep -v -E '^(broken.*|longversion|version|valuesfromarguments)$' | sort #grep -E '^[a-z0-9\_-]*(\)|\|\\)$' "${labelFile}" | tr -d ')|\' | grep -v -E '^(broken.*|longversion|version|valuesfromarguments)$' | sort exit 0 fi elif [[ $1 == "/" ]]; then # jamf uses sends '/' as the first argument - printlog "shifting arguments for Jamf" + printlog "shifting arguments for Jamf" REQ shift 3 fi while [[ -n $1 ]]; do if [[ $1 =~ ".*\=.*" ]]; then # if an argument contains an = character, send it to eval - printlog "setting variable from argument $1" + printlog "setting variable from argument $1" REQ eval $1 else # assume it's a label @@ -96,31 +96,31 @@ currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ { print # MARK: check for root if [[ "$(whoami)" != "root" && "$DEBUG" -eq 0 ]]; then # not running as root - cleanupAndExit 6 "not running as root, exiting" + cleanupAndExit 6 "not running as root, exiting" ERROR fi # MARK: labels in case statement case $label in longversion) # print the script version - printlog "Installomater: version $VERSION ($VERSIONDATE)" + printlog "Installomater: version $VERSION ($VERSIONDATE)" REQ exit 0 ;; valuesfromarguments) if [[ -z $name ]]; then - printlog "need to provide 'name'" + printlog "need to provide 'name'" ERROR exit 1 fi if [[ -z $type ]]; then - printlog "need to provide 'type'" + printlog "need to provide 'type'" ERROR exit 1 fi if [[ -z $downloadURL ]]; then - printlog "need to provide 'downloadURL'" + printlog "need to provide 'downloadURL'" ERROR exit 1 fi if [[ -z $expectedTeamID ]]; then - printlog "need to provide 'expectedTeamID'" + printlog "need to provide 'expectedTeamID'" ERROR exit 1 fi ;; diff --git a/fragments/functions.sh b/fragments/functions.sh index a851077..7e542ea 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -176,7 +176,7 @@ versionFromGit() { appNewVersion=$(curl --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | grep tag_name | cut -d '"' -f 4 | sed 's/[^0-9\.]//g') if [ -z "$appNewVersion" ]; then - printlog "could not retrieve version number for $gitusername/$gitreponame" + printlog "could not retrieve version number for $gitusername/$gitreponame" WARN appNewVersion="" else echo "$appNewVersion" @@ -229,9 +229,9 @@ getAppVersion() { applist=$(mdfind "kind:application $appName" -0 ) fi if [[ -z applist ]]; then - printlog "No previous app found" DEBUG + printlog "No previous app found" INFO else - printlog "App(s) found: ${applist}" DEBUG + printlog "App(s) found: ${applist}" INFO fi appPathArray=( ${(0)applist} ) @@ -255,10 +255,10 @@ getAppVersion() { fi fi else - printlog "could not determine location of $appName" + printlog "could not determine location of $appName" WARN fi else - printlog "could not find $appName" + printlog "could not find $appName" WARN fi } @@ -385,7 +385,7 @@ reopenClosedProcess() { processuser=$(ps aux | grep -i "${appName}" | grep -vi "grep" | awk '{print $1}') printlog "Reopened ${appName} as $processuser" else - printlog "App not closed, so no reopen." DEBUG + printlog "App not closed, so no reopen." INFO fi } @@ -395,7 +395,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir # check if app exists if [ ! -e "$appPath" ]; then - cleanupAndExit 8 "could not find: $appPath" DEBUG + cleanupAndExit 8 "could not find: $appPath" ERROR fi # verify with spctl @@ -427,10 +427,12 @@ installAppWithPath() { # $1: path to app to install in $targetDir printlog "notifying" displaynotification "$message" "No update for $name!" fi - cleanupAndExit 0 "No new version to install" INFO + cleanupAndExit 0 "No new version to install" WARN else printlog "Using force to install anyway." fi + elif [[ -z $appversion ]]; then + printlog "Installing $name version $appNewVersion on versionKey $versionKey." else printlog "Downloaded version of $name is $appNewVersion on versionKey $versionKey (replacing version $appversion)." fi @@ -446,7 +448,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir printlog "notifying" displaynotification "$message" "Error updating $name!" fi - cleanupAndExit 6 "Installed macOS is too old for this app." INFO + cleanupAndExit 6 "Installed macOS is too old for this app." ERROR fi fi @@ -585,7 +587,7 @@ installFromPKG() { printlog "notifying" displaynotification "$message" "No update for $name!" fi - cleanupAndExit 0 "No new version to install" INFO + cleanupAndExit 0 "No new version to install" WARN else printlog "Using force to install anyway." fi @@ -770,13 +772,13 @@ runUpdateTool() { printlog "Error running $updateTool, Procceding with normal installation. Exit Status: $updateStatus Error:\n$logoutput" WARN return 1 if [[ $type == updateronly ]]; then - cleanupAndExit 77 "No Download URL Set, this is an update only application and the updater failed" WARN + cleanupAndExit 77 "No Download URL Set, this is an update only application and the updater failed" ERROR fi elif [[ $updateStatus -eq 0 ]]; then printlog "Debugging enabled, update tool output was:\n$logoutput" DEBUG fi else - printlog "couldn't find $updateTool, continuing normally" + printlog "couldn't find $updateTool, continuing normally" WARN return 1 fi return 0 diff --git a/fragments/main.sh b/fragments/main.sh index 1de095f..a508d52 100644 --- a/fragments/main.sh +++ b/fragments/main.sh @@ -1,13 +1,13 @@ *) # unknown label #printlog "unknown label $label" - cleanupAndExit 1 "unknown label $label" + cleanupAndExit 1 "unknown label $label" ERROR ;; esac # Are we only asked to return label name if [[ $RETURN_LABEL_NAME -eq 1 ]]; then - printlog "Only returning label name." + printlog "Only returning label name." REQ printlog "$name" echo "$name" exit @@ -18,7 +18,7 @@ fi if [[ ${INTERRUPT_DND} = "no" ]]; then # Check if a fullscreen app is active if hasDisplaySleepAssertion; then - cleanupAndExit 1 "active display sleep assertion detected, aborting" + cleanupAndExit 1 "active display sleep assertion detected, aborting" ERROR fi fi @@ -63,9 +63,9 @@ if [[ ! -a "${LOGO}" ]]; then LOGO="/Applications/App Store.app/Contents/Resources/AppIcon.icns" fi fi -printlog "LOGO=${LOGO}" +printlog "LOGO=${LOGO}" INFO -printlog "Label type: $type" +printlog "Label type: $type" INFO # MARK: extract info from data if [ -z "$archiveName" ]; then @@ -87,7 +87,7 @@ if [ -z "$archiveName" ]; then ;; esac fi -printlog "archiveName: $archiveName" DEBUG +printlog "archiveName: $archiveName" INFO if [ -z "$appName" ]; then # when not given derive from name @@ -105,14 +105,13 @@ if [ -z "$targetDir" ]; then updateronly) ;; *) - printlog "Cannot handle type $type" - cleanupAndExit 99 + cleanupAndExit 99 "Cannot handle type $type" ERROR ;; esac fi if [[ -z $blockingProcesses ]]; then - printlog "no blocking processes defined, using $name as default" + printlog "no blocking processes defined, using $name as default" INFO blockingProcesses=( $name ) fi @@ -128,8 +127,7 @@ fi # MARK: change directory to temporary working directory printlog "Changing directory to $tmpDir" DEBUG if ! cd "$tmpDir"; then - printlog "error changing directory $tmpDir" - cleanupAndExit 1 + cleanupAndExit 1 "error changing directory $tmpDir" ERROR fi # MARK: get installed version @@ -152,10 +150,10 @@ if [[ -n $appNewVersion ]]; then printlog "notifying" displaynotification "$message" "No update for $name!" fi - cleanupAndExit 0 "No newer version." + cleanupAndExit 0 "No newer version." WARN fi else - printlog "DEBUG mode 1 enabled, not exiting, but there is no new version of app." + printlog "DEBUG mode 1 enabled, not exiting, but there is no new version of app." WARN fi fi else @@ -174,7 +172,7 @@ if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then cleanupAndExit 0 fi # otherwise continue else - printlog "DEBUG mode 1 enabled, not running update tool" + printlog "DEBUG mode 1 enabled, not running update tool" WARN fi fi @@ -197,14 +195,14 @@ else deduplicatelogs "$curlDownload" if [[ $curlDownloadStatus -ne 0 ]]; then #if ! curl --location --fail --silent "$downloadURL" -o "$archiveName"; then - printlog "error downloading $downloadURL" + printlog "error downloading $downloadURL" ERROR message="$name update/installation failed. This will be logged, so IT can follow up." if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then printlog "notifying" if [[ $updateDetected == "YES" ]]; then - displaynotification "$message" "Error updating $name" ERROR + displaynotification "$message" "Error updating $name" else - displaynotification "$message" "Error installing $name" ERROR + displaynotification "$message" "Error installing $name" fi fi printlog "File list: $(ls -lh "$archiveName")" ERROR @@ -269,8 +267,7 @@ case $type in installAppInDmgInZip ;; *) - printlog "Cannot handle type $type" - cleanupAndExit 99 + cleanupAndExit 99 "Cannot handle type $type" ERROR ;; esac From 557d63a4f39fe4af46c819b804a9f783e6a92fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Tue, 8 Feb 2022 13:48:33 +0100 Subject: [PATCH 02/18] If we exit a `0` we should still get the exit message --- fragments/functions.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fragments/functions.sh b/fragments/functions.sh index 7e542ea..26acf46 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -18,6 +18,8 @@ cleanupAndExit() { # $1 = exit code, $2 message, $3 level reopenClosedProcess if [[ -n $2 && $1 -ne 0 ]]; then printlog "ERROR: $2" $3 + else + printlog "$2" $3 fi printlog "################## End Installomator, exit code $1 \n\n" REQ From c55cc788bba09ca3d0070ca66303c973379a3b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 09:21:46 +0100 Subject: [PATCH 03/18] Update functions.sh --- fragments/functions.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index a851077..54e427b 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -220,13 +220,21 @@ getAppVersion() { fi fi - # get app in /Applications, or /Applications/Utilities, or find using Spotlight - if [[ -d "/Applications/$appName" ]]; then + # get app in targetDir, /Applications, or /Applications/Utilities + if [[ -d "$targetDir/$appName" ]]; then + applist="$targetDir/$appName" + elif [[ -d "/Applications/$appName" ]]; then applist="/Applications/$appName" + if [[ $type =~ '^(dmg|zip|tbz|app.*)$']]; then + targetDir="/Applications" + fi elif [[ -d "/Applications/Utilities/$appName" ]]; then applist="/Applications/Utilities/$appName" - else - applist=$(mdfind "kind:application $appName" -0 ) + if [[ $type =~ '^(dmg|zip|tbz|app.*)$']]; then + targetDir="/Applications/Utilities" + fi + #else + # applist=$(mdfind "kind:application $appName" -0 ) fi if [[ -z applist ]]; then printlog "No previous app found" DEBUG From dd83f6bd75bcb17eb6520b63043d93f597432581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 09:41:03 +0100 Subject: [PATCH 04/18] Update functions.sh --- fragments/functions.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fragments/functions.sh b/fragments/functions.sh index 54e427b..38ac3d3 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -241,6 +241,9 @@ getAppVersion() { else printlog "App(s) found: ${applist}" DEBUG fi + if [[ $type =~ '^(dmg|zip|tbz|app.*)$']]; then + printlog "targetDir for installation: $targetDir" INFO + fi appPathArray=( ${(0)applist} ) From c3714d855c6dd6bdce63167d7a1dd7e78bceedf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 09:46:24 +0100 Subject: [PATCH 05/18] Missing spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After manually moving Firefox to Utilities I have tested with this: ``` $ sudo /Installomator/utils/assemble.sh firefox DEBUG=0 INSTALL=force 2022-02-09 09:44:04 : INFO : firefox : setting variable from argument DEBUG=0 2022-02-09 09:44:04 : INFO : firefox : setting variable from argument INSTALL=force 2022-02-09 09:44:04 : REQ : firefox : ################## Start Installomator v. 9.1beta, date 2022-02-09 2022-02-09 09:44:04 : INFO : firefox : ################## Version: 9.1beta 2022-02-09 09:44:04 : INFO : firefox : ################## Date: 2022-02-09 2022-02-09 09:44:04 : INFO : firefox : ################## firefox 2022-02-09 09:44:04 : INFO : firefox : BLOCKING_PROCESS_ACTION=tell_user 2022-02-09 09:44:04 : INFO : firefox : NOTIFY=success 2022-02-09 09:44:04 : INFO : firefox : LOGGING=INFO 2022-02-09 09:44:04 : INFO : firefox : LOGO=/System/Applications/App Store.app/Contents/Resources/AppIcon.icns 2022-02-09 09:44:04 : INFO : firefox : Label type: dmg 2022-02-09 09:44:04 : INFO : firefox : targetDir for installation: /Applications/Utilities 2022-02-09 09:44:04 : INFO : firefox : found app at /Applications/Utilities/Firefox.app, version 97.0, on versionKey CFBundleShortVersionString 2022-02-09 09:44:04 : INFO : firefox : appversion: 97.0 2022-02-09 09:44:04 : INFO : firefox : Label is not of type “updateronly”, and it’s set to use force to install or ignoring app store apps, so not using updateTool. 2022-02-09 09:44:04 : INFO : firefox : Latest version of Firefox is 97.0 2022-02-09 09:44:04 : INFO : firefox : There is no newer version available. 2022-02-09 09:44:04 : REQ : firefox : Downloading https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US to Firefox.dmg 2022-02-09 09:44:16 : REQ : firefox : no more blocking processes, continue with update 2022-02-09 09:44:16 : REQ : firefox : Installing Firefox 2022-02-09 09:44:16 : INFO : firefox : Mounting /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tmp.NMItuUfS/Firefox.dmg 2022-02-09 09:44:24 : INFO : firefox : Mounted: /Volumes/Firefox 2022-02-09 09:44:24 : INFO : firefox : Verifying: /Volumes/Firefox/Firefox.app 2022-02-09 09:44:33 : INFO : firefox : Team ID matching: 43AQ936H96 (expected: 43AQ936H96 ) 2022-02-09 09:44:33 : INFO : firefox : Downloaded version of Firefox is 97.0 on versionKey CFBundleShortVersionString, same as installed. 2022-02-09 09:44:33 : INFO : firefox : Using force to install anyway. 2022-02-09 09:44:33 : INFO : firefox : App has LSMinimumSystemVersion: 10.12.0 2022-02-09 09:44:33 : INFO : firefox : Copy /Volumes/Firefox/Firefox.app to /Applications/Utilities 2022-02-09 09:44:40 : INFO : firefox : Changing owner to st 2022-02-09 09:44:40 : INFO : firefox : Finishing... 2022-02-09 09:44:50 : INFO : firefox : targetDir for installation: /Applications/Utilities 2022-02-09 09:44:50 : INFO : firefox : found app at /Applications/Utilities/Firefox.app, version 97.0, on versionKey CFBundleShortVersionString 2022-02-09 09:44:50 : INFO : firefox : Installed Firefox, version 97.0 2022-02-09 09:44:50 : INFO : firefox : notifying 2022-02-09 09:44:50 : REQ : firefox : ################## End Installomator, exit code 0 ``` --- fragments/functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 38ac3d3..25b53a5 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -225,12 +225,12 @@ getAppVersion() { applist="$targetDir/$appName" elif [[ -d "/Applications/$appName" ]]; then applist="/Applications/$appName" - if [[ $type =~ '^(dmg|zip|tbz|app.*)$']]; then + if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then targetDir="/Applications" fi elif [[ -d "/Applications/Utilities/$appName" ]]; then applist="/Applications/Utilities/$appName" - if [[ $type =~ '^(dmg|zip|tbz|app.*)$']]; then + if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then targetDir="/Applications/Utilities" fi #else @@ -241,7 +241,7 @@ getAppVersion() { else printlog "App(s) found: ${applist}" DEBUG fi - if [[ $type =~ '^(dmg|zip|tbz|app.*)$']]; then + if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then printlog "targetDir for installation: $targetDir" INFO fi From b30d4da703f496dd6e8d6dd1a8f896822f7e6a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 14:04:23 +0100 Subject: [PATCH 06/18] Update functions.sh --- fragments/functions.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 25b53a5..419275d 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -225,25 +225,29 @@ getAppVersion() { applist="$targetDir/$appName" elif [[ -d "/Applications/$appName" ]]; then applist="/Applications/$appName" - if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then - targetDir="/Applications" - fi +# if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then +# targetDir="/Applications" +# fi elif [[ -d "/Applications/Utilities/$appName" ]]; then applist="/Applications/Utilities/$appName" - if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then - targetDir="/Applications/Utilities" - fi - #else +# if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then +# targetDir="/Applications/Utilities" +# fi + else # applist=$(mdfind "kind:application $appName" -0 ) + printlog "name: $name, appName: $appName" + applist=$(mdfind "kind:application AND name:$name" -0 ) +# printlog "App(s) found: ${applist}" DEBUG +# applist=$(mdfind "kind:application AND name:$appName" -0 ) fi if [[ -z applist ]]; then printlog "No previous app found" DEBUG else printlog "App(s) found: ${applist}" DEBUG fi - if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then - printlog "targetDir for installation: $targetDir" INFO - fi +# if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then +# printlog "targetDir for installation: $targetDir" INFO +# fi appPathArray=( ${(0)applist} ) From 1da37a13cac1f3834893cabcd41c5a483083fa64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 14:10:01 +0100 Subject: [PATCH 07/18] Another `ls` that could return an error --- fragments/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 26acf46..9e897b2 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -670,7 +670,7 @@ installPkgInDmg() { archiveName="${filearray[1]}" printlog "found pkg: $archiveName" else - if ls "$tmpDir/$pkgName" ; then + if [[ -s "$tmpDir/$pkgName" ]] ; then archiveName="$tmpDir/$pkgName" else # try searching for pkg From bf740d1ffe99b1e94377a3360623970a9706069a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 14:23:32 +0100 Subject: [PATCH 08/18] Update functions.sh --- fragments/functions.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 9e897b2..4423463 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -668,23 +668,22 @@ installPkgInDmg() { cleanupAndExit 20 "couldn't find pkg in dmg $archiveName" ERROR fi archiveName="${filearray[1]}" - printlog "found pkg: $archiveName" else if [[ -s "$tmpDir/$pkgName" ]] ; then archiveName="$tmpDir/$pkgName" else # try searching for pkg - findfiles=$(find "$tmpDir" -iname "$pkgName") + findfiles=$(find "$dmgmount" -iname "$pkgName") # was: $tmpDir filearray=( ${(f)findfiles} ) if [[ ${#filearray} -eq 0 ]]; then - cleanupAndExit 20 "couldn't find pkg “$pkgName” in zip $archiveName" ERROR + cleanupAndExit 20 "couldn't find pkg “$pkgName” in dmg $archiveName" ERROR fi # it is now safe to overwrite archiveName for installFromPKG archiveName="${filearray[1]}" - printlog "found pkg: $archiveName" fi fi - + printlog "found pkg: $archiveName" + # installFromPkgs installFromPKG } From ff8a9c2c3a6365984c35b2d894ed444b76609982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 14:38:58 +0100 Subject: [PATCH 09/18] Few more DEBUG loggings --- fragments/functions.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 4423463..3b0df4a 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -663,17 +663,19 @@ installPkgInDmg() { if [[ -z $pkgName ]]; then # find first file ending with 'pkg' findfiles=$(find "$dmgmount" -iname "*.pkg" -type f -maxdepth 1 ) + printlog "Found pkg(s):\n$findfiles" DEBUG filearray=( ${(f)findfiles} ) if [[ ${#filearray} -eq 0 ]]; then cleanupAndExit 20 "couldn't find pkg in dmg $archiveName" ERROR fi archiveName="${filearray[1]}" else - if [[ -s "$tmpDir/$pkgName" ]] ; then + if [[ -s "$dmgmount/$pkgName" ]] ; then # was: $tmpDir archiveName="$tmpDir/$pkgName" else # try searching for pkg findfiles=$(find "$dmgmount" -iname "$pkgName") # was: $tmpDir + printlog "Found pkg(s):\n$findfiles" DEBUG filearray=( ${(f)findfiles} ) if [[ ${#filearray} -eq 0 ]]; then cleanupAndExit 20 "couldn't find pkg “$pkgName” in dmg $archiveName" ERROR @@ -697,6 +699,7 @@ installPkgInZip() { if [[ -z $pkgName ]]; then # find first file ending with 'pkg' findfiles=$(find "$tmpDir" -iname "*.pkg" -type f -maxdepth 2 ) + printlog "Found pkg(s):\n$findfiles" DEBUG filearray=( ${(f)findfiles} ) if [[ ${#filearray} -eq 0 ]]; then cleanupAndExit 20 "couldn't find pkg in zip $archiveName" ERROR From 175f682b431004a94415b95f460a63d43b19d51d Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Wed, 9 Feb 2022 15:41:45 +0100 Subject: [PATCH 10/18] re-enabled packages label --- fragments/{disabled => labels}/packages.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename fragments/{disabled => labels}/packages.sh (100%) diff --git a/fragments/disabled/packages.sh b/fragments/labels/packages.sh similarity index 100% rename from fragments/disabled/packages.sh rename to fragments/labels/packages.sh From 9afdc233f90c1599f30b9bee875a12c066574842 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Wed, 9 Feb 2022 15:49:05 +0100 Subject: [PATCH 11/18] replaced a stray 'tmpdir' --- fragments/functions.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 3b0df4a..6ddaab9 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -22,7 +22,7 @@ cleanupAndExit() { # $1 = exit code, $2 message, $3 level printlog "$2" $3 fi printlog "################## End Installomator, exit code $1 \n\n" REQ - + # if label is wrong and we wanted name of the label, then return ################## if [[ $RETURN_LABEL_NAME -eq 1 ]]; then 1=0 # If only label name should be returned we exit without any errors @@ -99,7 +99,7 @@ printlog(){ curl -s -X POST https://http-intake.logs.datadoghq.com/v1/input -H "Content-Type: text/plain" -H "DD-API-KEY: $datadogAPI" -d "${log_priority} : $mdmURL : Installomator-${label} : ${VERSIONDATE//-/} : $SESSION : ${logmessage}" > /dev/null done <<< "$log_message" fi - + # Extra spaces space_char="" if [[ ${#log_priority} -eq 3 ]]; then @@ -491,7 +491,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir printlog "Changing owner to $currentUser" chown -R "$currentUser" "$targetDir/$appName" else - printlog "No user logged in or SYSTEMOWNER=1, setting owner to root:wheel" + printlog "No user logged in or SYSTEMOWNER=1, setting owner to root:wheel" chown -R root:wheel "$targetDir/$appName" fi @@ -521,7 +521,7 @@ mountDMG() { dmgmountStatus=$(echo $?) dmgmount=$(echo $dmgmountOut | tail -n 1 | cut -c 54- ) deduplicatelogs "$dmgmountOut" - + if [[ $dmgmountStatus -ne 0 ]] ; then #if ! dmgmount=$(echo 'Y'$'\n' | hdiutil attach "$tmpDir/$archiveName" -nobrowse -readonly | tail -n 1 | cut -c 54- ); then cleanupAndExit 3 "Error mounting $tmpDir/$archiveName error:\n$logoutput" ERROR @@ -530,7 +530,7 @@ mountDMG() { cleanupAndExit 3 "Error accessing mountpoint for $tmpDir/$archiveName error:\n$logoutput" ERROR fi printlog "Debugging enabled, dmgmount output was:\n$logoutput" DEBUG - + printlog "Mounted: $dmgmount" INFO } @@ -547,7 +547,7 @@ installFromPKG() { spctlOut=$(spctl -a -vv -t install "$archiveName" 2>&1 ) spctlStatus=$(echo $?) printlog "spctlOut is $spctlOut" DEBUG - + teamID=$(echo $spctlOut | awk -F '(' '/origin=/ {print $2 }' | tr -d '()' ) # Apple signed software has no teamID, grab entire origin instead if [[ -z $teamID ]]; then @@ -555,7 +555,7 @@ installFromPKG() { fi deduplicatelogs "$spctlOut" - + if [[ $spctlStatus -ne 0 ]] ; then #if ! spctlout=$(spctl -a -vv -t install "$archiveName" 2>&1 ); then cleanupAndExit 4 "Error verifying $archiveName error:\n$logoutput" ERROR @@ -671,7 +671,7 @@ installPkgInDmg() { archiveName="${filearray[1]}" else if [[ -s "$dmgmount/$pkgName" ]] ; then # was: $tmpDir - archiveName="$tmpDir/$pkgName" + archiveName="$dmgmount/$pkgName" else # try searching for pkg findfiles=$(find "$dmgmount" -iname "$pkgName") # was: $tmpDir @@ -685,7 +685,7 @@ installPkgInDmg() { fi fi printlog "found pkg: $archiveName" - + # installFromPkgs installFromPKG } From a25c904ba77949f1f29388d1897a6b0077a97abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 9 Feb 2022 16:23:52 +0100 Subject: [PATCH 12/18] Update functions.sh --- fragments/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 3b0df4a..74167b8 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -21,7 +21,7 @@ cleanupAndExit() { # $1 = exit code, $2 message, $3 level else printlog "$2" $3 fi - printlog "################## End Installomator, exit code $1 \n\n" REQ + printlog "################## End Installomator, exit code $1 \n" REQ # if label is wrong and we wanted name of the label, then return ################## if [[ $RETURN_LABEL_NAME -eq 1 ]]; then From 0c12343fbb9597953e7bf9a75efdedb8025d332f Mon Sep 17 00:00:00 2001 From: Fletcher Salesky Date: Fri, 11 Feb 2022 15:08:57 -0800 Subject: [PATCH 13/18] Added support for Loom Apple Silicon version --- fragments/labels/loom.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fragments/labels/loom.sh b/fragments/labels/loom.sh index a1d6190..1ed4266 100644 --- a/fragments/labels/loom.sh +++ b/fragments/labels/loom.sh @@ -2,7 +2,11 @@ loom) # credit: Lance Stephens (@pythoninthegrass on MacAdmins Slack) name="Loom" type="dmg" - downloadURL=https://cdn.loom.com/desktop-packages/$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/url/ && /dmg/ {print $3}' | head -1) + if [[ $(arch) == "arm64" ]]; then + downloadURL=https://cdn.loom.com/desktop-packages/$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/url/ && /arm64/ && /dmg/ {print $3}' | head -1) + elif [[ $(arch) == "i386" ]]; then + downloadURL=https://cdn.loom.com/desktop-packages/$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/url/ && /dmg/ {print $3}' | head -1) + fi appNewVersion=$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/version/ {print $2}' ) expectedTeamID="QGD2ZPXZZG" ;; From 81b02e3932099959de1e7150426564cdc73a570e Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Fri, 18 Feb 2022 17:16:43 +0100 Subject: [PATCH 14/18] updated Installomator.sh --- Installomator.sh | 149 ++++++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 59 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index 59ee5e1..cc42c79 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -301,8 +301,8 @@ if [[ $(/usr/bin/arch) == "arm64" ]]; then rosetta2=no fi fi -VERSION="9.0" -VERSIONDATE="2022-02-08" +VERSION="10.0dev" +VERSIONDATE="2022-02-18" # MARK: Functions @@ -324,8 +324,10 @@ cleanupAndExit() { # $1 = exit code, $2 message, $3 level reopenClosedProcess if [[ -n $2 && $1 -ne 0 ]]; then printlog "ERROR: $2" $3 + else + printlog "$2" $3 fi - printlog "################## End Installomator, exit code $1 \n\n" REQ + printlog "################## End Installomator, exit code $1 \n" REQ # if label is wrong and we wanted name of the label, then return ################## if [[ $RETURN_LABEL_NAME -eq 1 ]]; then @@ -403,7 +405,7 @@ printlog(){ curl -s -X POST https://http-intake.logs.datadoghq.com/v1/input -H "Content-Type: text/plain" -H "DD-API-KEY: $datadogAPI" -d "${log_priority} : $mdmURL : Installomator-${label} : ${VERSIONDATE//-/} : $SESSION : ${logmessage}" > /dev/null done <<< "$log_message" fi - + # Extra spaces space_char="" if [[ ${#log_priority} -eq 3 ]]; then @@ -482,7 +484,7 @@ versionFromGit() { appNewVersion=$(curl --silent --fail "https://api.github.com/repos/$gitusername/$gitreponame/releases/latest" | grep tag_name | cut -d '"' -f 4 | sed 's/[^0-9\.]//g') if [ -z "$appNewVersion" ]; then - printlog "could not retrieve version number for $gitusername/$gitreponame" + printlog "could not retrieve version number for $gitusername/$gitreponame" WARN appNewVersion="" else echo "$appNewVersion" @@ -526,19 +528,34 @@ getAppVersion() { fi fi - # get app in /Applications, or /Applications/Utilities, or find using Spotlight - if [[ -d "/Applications/$appName" ]]; then + # get app in targetDir, /Applications, or /Applications/Utilities + if [[ -d "$targetDir/$appName" ]]; then + applist="$targetDir/$appName" + elif [[ -d "/Applications/$appName" ]]; then applist="/Applications/$appName" +# if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then +# targetDir="/Applications" +# fi elif [[ -d "/Applications/Utilities/$appName" ]]; then applist="/Applications/Utilities/$appName" +# if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then +# targetDir="/Applications/Utilities" +# fi else - applist=$(mdfind "kind:application $appName" -0 ) + # applist=$(mdfind "kind:application $appName" -0 ) + printlog "name: $name, appName: $appName" + applist=$(mdfind "kind:application AND name:$name" -0 ) +# printlog "App(s) found: ${applist}" DEBUG +# applist=$(mdfind "kind:application AND name:$appName" -0 ) fi if [[ -z applist ]]; then - printlog "No previous app found" DEBUG + printlog "No previous app found" INFO else - printlog "App(s) found: ${applist}" DEBUG + printlog "App(s) found: ${applist}" INFO fi +# if [[ $type =~ '^(dmg|zip|tbz|app.*)$' ]]; then +# printlog "targetDir for installation: $targetDir" INFO +# fi appPathArray=( ${(0)applist} ) @@ -561,10 +578,10 @@ getAppVersion() { fi fi else - printlog "could not determine location of $appName" + printlog "could not determine location of $appName" WARN fi else - printlog "could not find $appName" + printlog "could not find $appName" WARN fi } @@ -691,7 +708,7 @@ reopenClosedProcess() { processuser=$(ps aux | grep -i "${appName}" | grep -vi "grep" | awk '{print $1}') printlog "Reopened ${appName} as $processuser" else - printlog "App not closed, so no reopen." DEBUG + printlog "App not closed, so no reopen." INFO fi } @@ -701,7 +718,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir # check if app exists if [ ! -e "$appPath" ]; then - cleanupAndExit 8 "could not find: $appPath" DEBUG + cleanupAndExit 8 "could not find: $appPath" ERROR fi # verify with spctl @@ -733,10 +750,12 @@ installAppWithPath() { # $1: path to app to install in $targetDir printlog "notifying" displaynotification "$message" "No update for $name!" fi - cleanupAndExit 0 "No new version to install" INFO + cleanupAndExit 0 "No new version to install" WARN else printlog "Using force to install anyway." fi + elif [[ -z $appversion ]]; then + printlog "Installing $name version $appNewVersion on versionKey $versionKey." else printlog "Downloaded version of $name is $appNewVersion on versionKey $versionKey (replacing version $appversion)." fi @@ -752,7 +771,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir printlog "notifying" displaynotification "$message" "Error updating $name!" fi - cleanupAndExit 6 "Installed macOS is too old for this app." INFO + cleanupAndExit 6 "Installed macOS is too old for this app." ERROR fi fi @@ -793,7 +812,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir printlog "Changing owner to $currentUser" chown -R "$currentUser" "$targetDir/$appName" else - printlog "No user logged in or SYSTEMOWNER=1, setting owner to root:wheel" + printlog "No user logged in or SYSTEMOWNER=1, setting owner to root:wheel" chown -R root:wheel "$targetDir/$appName" fi @@ -823,7 +842,7 @@ mountDMG() { dmgmountStatus=$(echo $?) dmgmount=$(echo $dmgmountOut | tail -n 1 | cut -c 54- ) deduplicatelogs "$dmgmountOut" - + if [[ $dmgmountStatus -ne 0 ]] ; then #if ! dmgmount=$(echo 'Y'$'\n' | hdiutil attach "$tmpDir/$archiveName" -nobrowse -readonly | tail -n 1 | cut -c 54- ); then cleanupAndExit 3 "Error mounting $tmpDir/$archiveName error:\n$logoutput" ERROR @@ -832,7 +851,7 @@ mountDMG() { cleanupAndExit 3 "Error accessing mountpoint for $tmpDir/$archiveName error:\n$logoutput" ERROR fi printlog "Debugging enabled, dmgmount output was:\n$logoutput" DEBUG - + printlog "Mounted: $dmgmount" INFO } @@ -849,7 +868,7 @@ installFromPKG() { spctlOut=$(spctl -a -vv -t install "$archiveName" 2>&1 ) spctlStatus=$(echo $?) printlog "spctlOut is $spctlOut" DEBUG - + teamID=$(echo $spctlOut | awk -F '(' '/origin=/ {print $2 }' | tr -d '()' ) # Apple signed software has no teamID, grab entire origin instead if [[ -z $teamID ]]; then @@ -857,7 +876,7 @@ installFromPKG() { fi deduplicatelogs "$spctlOut" - + if [[ $spctlStatus -ne 0 ]] ; then #if ! spctlout=$(spctl -a -vv -t install "$archiveName" 2>&1 ); then cleanupAndExit 4 "Error verifying $archiveName error:\n$logoutput" ERROR @@ -891,7 +910,7 @@ installFromPKG() { printlog "notifying" displaynotification "$message" "No update for $name!" fi - cleanupAndExit 0 "No new version to install" INFO + cleanupAndExit 0 "No new version to install" WARN else printlog "Using force to install anyway." fi @@ -965,27 +984,28 @@ installPkgInDmg() { if [[ -z $pkgName ]]; then # find first file ending with 'pkg' findfiles=$(find "$dmgmount" -iname "*.pkg" -type f -maxdepth 1 ) + printlog "Found pkg(s):\n$findfiles" DEBUG filearray=( ${(f)findfiles} ) if [[ ${#filearray} -eq 0 ]]; then cleanupAndExit 20 "couldn't find pkg in dmg $archiveName" ERROR fi archiveName="${filearray[1]}" - printlog "found pkg: $archiveName" else - if ls "$tmpDir/$pkgName" ; then - archiveName="$tmpDir/$pkgName" + if [[ -s "$dmgmount/$pkgName" ]] ; then # was: $tmpDir + archiveName="$dmgmount/$pkgName" else # try searching for pkg - findfiles=$(find "$tmpDir" -iname "$pkgName") + findfiles=$(find "$dmgmount" -iname "$pkgName") # was: $tmpDir + printlog "Found pkg(s):\n$findfiles" DEBUG filearray=( ${(f)findfiles} ) if [[ ${#filearray} -eq 0 ]]; then - cleanupAndExit 20 "couldn't find pkg “$pkgName” in zip $archiveName" ERROR + cleanupAndExit 20 "couldn't find pkg “$pkgName” in dmg $archiveName" ERROR fi # it is now safe to overwrite archiveName for installFromPKG archiveName="${filearray[1]}" - printlog "found pkg: $archiveName" fi fi + printlog "found pkg: $archiveName" # installFromPkgs installFromPKG @@ -1000,6 +1020,7 @@ installPkgInZip() { if [[ -z $pkgName ]]; then # find first file ending with 'pkg' findfiles=$(find "$tmpDir" -iname "*.pkg" -type f -maxdepth 2 ) + printlog "Found pkg(s):\n$findfiles" DEBUG filearray=( ${(f)findfiles} ) if [[ ${#filearray} -eq 0 ]]; then cleanupAndExit 20 "couldn't find pkg in zip $archiveName" ERROR @@ -1076,13 +1097,13 @@ runUpdateTool() { printlog "Error running $updateTool, Procceding with normal installation. Exit Status: $updateStatus Error:\n$logoutput" WARN return 1 if [[ $type == updateronly ]]; then - cleanupAndExit 77 "No Download URL Set, this is an update only application and the updater failed" WARN + cleanupAndExit 77 "No Download URL Set, this is an update only application and the updater failed" ERROR fi elif [[ $updateStatus -eq 0 ]]; then printlog "Debugging enabled, update tool output was:\n$logoutput" DEBUG fi else - printlog "couldn't find $updateTool, continuing normally" + printlog "couldn't find $updateTool, continuing normally" WARN return 1 fi return 0 @@ -1150,21 +1171,21 @@ fi # MARK: argument parsing if [[ $# -eq 0 ]]; then if [[ -z $label ]]; then # check if label is set inside script - printlog "no label provided, printing labels" + printlog "no label provided, printing labels" REQ grep -E '^[a-z0-9\_-]*(\)|\|\\)$' "$0" | tr -d ')|\' | grep -v -E '^(broken.*|longversion|version|valuesfromarguments)$' | sort #grep -E '^[a-z0-9\_-]*(\)|\|\\)$' "${labelFile}" | tr -d ')|\' | grep -v -E '^(broken.*|longversion|version|valuesfromarguments)$' | sort exit 0 fi elif [[ $1 == "/" ]]; then # jamf uses sends '/' as the first argument - printlog "shifting arguments for Jamf" + printlog "shifting arguments for Jamf" REQ shift 3 fi while [[ -n $1 ]]; do if [[ $1 =~ ".*\=.*" ]]; then # if an argument contains an = character, send it to eval - printlog "setting variable from argument $1" + printlog "setting variable from argument $1" REQ eval $1 else # assume it's a label @@ -1236,31 +1257,31 @@ currentUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ { print # MARK: check for root if [[ "$(whoami)" != "root" && "$DEBUG" -eq 0 ]]; then # not running as root - cleanupAndExit 6 "not running as root, exiting" + cleanupAndExit 6 "not running as root, exiting" ERROR fi # MARK: labels in case statement case $label in longversion) # print the script version - printlog "Installomater: version $VERSION ($VERSIONDATE)" + printlog "Installomater: version $VERSION ($VERSIONDATE)" REQ exit 0 ;; valuesfromarguments) if [[ -z $name ]]; then - printlog "need to provide 'name'" + printlog "need to provide 'name'" ERROR exit 1 fi if [[ -z $type ]]; then - printlog "need to provide 'type'" + printlog "need to provide 'type'" ERROR exit 1 fi if [[ -z $downloadURL ]]; then - printlog "need to provide 'downloadURL'" + printlog "need to provide 'downloadURL'" ERROR exit 1 fi if [[ -z $expectedTeamID ]]; then - printlog "need to provide 'expectedTeamID'" + printlog "need to provide 'expectedTeamID'" ERROR exit 1 fi ;; @@ -2795,7 +2816,11 @@ loom) # credit: Lance Stephens (@pythoninthegrass on MacAdmins Slack) name="Loom" type="dmg" - downloadURL=https://cdn.loom.com/desktop-packages/$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/url/ && /dmg/ {print $3}' | head -1) + if [[ $(arch) == "arm64" ]]; then + downloadURL=https://cdn.loom.com/desktop-packages/$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/url/ && /arm64/ && /dmg/ {print $3}' | head -1) + elif [[ $(arch) == "i386" ]]; then + downloadURL=https://cdn.loom.com/desktop-packages/$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/url/ && /dmg/ {print $3}' | head -1) + fi appNewVersion=$(curl -fs https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml | awk '/version/ {print $2}' ) expectedTeamID="QGD2ZPXZZG" ;; @@ -3494,6 +3519,15 @@ pacifist) downloadURL="https://charlessoft.com/cgi-bin/pacifist_download.cgi?type=dmg" expectedTeamID="HRLUCP7QP4" ;; + +packages) + #NOTE: Packages is signed but _not_ notarized, so spctl will reject it + name="Packages" + type="pkgInDmg" + pkgName="Install Packages.pkg" + downloadURL="http://s.sudre.free.fr/Software/files/Packages.dmg" + expectedTeamID="NL5M9E394P" + ;; pandoc) name="Pandoc" type="pkg" @@ -4605,13 +4639,13 @@ zulujdk8) *) # unknown label #printlog "unknown label $label" - cleanupAndExit 1 "unknown label $label" + cleanupAndExit 1 "unknown label $label" ERROR ;; esac # Are we only asked to return label name if [[ $RETURN_LABEL_NAME -eq 1 ]]; then - printlog "Only returning label name." + printlog "Only returning label name." REQ printlog "$name" echo "$name" exit @@ -4622,7 +4656,7 @@ fi if [[ ${INTERRUPT_DND} = "no" ]]; then # Check if a fullscreen app is active if hasDisplaySleepAssertion; then - cleanupAndExit 1 "active display sleep assertion detected, aborting" + cleanupAndExit 1 "active display sleep assertion detected, aborting" ERROR fi fi @@ -4667,9 +4701,9 @@ if [[ ! -a "${LOGO}" ]]; then LOGO="/Applications/App Store.app/Contents/Resources/AppIcon.icns" fi fi -printlog "LOGO=${LOGO}" +printlog "LOGO=${LOGO}" INFO -printlog "Label type: $type" +printlog "Label type: $type" INFO # MARK: extract info from data if [ -z "$archiveName" ]; then @@ -4691,7 +4725,7 @@ if [ -z "$archiveName" ]; then ;; esac fi -printlog "archiveName: $archiveName" DEBUG +printlog "archiveName: $archiveName" INFO if [ -z "$appName" ]; then # when not given derive from name @@ -4709,14 +4743,13 @@ if [ -z "$targetDir" ]; then updateronly) ;; *) - printlog "Cannot handle type $type" - cleanupAndExit 99 + cleanupAndExit 99 "Cannot handle type $type" ERROR ;; esac fi if [[ -z $blockingProcesses ]]; then - printlog "no blocking processes defined, using $name as default" + printlog "no blocking processes defined, using $name as default" INFO blockingProcesses=( $name ) fi @@ -4732,8 +4765,7 @@ fi # MARK: change directory to temporary working directory printlog "Changing directory to $tmpDir" DEBUG if ! cd "$tmpDir"; then - printlog "error changing directory $tmpDir" - cleanupAndExit 1 + cleanupAndExit 1 "error changing directory $tmpDir" ERROR fi # MARK: get installed version @@ -4756,10 +4788,10 @@ if [[ -n $appNewVersion ]]; then printlog "notifying" displaynotification "$message" "No update for $name!" fi - cleanupAndExit 0 "No newer version." + cleanupAndExit 0 "No newer version." WARN fi else - printlog "DEBUG mode 1 enabled, not exiting, but there is no new version of app." + printlog "DEBUG mode 1 enabled, not exiting, but there is no new version of app." WARN fi fi else @@ -4778,7 +4810,7 @@ if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then cleanupAndExit 0 fi # otherwise continue else - printlog "DEBUG mode 1 enabled, not running update tool" + printlog "DEBUG mode 1 enabled, not running update tool" WARN fi fi @@ -4801,14 +4833,14 @@ else deduplicatelogs "$curlDownload" if [[ $curlDownloadStatus -ne 0 ]]; then #if ! curl --location --fail --silent "$downloadURL" -o "$archiveName"; then - printlog "error downloading $downloadURL" + printlog "error downloading $downloadURL" ERROR message="$name update/installation failed. This will be logged, so IT can follow up." if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then printlog "notifying" if [[ $updateDetected == "YES" ]]; then - displaynotification "$message" "Error updating $name" ERROR + displaynotification "$message" "Error updating $name" else - displaynotification "$message" "Error installing $name" ERROR + displaynotification "$message" "Error installing $name" fi fi printlog "File list: $(ls -lh "$archiveName")" ERROR @@ -4873,8 +4905,7 @@ case $type in installAppInDmgInZip ;; *) - printlog "Cannot handle type $type" - cleanupAndExit 99 + cleanupAndExit 99 "Cannot handle type $type" ERROR ;; esac From 24f729d3575461686d124cdeedb00aad2ea49419 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Fri, 18 Feb 2022 17:17:46 +0100 Subject: [PATCH 15/18] updated Labels.txt --- Labels.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Labels.txt b/Labels.txt index 91483c3..c7756c7 100644 --- a/Labels.txt +++ b/Labels.txt @@ -255,6 +255,7 @@ opera ottomatic overflow pacifist +packages pandoc paretosecurity parsec From 22bc0ecbf631be5b62aa6fbf3c795f5403c293c4 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Sun, 20 Feb 2022 12:48:46 +0100 Subject: [PATCH 16/18] updated version --- Installomator.sh | 4 ++-- fragments/version.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Installomator.sh b/Installomator.sh index cc42c79..5b1a880 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -301,8 +301,8 @@ if [[ $(/usr/bin/arch) == "arm64" ]]; then rosetta2=no fi fi -VERSION="10.0dev" -VERSIONDATE="2022-02-18" +VERSION="9.0.1" +VERSIONDATE="2022-02-20" # MARK: Functions diff --git a/fragments/version.sh b/fragments/version.sh index eb3075d..37ad5c8 100644 --- a/fragments/version.sh +++ b/fragments/version.sh @@ -1 +1 @@ -10.0dev +9.0.1 From afbd1e363e33623a648167135d7e7d961e2abaac Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Sun, 20 Feb 2022 12:57:15 +0100 Subject: [PATCH 17/18] updated changelog --- CHANGELOG.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 681e39c..6131c19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ -## v10 +## v9.0.1 -- Changed and improved logging levels on many messages throughout the script. Should be more polished. -- +- improved logging levels throughout the script #408 +- fixed a bug for `pkgindmg` style labels #408 +- changed the criteria used to locate an app in the case the it cannot be found in the default locations, this should help with some apps with similar name (Virtual Box and Box Drive, #401) #413 +- new label: WhiteBox Packages (`packages`) #415 +- modified label: `loom` (added Apple silicon download) #417 ## v9 From a3dbf75818bec8d2f1fdc91d490ec5cf67745308 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Sun, 20 Feb 2022 13:07:53 +0100 Subject: [PATCH 18/18] updated version --- fragments/version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fragments/version.sh b/fragments/version.sh index 37ad5c8..633e31a 100644 --- a/fragments/version.sh +++ b/fragments/version.sh @@ -1 +1 @@ -9.0.1 +9.1beta