merged logging fixes, closes #427

This commit is contained in:
Armin Briegel
2022-03-18 10:42:06 +01:00
3 changed files with 19 additions and 15 deletions

View File

@@ -3,7 +3,7 @@ autoload is-at-least
installedOSversion=$(sw_vers -productVersion) installedOSversion=$(sw_vers -productVersion)
if ! is-at-least 10.14 $installedOSversion; then if ! is-at-least 10.14 $installedOSversion; then
printlog "Installomator requires at least macOS 10.14 Mojave." printlog "Installomator requires at least macOS 10.14 Mojave." ERROR
exit 98 exit 98
fi fi
@@ -24,7 +24,7 @@ fi
while [[ -n $1 ]]; do while [[ -n $1 ]]; do
if [[ $1 =~ ".*\=.*" ]]; then if [[ $1 =~ ".*\=.*" ]]; then
# if an argument contains an = character, send it to eval # if an argument contains an = character, send it to eval
printlog "setting variable from argument $1" REQ printlog "setting variable from argument $1" WARN
eval $1 eval $1
else else
# assume it's a label # assume it's a label

View File

@@ -444,7 +444,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
printlog "notifying" printlog "notifying"
displaynotification "$message" "No update for $name!" displaynotification "$message" "No update for $name!"
fi fi
cleanupAndExit 0 "No new version to install" WARN cleanupAndExit 0 "No new version to install" REG
else else
printlog "Using force to install anyway." printlog "Using force to install anyway."
fi fi
@@ -486,7 +486,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
# remove existing application # remove existing application
if [ -e "$targetDir/$appName" ]; then if [ -e "$targetDir/$appName" ]; then
printlog "Removing existing $targetDir/$appName" DEBUG printlog "Removing existing $targetDir/$appName" WARN
deleteAppOut=$(rm -Rfv "$targetDir/$appName" 2>&1) deleteAppOut=$(rm -Rfv "$targetDir/$appName" 2>&1)
tempName="$targetDir/$appName" tempName="$targetDir/$appName"
tempNameLength=$((${#tempName} + 10)) tempNameLength=$((${#tempName} + 10))
@@ -497,16 +497,21 @@ installAppWithPath() { # $1: path to app to install in $targetDir
# copy app to /Applications # copy app to /Applications
printlog "Copy $appPath to $targetDir" printlog "Copy $appPath to $targetDir"
if ! ditto "$appPath" "$targetDir/$appName"; then copyAppOut=$(ditto -v "$appPath" "$targetDir/$appName" 2>&1)
cleanupAndExit 7 "Error while copying" ERROR copyAppStatus=$(echo $?)
deduplicatelogs "$copyAppOut"
printlog "Debugging enabled, App copy output was:\n$logoutput" DEBUG
if [[ $copyAppStatus -ne 0 ]] ; then
#if ! ditto "$appPath" "$targetDir/$appName"; then
cleanupAndExit 7 "Error while copying:\n$logoutput" ERROR
fi fi
# set ownership to current user # set ownership to current user
if [[ "$currentUser" != "loginwindow" && $SYSTEMOWNER -ne 1 ]]; then if [[ "$currentUser" != "loginwindow" && $SYSTEMOWNER -ne 1 ]]; then
printlog "Changing owner to $currentUser" printlog "Changing owner to $currentUser" WARN
chown -R "$currentUser" "$targetDir/$appName" chown -R "$currentUser" "$targetDir/$appName"
else 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" WARN
chown -R root:wheel "$targetDir/$appName" chown -R root:wheel "$targetDir/$appName"
fi fi
@@ -604,7 +609,7 @@ installFromPKG() {
printlog "notifying" printlog "notifying"
displaynotification "$message" "No update for $name!" displaynotification "$message" "No update for $name!"
fi fi
cleanupAndExit 0 "No new version to install" WARN cleanupAndExit 0 "No new version to install" REQ
else else
printlog "Using force to install anyway." printlog "Using force to install anyway."
fi fi
@@ -814,7 +819,7 @@ finishing() {
message="Installed $name, version $appversion" message="Installed $name, version $appversion"
fi fi
printlog "$message" printlog "$message" REQ
if [[ $currentUser != "loginwindow" && ( $NOTIFY == "success" || $NOTIFY == "all" ) ]]; then if [[ $currentUser != "loginwindow" && ( $NOTIFY == "success" || $NOTIFY == "all" ) ]]; then
printlog "notifying" printlog "notifying"

View File

@@ -150,7 +150,7 @@ if [[ -n $appNewVersion ]]; then
printlog "notifying" printlog "notifying"
displaynotification "$message" "No update for $name!" displaynotification "$message" "No update for $name!"
fi fi
cleanupAndExit 0 "No newer version." WARN cleanupAndExit 0 "No newer version." REQ
fi fi
else else
printlog "DEBUG mode 1 enabled, not exiting, but there is no new version of app." WARN printlog "DEBUG mode 1 enabled, not exiting, but there is no new version of app." WARN
@@ -166,10 +166,9 @@ if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then
if [[ $DEBUG -ne 1 ]]; then if [[ $DEBUG -ne 1 ]]; then
if runUpdateTool; then if runUpdateTool; then
finishing finishing
cleanupAndExit 0 cleanupAndExit 0 "updateTool has run" REQ
elif [[ $type == "updateronly" ]];then elif [[ $type == "updateronly" ]];then
printlog "type is $type so we end here." cleanupAndExit 0 "type is $type so we end here." REQ
cleanupAndExit 0
fi # otherwise continue fi # otherwise continue
else else
printlog "DEBUG mode 1 enabled, not running update tool" WARN printlog "DEBUG mode 1 enabled, not running update tool" WARN
@@ -275,4 +274,4 @@ esac
finishing finishing
# all done! # all done!
cleanupAndExit 0 cleanupAndExit 0 "All done!" REQ