updated variable description

This commit is contained in:
Armin Briegel
2020-03-11 11:05:28 +01:00
parent 573ed2e463
commit 37c7af7b63
2 changed files with 53 additions and 6 deletions

View File

@@ -52,16 +52,15 @@ identifier=$(echo "$identifier" | tr '[:upper:]' '[:lower:]' )
#
# - archiveName: (optional)
# The name of the downloaded dmg
# When not given the archiveName is derived from the last part of the downloadURL
# When not given the archiveName is derived from the name
#
# - appName: (optional)
# file name of the app bundle in the dmg to verify and copy (include .app)
# When not given, the App name is derived from the archiveName by removing the extension
# and adding .app
# When not given, the App name is derived from the name
#
# - targetDir: (optional)
# Applications will be copied to this directory, remember to omit trailing '/'
# default value is '/Applications' for dmg and zip installations
# Applications will be copied to this directory
# Default value is '/Applications' for dmg and zip installations
# With a pkg the targetDir is used as the install-location. Default is "/"
@@ -72,7 +71,6 @@ identifier=$(echo "$identifier" | tr '[:upper:]' '[:lower:]' )
# TODO: check for running processes and either abort or prompt user
# TODO: print version of installed software
# TODO: notification when done
# TODO: build helper tool to build case statement from a URL
# TODO: add remaining MS pkgs
# functions to help with getting info

49
checkrunningprocesses.sh Normal file
View File

@@ -0,0 +1,49 @@
#!/bin/zsh
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
blockingProcesses=( Notes firefox "Activity Monitor" "Microsoft Word" )
# functions
consoleUser() {
scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }'
}
runAsUser() {
cuser=$(consoleUser)
if [[ $cuser != "loginwindow" ]]; then
uid=$(id -u "$cuser")
launchctl asuser $uid sudo -u $cuser "$@"
fi
}
displaydialog() { # $1: message
message=${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
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?")
if [[ $button = "Not Now" ]]; then
echo "user aborted update"
exit 1
else
runAsUser osascript -e "tell app \"$x\" to quit"
fi
countedProcesses=$((countedProcesses + 1))
fi
done
if [[ $countedProcesses -ne 0 ]]; then
# give the user some time to quit the app
sleep 10
fi
done