This commit is contained in:
Søren Theilgaard
2021-04-18 10:56:59 +02:00
parent 2946990942
commit ced90daa71
2 changed files with 37 additions and 6 deletions

View File

@@ -72,6 +72,13 @@ INSTALL=""
# - force Install even if its the same version # - force Install even if its the same version
# Re-opening of closed app
REOPEN="yes"
# options:
# - yes App wil be reopened if it was closed
# - no App not reopened
# NOTE: How labels work # NOTE: How labels work
# Each workflow label needs to be listed in the case statement below. # Each workflow label needs to be listed in the case statement below.
@@ -179,7 +186,7 @@ cleanupAndExit() { # $1 = exit code, $2 message
hdiutil detach "$dmgmount" hdiutil detach "$dmgmount"
fi fi
# If we closed any processes, reopen the app again # If we closed any processes, reopen the app again
#reopenClosedProcess # We skip this again, not all apps work correctly when opened like this reopenClosedProcess
printlog "################## End Installomator, exit code $1 \n\n" printlog "################## End Installomator, exit code $1 \n\n"
exit "$1" exit "$1"
} }
@@ -191,6 +198,13 @@ runAsUser() {
fi fi
} }
reloadAsUser() {
if [[ $currentUser != "loginwindow" ]]; then
uid=$(id -u "$currentUser")
su - $currentUser -c "${@}"
fi
}
displaydialog() { # $1: message $2: title displaydialog() { # $1: message $2: title
message=${1:-"Message"} message=${1:-"Message"}
title=${2:-"Installomator"} title=${2:-"Installomator"}
@@ -418,6 +432,12 @@ reopenClosedProcess() {
# If Installomator closed any processes, let's get the app opened again # If Installomator closed any processes, let's get the app opened again
# credit: Søren Theilgaard (@theilgaard) # credit: Søren Theilgaard (@theilgaard)
# don't reopen if REOPEN is not "yes"
if [[ $REOPEN != yes ]]; then
printlog "REOPEN=no, not reopening anything"
return
fi
# don't reopen in DEBUG mode # don't reopen in DEBUG mode
if [[ $DEBUG -ne 0 ]]; then if [[ $DEBUG -ne 0 ]]; then
printlog "DEBUG mode, not reopening anything" printlog "DEBUG mode, not reopening anything"
@@ -425,11 +445,15 @@ reopenClosedProcess() {
fi fi
if [[ $appClosed == 1 ]]; then if [[ $appClosed == 1 ]]; then
printlog "Telling app $name to open" printlog "Telling app $appName to open"
#runAsUser osascript -e "tell app \"$name\" to open" #runAsUser osascript -e "tell app \"$appName\" to open"
runAsUser open -a "${name}" #runAsUser open -a "${appName}"
processuser=$(ps aux | grep -i "${name}") reloadAsUser "open -a \"${appName}\""
printlog "Reopened ${name} as $processuser" #reloadAsUser "open \"${(0)applist}\""
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."
fi fi
} }

View File

@@ -259,6 +259,12 @@ Since we now make a version checking, and only installs the software if the vers
- ``: When not set, software is only installed if it is newer/different in version (default) - ``: When not set, software is only installed if it is newer/different in version (default)
- `force`: Install even if its the same version - `force`: Install even if its the same version
### Re-opening of closed app
The `REOPEN` can be used to prevent the reopening of a closed app
- `yes`: (default) app will be reopened if it was closed
- `no`: app not reopened
### Adding applications/label blocks ### Adding applications/label blocks
@@ -327,6 +333,7 @@ Depending on the application or pkg there are a few more variables you can or ne
- `appName`: (optional) - `appName`: (optional)
File name of the app bundle in the dmg to verify and copy (include the `.app`). File name of the app bundle in the dmg to verify and copy (include the `.app`).
When not given, the `appName` is set to `$name.app`. When not given, the `appName` is set to `$name.app`.
This is also the name of the app that will get reopned, if we closed any `blockingProcesses` (see further down)
- `targetDir`: (optional) - `targetDir`: (optional)
dmg or zip: dmg or zip: