CLIInstaller included

and a few other displaylog lines changed
This commit is contained in:
Søren Theilgaard
2022-01-13 09:44:34 +01:00
parent 99b908f646
commit f96cd178c6
4 changed files with 38 additions and 27 deletions

View File

@@ -8,9 +8,15 @@
- Added variable `SYSTEMOWNER` that is used when copying files when installing. Default `0` is to change owner of the app to the current user on the Mac, like this user was installing this app themselves. When using `1` we will put “root:wheel” on the app, which can be useful for shared machines. - Added variable `SYSTEMOWNER` that is used when copying files when installing. Default `0` is to change owner of the app to the current user on the Mac, like this user was installing this app themselves. When using `1` we will put “root:wheel” on the app, which can be useful for shared machines.
Big changes to logging: Big changes to logging:
- Logging levels as DEBUG 0 INFO 1 WARN 2 ERROR 3 REQ 4 - Introducing variable `LOGGING`, that can be either of the logging levels
- Logging levels:
0: DEBUG Everything is logged
1: INFO Normal logging behavior
2: WARN
3: ERROR
4: REQ
- External logging to Datadog - External logging to Datadog
- A function to shorten duplicate lines in installation logs - A function to shorten duplicate lines in installation logs or output of longer commands
- Ability to extract install.log in the time when Installomator was running, if further investigations needs to be done to logs - Ability to extract install.log in the time when Installomator was running, if further investigations needs to be done to logs
## v8.0 ## v8.0

View File

