mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-20 05:10:58 +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\")"
|
runAsUser /usr/bin/osascript -e "button returned of (display dialog \"$message\" buttons {\"Not Now\", \"Quit and Update\"} default button \"Quit and Update\")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# try at most 3 times
|
||||||
countedProcesses=1
|
for i in {1..3}; do
|
||||||
countedErrors=0
|
|
||||||
while [[ $countedProcesses -ne 0 ]]; do
|
|
||||||
countedProcesses=0
|
countedProcesses=0
|
||||||
for x in ${blockingProcesses}; do
|
for x in ${blockingProcesses}; do
|
||||||
if pgrep -xq "$x"; then
|
if pgrep -xq "$x"; then
|
||||||
echo "process $x is running"
|
echo "process $x is running"
|
||||||
# pkill $x
|
# 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
|
if [[ $button = "Not Now" ]]; then
|
||||||
echo "user aborted update"
|
echo "user aborted update"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -40,10 +38,25 @@ while [[ $countedProcesses -ne 0 ]]; do
|
|||||||
runAsUser osascript -e "tell app \"$x\" to quit"
|
runAsUser osascript -e "tell app \"$x\" to quit"
|
||||||
fi
|
fi
|
||||||
countedProcesses=$((countedProcesses + 1))
|
countedProcesses=$((countedProcesses + 1))
|
||||||
|
countedErrors=$((countedErrors + 1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ $countedProcesses -ne 0 ]]; then
|
|
||||||
# give the user some time to quit the app
|
if [[ $countedProcesses -eq 0 ]]; then
|
||||||
sleep 10
|
# no blocking processes, exit the loop early
|
||||||
|
break
|
||||||
|
else
|
||||||
|
# give the user a bit of time to quit apps
|
||||||
|
sleep 30
|
||||||
fi
|
fi
|
||||||
done
|
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