setup-your-mac / Setup-Your-Mac

Setup Your Mac aims to simplify initial device configuration by leveraging swiftDialog and Jamf Pro Policy Custom Events to allow end-users to self-complete Mac setup post-enrollment.
https://snelson.us/sym
MIT License
238 stars 52 forks source link

Feature Request : Add this in to built in feature for the swiftdialog install where Github restricted environment #92

Closed mani2care closed 11 months ago

mani2care commented 11 months ago

Hi Dan,

In my organization, internet services are disabled, preventing me from downloading GitHub packages to Mac devices. Therefore, I attempted customization to download 'swiftdialog.app' from Jamf when the GitHub download failed.

Please find the script below and consider adding this as a new feature. It can be used when needed, reducing the likelihood of failure.


jamfBinary="/usr/local/bin/jamf"
dialoginstall="dialoginstaller" #package event name must be defined

function dialogInstall() {

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

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

    updateScriptLog "PRE-FLIGHT CHECK: Installing swiftDialog..."

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

        # Download the installer package
        /usr/bin/curl --location --silent "$dialogURL" -o "$tempDirectory/Dialog.pkg"

        # Verify the download
        teamID=$(/usr/sbin/spctl -a -vv -t install "$tempDirectory/Dialog.pkg" 2>&1 | awk '/origin=/ {print $NF }' | tr -d '()')

        # Install the package if Team ID validates
        if [[ "$expectedDialogTeamID" == "$teamID" ]]; then

            /usr/sbin/installer -pkg "$tempDirectory/Dialog.pkg" -target /
            sleep 2
            dialogVersion=$( /usr/local/bin/dialog --version )
            updateScriptLog "PRE-FLIGHT CHECK: swiftDialog version ${dialogVersion} installed; proceeding..."

        else
                updateScriptLog "PRE-FLIGHT CHECK: Dialog is not installed, attempting to install..."
                # Attempt to install "dialog" using Jamf
                #sudo jamf policy -event "$dialoginstall"
                eval "${jamfBinary} policy -event ${dialoginstall}"
                if [ $? -eq 0 ]; then
                updateScriptLog "PRE-FLIGHT CHECK: swiftDialog version ${dialogVersion} installed success; proceeding..."
        else
                echo "Policy installation and validation failed."
                # Display a so-called "simple" dialog if Team ID fails to validate
                osascript -e 'display dialog "Please advise your Support Representative of the following error:\r\r• Dialog Team ID verification failed\r\r" with title "Setup Your Mac: Error" buttons {"Close"} with icon caution'
                completionActionOption="Quit"
                exitCode="1"
                quitScript
            fi
        fi
dan-snelson commented 11 months ago

@mani2care:

This appears to be a solution in search of a problem; can't you just add your preferred swiftDialog .PKG to the Packages payload in your Jamf Pro policy?

mani2care commented 11 months ago

Im packaged and uploaded to JAMF. Only calling and installing the package when it’s necessary.

problem ) if I define this package as first to install & every trigger the package will call and install even though swiftdialog already exists the same version. And time delay for the installation and installing every time.

Solution ) just define the custom name and call the policy or package to install if the GitHub installation is failed. So I no need to install every device.

My company it’s restructured the GitHub download and my case it’s working well.

On Wed, 30 Aug 2023 at 5:39 PM, Dan K. Snelson @.***> wrote:

@mani2care https://github.com/mani2care:

This appears to be a solution in search of a problem; can't you just add your preferred swiftDialog .PKG to the Packages payload in your Jamf Pro policy?

— Reply to this email directly, view it on GitHub https://github.com/dan-snelson/Setup-Your-Mac/issues/92#issuecomment-1699044410, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMUGJU3SFBW4CDZIPA3IB63XX4UPTANCNFSM6AAAAAA4EGANSQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Thanks & Regards,

Manikandan R Contact: +91-9902103878 E-mail: @.***

dan-snelson commented 11 months ago

Are you saying the following, already included function is not working for your use-case?

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

        dialogVersion=$(/usr/local/bin/dialog --version)
        if [[ "${dialogVersion}" < "2.3.1.4721" ]]; then

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

        else

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

        fi

    fi

}
mani2care commented 11 months ago

Yes, it works! But from protected network not working url blocked by firewall from my end.

On Wed, 30 Aug 2023 at 6:14 PM, Dan K. Snelson @.***> wrote:

Are you saying the following, already included function is not working for your use-case?

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

    dialogVersion=$(/usr/local/bin/dialog --version)
    if [[ "${dialogVersion}" < "2.3.1.4721" ]]; then

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

    else

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

    fi

fi

}

— Reply to this email directly, view it on GitHub https://github.com/dan-snelson/Setup-Your-Mac/issues/92#issuecomment-1699101263, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMUGJU5XA5JSQP64KC7TCLTXX4YUFANCNFSM6AAAAAA4EGANSQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Thanks & Regards,

Manikandan R Contact: +91-9902103878 E-mail: @.***

dan-snelson commented 11 months ago

Thanks for confirming; then where is installing the .PKG as part of your Jamf Pro policy not working?

mani2care commented 11 months ago

Please find this I have modified your script and it’s working fine for me as expected here I’m asking you to add this feature to SYM script.

*else updateScriptLog "PRE-FLIGHT CHECK: Dialog is not installed, attempting to install..."

Attempt to install "dialog" using Jamf

            #sudo jamf policy -event "$dialoginstall"
            eval "${jamfBinary} policy -event ${dialoginstall}"
            if [ $? -eq 0 ]; then
            updateScriptLog "PRE-FLIGHT CHECK: swiftDialog version

${dialogVersion} installed success; proceeding..." else**

On Wed, 30 Aug 2023 at 6:32 PM, Dan K. Snelson @.***> wrote:

Thanks for confirming; then where is installing the .PKG as part of your Jamf Pro policy not working?

— Reply to this email directly, view it on GitHub https://github.com/dan-snelson/Setup-Your-Mac/issues/92#issuecomment-1699127078, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMUGJU2GEVNTH5D2DUMWXNTXX42VXANCNFSM6AAAAAA4EGANSQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Thanks & Regards,

Manikandan R Contact: +91-9902103878 E-mail: @.***

dan-snelson commented 11 months ago

@mani2care:

Thanks for the additional details.

Again, this appears to be a solution in search of a problem.

With the approach shown above, how will new admins demo SYM?

(Closing as not planned.)