From 31c18118ac68920e2772022d12d2ab5cef3f4f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Wed, 26 May 2021 09:41:30 +0200 Subject: [PATCH] quit & quit_kill Should be great for certain service apps, that we want to kill politely. Before use it should be checked it will not respawn automatically. --- Installomator.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Installomator.sh b/Installomator.sh index 579f7c8..49de03c 100755 --- a/Installomator.sh +++ b/Installomator.sh @@ -34,6 +34,9 @@ NOTIFY=success BLOCKING_PROCESS_ACTION=prompt_user # options: # - ignore continue even when blocking processes are found +# - quit app will be told to quit nicely, if running +# - quit_kill told to quit twice, then it will be killed +# Could be great for service apps, if they do not respawn # - silent_fail exit script without prompt or installation # - prompt_user show a user dialog for each blocking process found # abort after three attempts to quit @@ -379,6 +382,18 @@ checkRunningProcesses() { appClosed=1 case $BLOCKING_PROCESS_ACTION in + quit|quit_kill) + printlog "telling app $x to quit" + runAsUser osascript -e "tell app \"$x\" to quit" + if [[ $i > 2 && $BLOCKING_PROCESS_ACTION = "quit_kill" ]]; then + printlog "Changing BLOCKING_PROCESS_ACTION to kill" + BLOCKING_PROCESS_ACTION=kill + else + # give the user a bit of time to quit apps + printlog "waiting 30 seconds for processes to quit" + sleep 30 + fi + ;; kill) printlog "killing process $x" pkill $x