mirror of
https://github.com/mtan93/Installomator.git
synced 2026-04-04 22:04:35 +01:00
updated variable description
This commit is contained in:
@@ -52,16 +52,15 @@ identifier=$(echo "$identifier" | tr '[:upper:]' '[:lower:]' )
|
|||||||
#
|
#
|
||||||
# - archiveName: (optional)
|
# - archiveName: (optional)
|
||||||
# The name of the downloaded dmg
|
# 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)
|
# - appName: (optional)
|
||||||
# file name of the app bundle in the dmg to verify and copy (include .app)
|
# 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
|
# When not given, the App name is derived from the name
|
||||||
# and adding .app
|
|
||||||
#
|
#
|
||||||
# - targetDir: (optional)
|
# - targetDir: (optional)
|
||||||
# Applications will be copied to this directory, remember to omit trailing '/'
|
# Applications will be copied to this directory
|
||||||
# default value is '/Applications' for dmg and zip installations
|
# Default value is '/Applications' for dmg and zip installations
|
||||||
# With a pkg the targetDir is used as the install-location. Default is "/"
|
# 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: check for running processes and either abort or prompt user
|
||||||
# TODO: print version of installed software
|
# TODO: print version of installed software
|
||||||
# TODO: notification when done
|
# TODO: notification when done
|
||||||
# TODO: build helper tool to build case statement from a URL
|
|
||||||
# TODO: add remaining MS pkgs
|
# TODO: add remaining MS pkgs
|
||||||
|
|
||||||
# functions to help with getting info
|
# functions to help with getting info
|
||||||
|
|||||||
49
checkrunningprocesses.sh
Normal file
49
checkrunningprocesses.sh
Normal 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
|
||||||
Reference in New Issue
Block a user