mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-29 06:13:14 +01:00
changed cleanupandexit
This commit is contained in:
@@ -96,6 +96,7 @@ BLOCKING_PROCESS_ACTION=prompt_user
|
|||||||
# TODO: add remaining MS pkgs
|
# TODO: add remaining MS pkgs
|
||||||
# TODO: determine blockingProcesses for SharePointPlugin
|
# TODO: determine blockingProcesses for SharePointPlugin
|
||||||
# TODO: use Sparkle to get latest download
|
# TODO: use Sparkle to get latest download
|
||||||
|
# TODO: notify user of errors
|
||||||
|
|
||||||
# functions to help with getting info
|
# functions to help with getting info
|
||||||
|
|
||||||
@@ -112,8 +113,7 @@ downloadURLFromGit() { # $1 git user name, $2 git repo name
|
|||||||
| awk -F '"' "/browser_download_url/ && /$type/ { print \$4 }")
|
| awk -F '"' "/browser_download_url/ && /$type/ { print \$4 }")
|
||||||
fi
|
fi
|
||||||
if [ -z "$downloadURL" ]; then
|
if [ -z "$downloadURL" ]; then
|
||||||
echo "could not retrieve download URL for $gitusername/$gitreponame"
|
cleanupAndExit 9 "could not retrieve download URL for $gitusername/$gitreponame"
|
||||||
cleanupAndExit 9
|
|
||||||
else
|
else
|
||||||
echo "$downloadURL"
|
echo "$downloadURL"
|
||||||
return 0
|
return 0
|
||||||
@@ -242,6 +242,12 @@ case $identifier in
|
|||||||
expectedTeamID="VRPY9KHGX6"
|
expectedTeamID="VRPY9KHGX6"
|
||||||
targetDir="/Applications/Utilities"
|
targetDir="/Applications/Utilities"
|
||||||
;;
|
;;
|
||||||
|
tunnelbear)
|
||||||
|
name="TunnelBear"
|
||||||
|
type="zip"
|
||||||
|
downloadURL="https://s3.amazonaws.com/tunnelbear/downloads/mac/TunnelBear.zip"
|
||||||
|
expectedTeamID="P2PHZ9K5JJ"
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -373,7 +379,10 @@ case $identifier in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
cleanupAndExit() { # $1 = exit code
|
cleanupAndExit() { # $1 = exit code, $2 message
|
||||||
|
if [[ -n $2 && $1 -ne 0 ]]; then
|
||||||
|
echo "ERROR: $2"
|
||||||
|
fi
|
||||||
if [ "$DEBUG" -eq 0 ]; then
|
if [ "$DEBUG" -eq 0 ]; then
|
||||||
# remove the temporary working directory when done
|
# remove the temporary working directory when done
|
||||||
echo "Deleting $tmpDir"
|
echo "Deleting $tmpDir"
|
||||||
@@ -421,15 +430,13 @@ checkRunningProcesses() {
|
|||||||
prompt_user)
|
prompt_user)
|
||||||
button=$(displaydialog "The application $x needs to be updated. Quit $x to continue updating?")
|
button=$(displaydialog "The application $x needs to be updated. Quit $x to continue updating?")
|
||||||
if [[ $button = "Not Now" ]]; then
|
if [[ $button = "Not Now" ]]; then
|
||||||
echo "user aborted update"
|
cleanupAndExit 10 "user aborted update"
|
||||||
cleanupAndExit 10
|
|
||||||
else
|
else
|
||||||
runAsUser osascript -e "tell app \"$x\" to quit"
|
runAsUser osascript -e "tell app \"$x\" to quit"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
silent_fail)
|
silent_fail)
|
||||||
echo "aborting"
|
cleanupAndExit 12 "blocking process '$x' found, aborting"
|
||||||
cleanupAndExit 12
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -448,8 +455,7 @@ checkRunningProcesses() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ $countedProcesses -ne 0 ]]; then
|
if [[ $countedProcesses -ne 0 ]]; then
|
||||||
echo "could not quit all processes, aborting..."
|
cleanupAndExit 11 "could not quit all processes, aborting..."
|
||||||
cleanupAndExit 11
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "no more blocking processes, continue with update"
|
echo "no more blocking processes, continue with update"
|
||||||
@@ -460,30 +466,26 @@ installAppWithPath() { # $1: path to app to install in $targetDir
|
|||||||
|
|
||||||
# check if app exists
|
# check if app exists
|
||||||
if [ ! -e "$appPath" ]; then
|
if [ ! -e "$appPath" ]; then
|
||||||
echo "could not find: $appPath"
|
cleanupAndExit 8 "could not find: $appPath"
|
||||||
cleanupAndExit 8
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# verify with spctl
|
# verify with spctl
|
||||||
echo "Verifying: $appPath"
|
echo "Verifying: $appPath"
|
||||||
if ! teamID=$(spctl -a -vv "$appPath" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()' ); then
|
if ! teamID=$(spctl -a -vv "$appPath" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()' ); then
|
||||||
echo "Error verifying $appPath"
|
cleanupAndExit 4 "Error verifying $appPath"
|
||||||
cleanupAndExit 4
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Team ID: $teamID (expected: $expectedTeamID )"
|
echo "Team ID: $teamID (expected: $expectedTeamID )"
|
||||||
|
|
||||||
if [ "$expectedTeamID" != "$teamID" ]; then
|
if [ "$expectedTeamID" != "$teamID" ]; then
|
||||||
echo "Team IDs do not match!"
|
cleanupAndExit 5 "Team IDs do not match"
|
||||||
cleanupAndExit 5
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for root
|
# check for root
|
||||||
if [ "$(whoami)" != "root" ]; then
|
if [ "$(whoami)" != "root" ]; then
|
||||||
# not running as root
|
# not running as root
|
||||||
if [ "$DEBUG" -eq 0 ]; then
|
if [ "$DEBUG" -eq 0 ]; then
|
||||||
echo "not running as root, exiting"
|
cleanupAndExit 6 "not running as root, exiting"
|
||||||
cleanupAndExit 6
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "DEBUG enabled, skipping copy and chown steps"
|
echo "DEBUG enabled, skipping copy and chown steps"
|
||||||
@@ -499,8 +501,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir
|
|||||||
# copy app to /Applications
|
# copy app to /Applications
|
||||||
echo "Copy $appPath to $targetDir"
|
echo "Copy $appPath to $targetDir"
|
||||||
if ! ditto "$appPath" "$targetDir/$appName"; then
|
if ! ditto "$appPath" "$targetDir/$appName"; then
|
||||||
echo "Error while copying!"
|
cleanupAndExit 7 "Error while copying"
|
||||||
cleanupAndExit 7
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -519,8 +520,7 @@ installFromDMG() {
|
|||||||
echo "Mounting $tmpDir/$archiveName"
|
echo "Mounting $tmpDir/$archiveName"
|
||||||
# always pipe 'Y\n' in case the dmg requires an agreement
|
# always pipe 'Y\n' in case the dmg requires an agreement
|
||||||
if ! dmgmount=$(echo 'Y'$'\n' | hdiutil attach "$tmpDir/$archiveName" -nobrowse -readonly | tail -n 1 | cut -c 54- ); then
|
if ! dmgmount=$(echo 'Y'$'\n' | hdiutil attach "$tmpDir/$archiveName" -nobrowse -readonly | tail -n 1 | cut -c 54- ); then
|
||||||
echo "Error mounting $tmpDir/$archiveName"
|
cleanupAndExit 3 "Error mounting $tmpDir/$archiveName"
|
||||||
cleanupAndExit 3
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e $dmgmount ]]; then
|
if [[ ! -e $dmgmount ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user