mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
now working as expected
This commit is contained in:
@@ -23,16 +23,14 @@ displaydialog() { # $1: message
|
||||
runAsUser /usr/bin/osascript -e "button returned of (display dialog \"$message\" buttons {\"Not Now\", \"Quit and Update\"} default button \"Quit and Update\")"
|
||||
}
|
||||
|
||||
|
||||
countedProcesses=1
|
||||
countedErrors=0
|
||||
while [[ $countedProcesses -ne 0 ]]; do
|
||||
# try at most 3 times
|
||||
for i in {1..3}; do
|
||||
countedProcesses=0
|
||||
for x in ${blockingProcesses}; do
|
||||
if pgrep -xq "$x"; then
|
||||
echo "process $x is running"
|
||||
# pkill $x
|
||||
button=$(displaydialog "The Application $x needs to be updated. Quit the app to continue updating?")
|
||||
button=$(displaydialog "The application $x needs to be updated. Quit the app to continue updating?")
|
||||
if [[ $button = "Not Now" ]]; then
|
||||
echo "user aborted update"
|
||||
exit 1
|
||||
@@ -40,10 +38,25 @@ while [[ $countedProcesses -ne 0 ]]; do
|
||||
runAsUser osascript -e "tell app \"$x\" to quit"
|
||||
fi
|
||||
countedProcesses=$((countedProcesses + 1))
|
||||
countedErrors=$((countedErrors + 1))
|
||||
fi
|
||||
done
|
||||
if [[ $countedProcesses -ne 0 ]]; then
|
||||
# give the user some time to quit the app
|
||||
sleep 10
|
||||
|
||||
if [[ $countedProcesses -eq 0 ]]; then
|
||||
# no blocking processes, exit the loop early
|
||||
break
|
||||
else
|
||||
# give the user a bit of time to quit apps
|
||||
sleep 30
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $countedProcesses -ne 0 ]]; then
|
||||
echo "could not quit all processes, aborting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "everything is quit, continue with update"
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user