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
249 stars 55 forks source link

policies spelt wrong (twice) and "# Remove custom welcomeBannerImageFileName" has a bug if welcomeDialog is false. #134

Closed Honestpuck closed 8 months ago

Honestpuck commented 8 months ago

Before submitting a Setup Your Mac bug report, please review the open swiftDialog issues to help determine the source of the issue.

Describe the bug policies is spelt 'polcies' in two strings. Do a search and replace :)

If you are running with welcomeDialog set to false the script attempts to remove a non-existent welcomeBannerImageFileName and fails

    # Remove custom welcomeBannerImageFileName
    if [[ -e "/var/tmp/${welcomeBannerImageFileName}" ]]; then
        updateScriptLog "COMPLETION ACTION: Removing /var/tmp/${welcomeBannerImageFileName} …"
        rm "/var/tmp/${welcomeBannerImageFileName}"

This has output of:

2024-01-23 16:53:56 - COMPLETION ACTION: Removing /var/tmp/ …
rm: /var/tmp/: is a directory

The problem is that when the variable is empty the -e test is testing for the existence of var/tmp/ which is true but then the rm command attempts to remove /var/tmp and fails, giving the error seen.

To Reproduce Set "welcomeDialog" to false

Expected behavior The routine to remove the file would not run.

Environment (please complete the following information):

Additional context This code works:

    # Remove custom welcomeBannerImageFileName
    if [[ "${welcomeBannerImageFileName}" != "" ]]; then
        updateScriptLog "COMPLETION ACTION: Removing /var/tmp/${welcomeBannerImageFileName} …"
        rm "/var/tmp/${welcomeBannerImageFileName}"
    fi

It would also work if you changed the -e (does it exist) to -f (is it a file) but I prefer the more explicit check.

dan-snelson commented 8 months ago

Thanks for the heads-up, @Honestpuck; I'll take a look.

dan-snelson commented 8 months ago

@Honestpuck:

While I did find two misspellings, I was unable to replicate the removal error with SYM 1.14.0:

2024-01-23 07:29:31 - # # # SETUP YOUR MAC VERBOSE DEBUG MODE: Line No. 2686 # # #
2024-01-23 07:29:31 - QUIT SCRIPT: Exiting …
2024-01-23 07:29:31 - QUIT SCRIPT: De-caffeinate …
2024-01-23 07:29:31 - The 'caffeinate' process isn't running.
2024-01-23 07:29:31 - QUIT SCRIPT: Removing /var/tmp/dialogCommandFileWelcome.3k5 …
2024-01-23 07:29:31 - QUIT SCRIPT: Removing /var/tmp/dialogCommandFileSetupYourMac.Loh …
2024-01-23 07:29:31 - QUIT SCRIPT: Removing /var/tmp/dialogCommandFileFailure.lP3 …
2024-01-23 07:29:31 - QUIT SCRIPT: Removing default dialog file …
2024-01-23 07:29:31 - QUIT SCRIPT: Executing Completion Action Option: 'Restart Attended' …
2024-01-23 07:29:31 - # # # SETUP YOUR MAC VERBOSE DEBUG MODE: Line No. 2218 # # #
2024-01-23 07:29:31 - Run "osascript -e display dialog "Setup Your Mac is operat" with title "Setup Your Mac: Debug Mode" buttons {"Close"} with icon note" as "501" … 
button returned:Close
2024-01-23 07:29:33 - COMPLETION ACTION: Removing /var/tmp/green-abstract-geometric-wallpaper_52683-29623.jpg …
2024-01-23 07:29:33 - COMPLETION ACTION: Removing /var/tmp/overlayicon.icns …
Dans-143-SYM:tmp root# 
Honestpuck commented 8 months ago

Did you set $welcomeDialog to false and not set welcomeBannerImageFileName ? It looks like you had welcomeBannerImageFileName set to green-abstract-geometric-wallpaper_52683-29623.jpg which would not trigger the bug. It has to be empty.

dan-snelson commented 8 months ago

@Honestpuck:

The only change I made was: welcomeDialog="${6:-"false"}"

(I want the banner image in the main SYM dialog.)

Honestpuck commented 8 months ago

It popped up again today. I will see if I can replicate exactly what happened. I think it has something to do with the images when you have welcomeDialog set to false. I'm back working on SYM full time now.

On Wed, Jan 24, 2024 at 12:15 AM Dan K. Snelson @.***> wrote:

@Honestpuck https://github.com/Honestpuck:

The only change I made was: welcomeDialog="${6:-"false"}"

— Reply to this email directly, view it on GitHub https://github.com/setup-your-mac/Setup-Your-Mac/issues/134#issuecomment-1906038226, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZIRBOF265GPZJ62CVRCALYP6ZXPAVCNFSM6AAAAABCGNLD4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWGAZTQMRSGY . You are receiving this because you were mentioned.Message ID: @.***>

dan-snelson commented 8 months ago

Addressed in SYM 1.14.0.