@@ -415,7 +415,7 @@ reopenClosedProcess() {
processuser=$(ps aux | grep -i "${appName}" | grep -vi "grep" | awk '{print $1}') processuser=$(ps aux | grep -i "${appName}" | grep -vi "grep" | awk '{print $1}')
printlog "Reopened ${appName} as $processuser" printlog "Reopened ${appName} as $processuser"
else else
printlog "App not closed, so no reopen." printlog "App not closed, so no reopen." DEBUG
fi fi
} }
@@ -434,12 +434,12 @@ installAppWithPath() { # $1: path to app to install in $targetDir
appVerifyStatus=$(echo $?) appVerifyStatus=$(echo $?)
teamID=$(echo $appVerify | awk '/origin=/ {print $NF }' | tr -d '()' ) teamID=$(echo $appVerify | awk '/origin=/ {print $NF }' | tr -d '()' )
deduplicatelogs "$appVerify" deduplicatelogs "$appVerify"
printlog "Debugging enabled, App Verification output was: $logoutput" DEBUG
if [[ $appVerifyStatus -ne 0 ]] ; then if [[ $appVerifyStatus -ne 0 ]] ; then
#if ! teamID=$(spctl -a -vv "$appPath" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()' ); then #if ! teamID=$(spctl -a -vv "$appPath" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()' ); then
cleanupAndExit 4 "Error verifying $appPath error: $logoutput" ERROR cleanupAndExit 4 "Error verifying $appPath error: $logoutput" ERROR
fi fi
printlog "Debugging enabled, App Verification output was: $logoutput" DEBUG
printlog "Team ID matching: $teamID (expected: $expectedTeamID )" INFO printlog "Team ID matching: $teamID (expected: $expectedTeamID )" INFO
if [ "$expectedTeamID" != "$teamID" ]; then if [ "$expectedTeamID" != "$teamID" ]; then
@@ -517,18 +517,18 @@ installAppWithPath() { # $1: path to app to install in $targetDir
elif [[ ! -z $CLIInstaller ]]; then elif [[ ! -z $CLIInstaller ]]; then
mountname=$(dirname $appPath) mountname=$(dirname $appPath)
printlog "CLIInstaller exists, running installer command $mountname/$CLIInstaller $CLIArguments" #INFO printlog "CLIInstaller exists, running installer command $mountname/$CLIInstaller $CLIArguments" INFO
CLIoutput=$("$mountname/$CLIInstaller" "${CLIArguments[@]}" 2>&1) CLIoutput=$("$mountname/$CLIInstaller" "${CLIArguments[@]}" 2>&1)
CLIstatus=$(echo $?) CLIstatus=$(echo $?)
logoutput="$CLIoutput" # dedupliatelogs "$CLIoutput" dedupliatelogs "$CLIoutput"
if [ $CLIstatus -ne 0 ] ; then if [ $CLIstatus -ne 0 ] ; then
cleanupAndExit 3 "Error installing $mountname/$CLIInstaller $CLIArguments error:\n$logoutput" #ERROR cleanupAndExit 3 "Error installing $mountname/$CLIInstaller $CLIArguments error: $logoutput" ERROR
else else
printlog "Succesfully ran $mountname/$CLIInstaller $CLIArguments" printlog "Succesfully ran $mountname/$CLIInstaller $CLIArguments" INFO
fi fi
printlog "Debugging enabled, update tool output was:\n$logoutput" #DEBUG printlog "Debugging enabled, update tool output was: $logoutput" DEBUG
fi fi
} }
@@ -537,16 +537,22 @@ mountDMG() {
# mount the dmg # mount the dmg
printlog "Mounting $tmpDir/$archiveName" printlog "Mounting $tmpDir/$archiveName"
# always pipe 'Y\n' in case the dmg requires an agreement # always pipe 'Y\n' in case the dmg requires an agreement
if ! dmgmount=$(echo 'Y'$'\n' | hdiutil attach "$tmpDir/$archiveName" -nobrowse -readonly | tail -n 1 | cut -c 54- ); then dmgmountOut=$(echo 'Y'$'\n' | hdiutil attach "$tmpDir/$archiveName" -nobrowse -readonly )
cleanupAndExit 3 "Error mounting $tmpDir/$archiveName" dmgmountStatus=$(echo $?)
fi dmgmount=$(echo $dmgmountOut | tail -n 1 | cut -c 54- )
printlog "dmgmountOut is $dmgmountOut" DEBUG
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: $logoutput" ERROR
fi
if [[ ! -e $dmgmount ]]; then if [[ ! -e $dmgmount ]]; then
printlog "Error mounting $tmpDir/$archiveName" cleanupAndExit 3 "Error accessing mountpoint for $tmpDir/$archiveName error: $logoutput" ERROR
cleanupAndExit 3
fi fi
printlog "Debugging enabled, installer output was: $logoutput" DEBUG
printlog "Mounted: $dmgmount" printlog "Mounted: $dmgmount" INFO
} }
installFromDMG() { installFromDMG() {
@@ -562,7 +568,7 @@ installFromPKG() {
spctlStatus=$(echo $?) spctlStatus=$(echo $?)
printlog "spctlOut is $spctlOut" DEBUG printlog "spctlOut is $spctlOut" DEBUG
teamID=$(echo $spctlOut | awk -F '(' '/origin=/ {print $2 }' | tr -d '()' ) teamID=$(echo $spctlOut | awk -F '(' '/origin=/ {print $2 }' | tr -d '()' )
deduplicatelogs "$spctlOut" # Why this? deduplicatelogs "$spctlOut"
if [[ $spctlStatus -ne 0 ]] ; then if [[ $spctlStatus -ne 0 ]] ; then
#if ! spctlout=$(spctl -a -vv -t install "$archiveName" 2>&1 ); then #if ! spctlout=$(spctl -a -vv -t install "$archiveName" 2>&1 ); then
@@ -636,7 +642,6 @@ installFromPKG() {
if [ $pkginstallstatus -ne 0 ] ; then if [ $pkginstallstatus -ne 0 ] ; then
#if ! installer -pkg "$archiveName" -tgt "$targetDir" ; then #if ! installer -pkg "$archiveName" -tgt "$targetDir" ; then
cleanupAndExit 9 "Error installing $archiveName error: $logoutput" ERROR cleanupAndExit 9 "Error installing $archiveName error: $logoutput" ERROR
fi fi
printlog "Debugging enabled, installer output was: $logoutput" DEBUG printlog "Debugging enabled, installer output was: $logoutput" DEBUG
} }

View File

@@ -255,7 +255,7 @@ MDMProfileName=""
# - MDM Profile Addigy has this name on the profile # - MDM Profile Addigy has this name on the profile
# - Mosyle Corporation MDM Mosyle uses this name on the profile # - Mosyle Corporation MDM Mosyle uses this name on the profile
# From the LOGO variable we can know if Addigy og Mosyle is used, so if that variable # From the LOGO variable we can know if Addigy og Mosyle is used, so if that variable
# is either of these, and this variable is empty, then we can will auto detect this. # is either of these, and this variable is empty, then we will auto detect this.
# Datadog logging used # Datadog logging used
datadogAPI="" datadogAPI=""

View File

@@ -172,7 +172,7 @@ if [ -f "$archiveName" ] && [ "$DEBUG" -eq 1 ]; then
printlog "$archiveName exists and DEBUG mode 1 enabled, skipping download" printlog "$archiveName exists and DEBUG mode 1 enabled, skipping download"
else else
# download the dmg # download the dmg
printlog "Downloading $downloadURL to $archiveName" printlog "Downloading $downloadURL to $archiveName" REQ
if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
printlog "notifying" printlog "notifying"
if [[ $updateDetected == "YES" ]]; then if [[ $updateDetected == "YES" ]]; then
@@ -181,7 +181,7 @@ else
displaynotification "Downloading new $name" "Download in progress …" displaynotification "Downloading new $name" "Download in progress …"
fi fi
fi fi
curlDownload=$(curl -v -fsL --show-error "$downloadURL" -o "$archiveName" 2>&1) curlDownload=$(curl -v -fsL --show-error ${curlOptions} "$downloadURL" -o "$archiveName" 2>&1)
curlDownloadStatus=$(echo $?) curlDownloadStatus=$(echo $?)
deduplicatelogs "$curlDownload" deduplicatelogs "$curlDownload"
printlog "curl output was: $logoutput" DEBUG printlog "curl output was: $logoutput" DEBUG
@@ -192,9 +192,9 @@ else
if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
printlog "notifying" printlog "notifying"
if [[ $updateDetected == "YES" ]]; then if [[ $updateDetected == "YES" ]]; then
displaynotification "$message" "Error updating $name" displaynotification "$message" "Error updating $name" ERROR
else else
displaynotification "$message" "Error installing $name" displaynotification "$message" "Error installing $name" ERROR
fi fi
fi fi
cleanupAndExit 2 "Error downloading $downloadURL error: $logoutput" ERROR cleanupAndExit 2 "Error downloading $downloadURL error: $logoutput" ERROR
@@ -215,7 +215,7 @@ else
fi fi
# MARK: install the download # MARK: install the download
printlog "Installing $name" printlog "Installing $name" REQ
if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
printlog "notifying" printlog "notifying"
if [[ $updateDetected == "YES" ]]; then if [[ $updateDetected == "YES" ]]; then
@@ -227,7 +227,7 @@ fi
if [ -n "$installerTool" ]; then if [ -n "$installerTool" ]; then
# installerTool defined, and we use that for installation # installerTool defined, and we use that for installation
printlog "installerTool used: $installerTool" printlog "installerTool used: $installerTool" REQ
appName="$installerTool" appName="$installerTool"
fi fi