mirror of
https://github.com/mtan93/Installomator.git
synced 2026-04-05 06:13:15 +01:00
fixed wrong status icons
This commit is contained in:
@@ -27,6 +27,7 @@ fakeInstallDelay=5
|
|||||||
|
|
||||||
items=(
|
items=(
|
||||||
"firefoxpkg|Firefox"
|
"firefoxpkg|Firefox"
|
||||||
|
"error|Expected Error"
|
||||||
"googlechromepkg|Google Chrome"
|
"googlechromepkg|Google Chrome"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -63,13 +64,11 @@ dialogUpdate() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogActivate() {
|
|
||||||
osascript -e 'tell app "Dialog" to activate'
|
|
||||||
}
|
|
||||||
|
|
||||||
progressUpdate() {
|
progressUpdate() {
|
||||||
# $1: progress text (optional)
|
# $1: progress text (optional)
|
||||||
local text=$1
|
local text=$1
|
||||||
|
itemCounter=$((itemCounter + 1))
|
||||||
|
dialogUpdate "progress: $itemCounter"
|
||||||
if [[ -n $text ]]; then
|
if [[ -n $text ]]; then
|
||||||
dialogUpdate "progresstext: $text"
|
dialogUpdate "progresstext: $text"
|
||||||
fi
|
fi
|
||||||
@@ -97,26 +96,11 @@ installomator() {
|
|||||||
local label=$1
|
local label=$1
|
||||||
local description=$2
|
local description=$2
|
||||||
|
|
||||||
startItem $description
|
|
||||||
|
|
||||||
$installomator $label \
|
$installomator $label \
|
||||||
DIALOG_CMD_FILE=${(q)dialog_command_file} \
|
DIALOG_CMD_FILE=${(q)dialog_command_file} \
|
||||||
DIALOG_LIST_ITEM_NAME=${(q)description} \
|
DIALOG_LIST_ITEM_NAME=${(q)description} \
|
||||||
DEBUG=$DEBUG \
|
DEBUG=$DEBUG \
|
||||||
LOGGING=DEBUG
|
LOGGING=DEBUG
|
||||||
|
|
||||||
# if [[ $DEBUG -eq 0 ]]; then
|
|
||||||
# $installomator $label DIALOG_PROGRESS=yes DIALOG_CMD_FILE=$dialog_command_file
|
|
||||||
# else
|
|
||||||
# echo "DEBUG enabled, this would be 'Installomator $label'"
|
|
||||||
# for ((c=0; c<$fakeInstallDelay; c++ )); do
|
|
||||||
# p=$((c * 100 / fakeInstallDelay))
|
|
||||||
# dialogUpdate "progress: $p"
|
|
||||||
# sleep 1
|
|
||||||
# done
|
|
||||||
# fi
|
|
||||||
|
|
||||||
completeItem $description "success"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupAndExit() {
|
cleanupAndExit() {
|
||||||
@@ -227,7 +211,7 @@ trap cleanupAndExit EXIT
|
|||||||
tmpDir=$(mktemp -d)
|
tmpDir=$(mktemp -d)
|
||||||
|
|
||||||
# setup first list
|
# setup first list
|
||||||
itemCount=${#items}
|
itemCount=$((${#items} + 2))
|
||||||
|
|
||||||
listitems=( "--listitem" "Configure Tools" )
|
listitems=( "--listitem" "Configure Tools" )
|
||||||
|
|
||||||
@@ -246,10 +230,10 @@ echo "installing Swift Dialog"
|
|||||||
checkSwiftDialog
|
checkSwiftDialog
|
||||||
|
|
||||||
# display first screen
|
# display first screen
|
||||||
$dialog --title "Configuring your Mac" \
|
$dialog --title "More Software" \
|
||||||
--icon "SF=gear" \
|
--icon "SF=gear" \
|
||||||
--message "Setting up some more things..." \
|
--message "We are downloading and installing some extra Apps. Hold on for minute..." \
|
||||||
--progress 100 \
|
--progress $itemCount \
|
||||||
"${listitems[@]}" \
|
"${listitems[@]}" \
|
||||||
--button1disabled \
|
--button1disabled \
|
||||||
--big \
|
--big \
|
||||||
@@ -258,14 +242,25 @@ $dialog --title "Configuring your Mac" \
|
|||||||
--messagefont size=16 \
|
--messagefont size=16 \
|
||||||
--commandfile $dialog_command_file & dialogPID=$!
|
--commandfile $dialog_command_file & dialogPID=$!
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
dialogActivate
|
|
||||||
|
itemCounter=0
|
||||||
|
progressUpdate "ConfigureTools"
|
||||||
|
|
||||||
completeItem "Configure Tools" "success"
|
completeItem "Configure Tools" "success"
|
||||||
|
|
||||||
for item in $items; do
|
for item in $items; do
|
||||||
label=$(cut -d '|' -f 1 <<< $item)
|
label=$(cut -d '|' -f 1 <<< $item)
|
||||||
description=$(cut -d '|' -f 2 <<< $item)
|
description=$(cut -d '|' -f 2 <<< $item)
|
||||||
|
|
||||||
|
startItem $description
|
||||||
installomator $label $description
|
installomator $label $description
|
||||||
done
|
done
|
||||||
|
|
||||||
dialogUpdate "quit:"
|
# clean up UI
|
||||||
|
|
||||||
|
dialogUpdate "progress: complete"
|
||||||
|
dialogUpdate "progresstext: Finished"
|
||||||
|
|
||||||
|
dialogUpdate "button1: enable"
|
||||||
|
dialogUpdate "button1text: Done"
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,20 @@ if ! is-at-least 10.14 $installedOSversion; then
|
|||||||
exit 98
|
exit 98
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check Swift Dialog presence and version
|
||||||
|
DIALOG_CMD="/usr/local/bin/dialog"
|
||||||
|
|
||||||
|
if [[ -x $DIALOG_CMD ]]; then
|
||||||
|
# Swift Dialog is not installed, clear cmd file variable to ignore
|
||||||
|
DIALOG_CMD_FILE=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is-at-least 1.11.2 "$(/usr/local/bindialog --version)"; then
|
||||||
|
# list item progress is only available with SD 1.11.2 and higher
|
||||||
|
DIALOG_LIST_ITEM_NAME=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# MARK: argument parsing
|
# MARK: argument parsing
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
if [[ -z $label ]]; then # check if label is set inside script
|
if [[ -z $label ]]; then # check if label is set inside script
|
||||||
|
|||||||
@@ -14,17 +14,15 @@ cleanupAndExit() { # $1 = exit code, $2 message, $3 level
|
|||||||
printlog "Debugging enabled, Deleting tmpDir output was:\n$deleteTmpOut" DEBUG
|
printlog "Debugging enabled, Deleting tmpDir output was:\n$deleteTmpOut" DEBUG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# # If displaying progres, quit dialog
|
|
||||||
# if [[ $DIALOG_PROGRESS == "main" || $DIALOG_PROGRESS == "list" ]]; then
|
|
||||||
# quitDialog "$DIALOGCMDFILE"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# If we closed any processes, reopen the app again
|
# If we closed any processes, reopen the app again
|
||||||
reopenClosedProcess
|
reopenClosedProcess
|
||||||
if [[ -n $2 && $1 -ne 0 ]]; then
|
if [[ -n $2 && $1 -ne 0 ]]; then
|
||||||
printlog "ERROR: $2" $3
|
printlog "ERROR: $2" $3
|
||||||
|
updateDialog "fail" "Error ($1; $2)"
|
||||||
else
|
else
|
||||||
printlog "$2" $3
|
printlog "$2" $3
|
||||||
|
updateDialog "success" ""
|
||||||
fi
|
fi
|
||||||
printlog "################## End Installomator, exit code $1 \n" REQ
|
printlog "################## End Installomator, exit code $1 \n" REQ
|
||||||
|
|
||||||
@@ -846,7 +844,6 @@ runUpdateTool() {
|
|||||||
|
|
||||||
finishing() {
|
finishing() {
|
||||||
printlog "Finishing..."
|
printlog "Finishing..."
|
||||||
updateDialog "wait" "Finishing..."
|
|
||||||
|
|
||||||
sleep 3 # wait a moment to let spotlight catch up
|
sleep 3 # wait a moment to let spotlight catch up
|
||||||
getAppVersion
|
getAppVersion
|
||||||
@@ -931,7 +928,7 @@ readDownloadPipe() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $char == % ]]; then
|
if [[ $char == % ]]; then
|
||||||
updateDialog $progress "Downloading $name - $progress%"
|
updateDialog $progress "Downloading..."
|
||||||
progress=""
|
progress=""
|
||||||
keep=0
|
keep=0
|
||||||
fi
|
fi
|
||||||
@@ -976,11 +973,11 @@ updateDialog() {
|
|||||||
local cmd_file=${4:-$DIALOG_CMD_FILE}
|
local cmd_file=${4:-$DIALOG_CMD_FILE}
|
||||||
local progress=""
|
local progress=""
|
||||||
|
|
||||||
if [[ state =~ [0-9]* \
|
if [[ $state =~ '^[0-9]' \
|
||||||
|| state == "reset" \
|
|| $state == "reset" \
|
||||||
|| state == "increment" \
|
|| $state == "increment" \
|
||||||
|| state == "complete" \
|
|| $state == "complete" \
|
||||||
|| state == "indeterminate" ]]; then
|
|| $state == "indeterminate" ]]; then
|
||||||
progress=$state
|
progress=$state
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -995,7 +992,7 @@ updateDialog() {
|
|||||||
echo "progress: $progress" >> $cmd_file
|
echo "progress: $progress" >> $cmd_file
|
||||||
fi
|
fi
|
||||||
if [[ $message != "" ]]; then
|
if [[ $message != "" ]]; then
|
||||||
echo "progresstext: $message" >> $cmd_file
|
echo "progresstext: $name - $message" >> $cmd_file
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# list item has a value, so we update the progress and text in the list
|
# list item has a value, so we update the progress and text in the list
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ fi
|
|||||||
# MARK: check if this is an Update and we can use updateTool
|
# MARK: check if this is an Update and we can use updateTool
|
||||||
if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then
|
if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then
|
||||||
printlog "appversion & updateTool"
|
printlog "appversion & updateTool"
|
||||||
|
updateDialog "wait" "Updating..."
|
||||||
|
|
||||||
if [[ $DEBUG -ne 1 ]]; then
|
if [[ $DEBUG -ne 1 ]]; then
|
||||||
if runUpdateTool; then
|
if runUpdateTool; then
|
||||||
finishing
|
finishing
|
||||||
@@ -257,8 +259,10 @@ if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then
|
|||||||
printlog "notifying"
|
printlog "notifying"
|
||||||
if [[ $updateDetected == "YES" ]]; then
|
if [[ $updateDetected == "YES" ]]; then
|
||||||
displaynotification "Updating $name" "Installation in progress …"
|
displaynotification "Updating $name" "Installation in progress …"
|
||||||
|
updateDialog "wait" "Updating..."
|
||||||
else
|
else
|
||||||
displaynotification "Installing $name" "Installation in progress …"
|
displaynotification "Installing $name" "Installation in progress …"
|
||||||
|
updateDialog "wait" "Installing..."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -295,8 +299,12 @@ case $type in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
updateDialog "wait" "Finishing..."
|
||||||
|
|
||||||
# MARK: Finishing — print installed application location and version
|
# MARK: Finishing — print installed application location and version
|
||||||
finishing
|
finishing
|
||||||
|
|
||||||
|
updateDialog "success" "$appversion"
|
||||||
|
|
||||||
# all done!
|
# all done!
|
||||||
cleanupAndExit 0 "All done!" REQ
|
cleanupAndExit 0 "All done!" REQ
|
||||||
|
|||||||
Reference in New Issue
Block a user