Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version check to dialogCheck, Split out install to new function #67

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions Setup-Your-Mac-via-Dialog.bash
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -362,23 +362,17 @@ toggleJamfLaunchDaemon
# Pre-flight Check: Validate / install swiftDialog (Thanks big bunches, @acodega!)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

function dialogCheck() {

# Output Line Number in `verbose` Debug Mode
if [[ "${debugMode}" == "verbose" ]]; then updateScriptLog "PRE-FLIGHT CHECK: # # # SETUP YOUR MAC VERBOSE DEBUG MODE: Line No. ${LINENO} # # #" ; fi
function dialogInstall() {

# Get the URL of the latest PKG From the Dialog GitHub repo
dialogURL=$(curl --silent --fail "https://api.github.com/repos/bartreardon/swiftDialog/releases/latest" | awk -F '"' "/browser_download_url/ && /pkg\"/ { print \$4; exit }")

# Expected Team ID of the downloaded PKG
expectedDialogTeamID="PWA5E9TQ59"

# Check for Dialog and install if not found
if [ ! -e "/Library/Application Support/Dialog/Dialog.app" ]; then

updateScriptLog "PRE-FLIGHT CHECK: Dialog not found. Installing..."
updateScriptLog "PRE-FLIGHT CHECK: Installing SwiftDialog..."

# Create temporary working directory
# Create temporary working directory
workDirectory=$( /usr/bin/basename "$0" )
tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" )

Expand Down Expand Up @@ -409,19 +403,40 @@ function dialogCheck() {
# Remove the temporary working directory when done
/bin/rm -Rf "$tempDirectory"

}



function dialogCheck() {

# Output Line Number in `verbose` Debug Mode
if [[ "${debugMode}" == "verbose" ]]; then updateScriptLog "PRE-FLIGHT CHECK: # # # SETUP YOUR MAC VERBOSE DEBUG MODE: Line No. ${LINENO} # # #" ; fi

# Check for Dialog and install if not found
if [ ! -e "/Library/Application Support/Dialog/Dialog.app" ]; then

updateScriptLog "PRE-FLIGHT CHECK: swiftDialog not found. Installing..."
dialogInstall

else

updateScriptLog "PRE-FLIGHT CHECK: swiftDialog version $(/usr/local/bin/dialog --version) found; proceeding..."
dialogVersion=$(/usr/local/bin/dialog --version)
if [[ "${dialogVersion}" < "2.2.0.4535" ]]; then

updateScriptLog "PRE-FLIGHT CHECK: swiftDialog version ${dialogVersion} found but swiftDialog 2.2 or newer is required; updating..."
dialogInstall

else

updateScriptLog "PRE-FLIGHT CHECK: swiftDialog version ${dialogVersion} found; proceeding..."

fi

fi

}

if [[ ! -e "/Library/Application Support/Dialog/Dialog.app" ]]; then
dialogCheck
else
updateScriptLog "PRE-FLIGHT CHECK: swiftDialog version $(/usr/local/bin/dialog --version) found; proceeding..."
fi
dialogCheck



Expand Down