diff --git a/MDM/swiftdialog_list.sh b/MDM/swiftdialog_list.sh index 1cd7f21..0b96869 100755 --- a/MDM/swiftdialog_list.sh +++ b/MDM/swiftdialog_list.sh @@ -27,6 +27,7 @@ fakeInstallDelay=5 items=( "firefoxpkg|Firefox" + "error|Expected Error" "googlechromepkg|Google Chrome" ) @@ -63,13 +64,11 @@ dialogUpdate() { fi } -dialogActivate() { - osascript -e 'tell app "Dialog" to activate' -} - progressUpdate() { # $1: progress text (optional) local text=$1 + itemCounter=$((itemCounter + 1)) + dialogUpdate "progress: $itemCounter" if [[ -n $text ]]; then dialogUpdate "progresstext: $text" fi @@ -97,26 +96,11 @@ installomator() { local label=$1 local description=$2 - startItem $description - $installomator $label \ DIALOG_CMD_FILE=${(q)dialog_command_file} \ DIALOG_LIST_ITEM_NAME=${(q)description} \ DEBUG=$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() { @@ -227,7 +211,7 @@ trap cleanupAndExit EXIT tmpDir=$(mktemp -d) # setup first list -itemCount=${#items} +itemCount=$((${#items} + 2)) listitems=( "--listitem" "Configure Tools" ) @@ -246,10 +230,10 @@ echo "installing Swift Dialog" checkSwiftDialog # display first screen -$dialog --title "Configuring your Mac" \ +$dialog --title "More Software" \ --icon "SF=gear" \ - --message "Setting up some more things..." \ - --progress 100 \ + --message "We are downloading and installing some extra Apps. Hold on for minute..." \ + --progress $itemCount \ "${listitems[@]}" \ --button1disabled \ --big \ @@ -258,14 +242,25 @@ $dialog --title "Configuring your Mac" \ --messagefont size=16 \ --commandfile $dialog_command_file & dialogPID=$! sleep 0.1 -dialogActivate + +itemCounter=0 +progressUpdate "ConfigureTools" completeItem "Configure Tools" "success" for item in $items; do label=$(cut -d '|' -f 1 <<< $item) description=$(cut -d '|' -f 2 <<< $item) + + startItem $description installomator $label $description done -dialogUpdate "quit:" +# clean up UI + +dialogUpdate "progress: complete" +dialogUpdate "progresstext: Finished" + +dialogUpdate "button1: enable" +dialogUpdate "button1text: Done" + diff --git a/fragments/arguments.sh b/fragments/arguments.sh index d600180..ebe30bf 100644 --- a/fragments/arguments.sh +++ b/fragments/arguments.sh @@ -7,6 +7,20 @@ if ! is-at-least 10.14 $installedOSversion; then exit 98 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 if [[ $# -eq 0 ]]; then if [[ -z $label ]]; then # check if label is set inside script diff --git a/fragments/functions.sh b/fragments/functions.sh index 2c4b35a..864bfce 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -14,17 +14,15 @@ cleanupAndExit() { # $1 = exit code, $2 message, $3 level printlog "Debugging enabled, Deleting tmpDir output was:\n$deleteTmpOut" DEBUG 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 reopenClosedProcess if [[ -n $2 && $1 -ne 0 ]]; then printlog "ERROR: $2" $3 + updateDialog "fail" "Error ($1; $2)" else printlog "$2" $3 + updateDialog "success" "" fi printlog "################## End Installomator, exit code $1 \n" REQ @@ -846,7 +844,6 @@ runUpdateTool() { finishing() { printlog "Finishing..." - updateDialog "wait" "Finishing..." sleep 3 # wait a moment to let spotlight catch up getAppVersion @@ -931,7 +928,7 @@ readDownloadPipe() { fi if [[ $char == % ]]; then - updateDialog $progress "Downloading $name - $progress%" + updateDialog $progress "Downloading..." progress="" keep=0 fi @@ -976,11 +973,11 @@ updateDialog() { local cmd_file=${4:-$DIALOG_CMD_FILE} local progress="" - if [[ state =~ [0-9]* \ - || state == "reset" \ - || state == "increment" \ - || state == "complete" \ - || state == "indeterminate" ]]; then + if [[ $state =~ '^[0-9]' \ + || $state == "reset" \ + || $state == "increment" \ + || $state == "complete" \ + || $state == "indeterminate" ]]; then progress=$state fi @@ -995,7 +992,7 @@ updateDialog() { echo "progress: $progress" >> $cmd_file fi if [[ $message != "" ]]; then - echo "progresstext: $message" >> $cmd_file + echo "progresstext: $name - $message" >> $cmd_file fi else # list item has a value, so we update the progress and text in the list diff --git a/fragments/main.sh b/fragments/main.sh index 6cf93b9..66a8200 100644 --- a/fragments/main.sh +++ b/fragments/main.sh @@ -168,6 +168,8 @@ fi # MARK: check if this is an Update and we can use updateTool if [[ (-n $appversion && -n "$updateTool") || "$type" == "updateronly" ]]; then printlog "appversion & updateTool" + updateDialog "wait" "Updating..." + if [[ $DEBUG -ne 1 ]]; then if runUpdateTool; then finishing @@ -257,8 +259,10 @@ if [[ $currentUser != "loginwindow" && $NOTIFY == "all" ]]; then printlog "notifying" if [[ $updateDetected == "YES" ]]; then displaynotification "Updating $name" "Installation in progress …" + updateDialog "wait" "Updating..." else displaynotification "Installing $name" "Installation in progress …" + updateDialog "wait" "Installing..." fi fi @@ -295,8 +299,12 @@ case $type in ;; esac +updateDialog "wait" "Finishing..." + # MARK: Finishing — print installed application location and version finishing +updateDialog "success" "$appversion" + # all done! cleanupAndExit 0 "All done!" REQ