From cc5326ce249ff0148006a3fbf209d31bdc89c010 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Thu, 11 Aug 2022 14:15:50 +0200 Subject: [PATCH] more cleanup and comments --- MDM/Jamf/00_Prepare_SwiftDialog.sh | 28 +++++++++++++++++++--------- MDM/Jamf/ReadMe.md | 4 ++++ MDM/Jamf/zz_Quit_SwiftDialog.sh | 14 +++++++++++--- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/MDM/Jamf/00_Prepare_SwiftDialog.sh b/MDM/Jamf/00_Prepare_SwiftDialog.sh index 7d1e6a4..d4b4efe 100755 --- a/MDM/Jamf/00_Prepare_SwiftDialog.sh +++ b/MDM/Jamf/00_Prepare_SwiftDialog.sh @@ -2,13 +2,22 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin +# MARK: Arguments/Parameters + +# Parameter 4: path to the swiftDialog command file +dialog_command_file=${4:-"/var/tmp/dialog.log"} + +# Parameter 5: message displayed over the progress bar +message=${5:-"Self Service Progress"} + +# Parameter 6: path or URL to an icon +icon=${6:-"/System/Applications/App Store.app/Contents/Resources/AppIcon.icns"} +# see Dan Snelson's advice on how to get a URL to an icon in Self Service +# https://rumble.com/v119x6y-harvesting-self-service-icons.html + # MARK: Constants -dialog="/usr/local/bin/dialog" - -dialog_command_file=${4:-"/var/tmp/dialog.log"} -message=${5:-"Self Service Progress"} -icon=${6:-"/System/Applications/App Store.app/Contents/Resources/AppIcon.icns"} +dialogApp="/Library/Application Support/Dialog/Dialog.app" # MARK: Functions @@ -37,16 +46,16 @@ if [[ $DEBUG -eq 0 && $(id -u) -ne 0 ]]; then fi # check for Swift Dialog -if [[ ! -x $dialog ]]; then - echo "Cannot find dialog at $dialog" +if [[ ! -d $dialogApp ]]; then + echo "Cannot find dialog at $dialogApp" exit 95 fi -# MARK: Setup +# MARK: Configure and display swiftDialog # display first screen -open -a /Library/Application\ Support/Dialog/Dialog.app --args \ +open -a "$dialogApp" --args \ --title none \ --icon "$icon" \ --message "$message" \ @@ -57,4 +66,5 @@ open -a /Library/Application\ Support/Dialog/Dialog.app --args \ --movable \ --commandfile "$dialog_command_file" +# give everything a moment to catch up sleep 0.1 diff --git a/MDM/Jamf/ReadMe.md b/MDM/Jamf/ReadMe.md index ef9e0b5..f4b9f08 100644 --- a/MDM/Jamf/ReadMe.md +++ b/MDM/Jamf/ReadMe.md @@ -21,13 +21,17 @@ The different scripts require a set of parameters. We will use the `googlechrome `00_Prepare_SwiftDialog.sh` Parameter 4: `/var/tmp/dialog` (Path to the swiftDialog command file) + Parameter 5: `Installing Google Chrome...` (text shown in the swiftDialog window above the progress bar) + Parameter 6: Path to or URL for an icon in swiftDialog. This can be a path on the client or a URL. See Dan Snelson's advice on how to get icon URLs for Self Service icons: https://rumble.com/v119x6y-harvesting-self-service-icons.html `Installomator.sh` Parameter 4: `googlechromepkg` (the label to install) + Parameter 5: `DIALOG_CMD_FILE=\var\log\dialog.log` (the swiftDialog command file, this has to be the same value as parameter 4 in the previous script) + Parameter 6: `NOTIFY=silent` (disable Installomator notifications, optional) You can add more configurations to the Installomator script when needed. diff --git a/MDM/Jamf/zz_Quit_SwiftDialog.sh b/MDM/Jamf/zz_Quit_SwiftDialog.sh index 9ce9303..705c78c 100755 --- a/MDM/Jamf/zz_Quit_SwiftDialog.sh +++ b/MDM/Jamf/zz_Quit_SwiftDialog.sh @@ -1,8 +1,13 @@ #!/bin/zsh -dialog="/usr/local/bin/dialog" +# MARK: Arguments/Parameters + +# Parameter 4: path to the swiftDialog command file dialog_command_file=${4:-"/var/tmp/dialog.log"} +# MARK: Constants +dialogApp="/Library/Application Support/Dialog/Dialog.app" + dialogUpdate() { # $1: dialog command local dcommand="$1" @@ -26,8 +31,8 @@ if [[ $DEBUG -eq 0 && $(id -u) -ne 0 ]]; then fi # check for Swift Dialog -if [[ ! -x $dialog ]]; then - echo "Cannot find dialog at $dialog" +if [[ ! -d $dialogApp ]]; then + echo "Cannot find dialog at $dialogApp" exit 95 fi @@ -36,6 +41,7 @@ fi dialogUpdate "progress: complete" dialogUpdate "progresstext: Done" +# pause a moment sleep 0.5 dialogUpdate "quit:" @@ -43,4 +49,6 @@ dialogUpdate "quit:" # just to be safe killall "Dialog" +# the killall command above will return error when Dialog is already quit +# but we don't want that to register as a failure in Jamf, so always exit 0 exit 0