grahampugh / erase-install

A script that automates downloading macOS installers, and optionally erasing or upgrading macOS in a single process. Watch the video!
https://grahamrpugh.com/2023/05/14/macaduk-presentation-eraseinstall.html
Apache License 2.0
834 stars 131 forks source link

Problems with argument parsing in script (from Jamf Pro) #499

Closed Theile closed 4 months ago

Theile commented 5 months ago

Describe the bug and To Reproduce I have imported the script to Jamf Pro, and made a policy with various parameters in the call: --reinstall --max-password-attempts=infinite --fs --cleanup-after-use --check-power --power-wait-limit 3600

And also this parameter in another test: --pkg

First this error happened: /Library/Application Support/JAMF/tmp/erase-install.sh:2713: bad math expression: operator expected at `infinite'

So I added an echo command above line 2713 so that it would echo the value so I could see it, but then it worked: echo "new_max_password_attempts: $new_max_password_attempts"

Then I got this error: check_power_status:36: bad math expression: operator expected at `1800'

I remember seeing before that numbers was seen as text, so I added these two lines above the failing line: ((power_wait_timer++)) ((power_wait_timer--))

Expected behavior I have followed the description here: https://github.com/grahampugh/erase-install/wiki/6.-Use-in-Jamf-Pro#option-2-upload-erase-installsh-into-jamf-pro-and-use-policy-script-parameters

Code/log output I don't want to ignore anything and have supplied all arguments used in the call above. So I think the above lines and my workarounds should be enough, as the failing was in handling of variables in the script.

Environment (please complete the following information):

grahampugh commented 5 months ago

Hi Theile If you're using Jamf policy parameters, you need a equals sign for any values, so this is bad syntax:

--power-wait-limit 3600

It needs to be:

--power-wait-limit=3600

That could break the reading of the other parameters, so could you correct that and try again.

Theile commented 5 months ago

Oh, thanks. Will test tomorrow!

Theile commented 5 months ago

It worked. I was honestly puzzled from the wiki if I should use the equal sign or not.

This wiki page: https://github.com/grahampugh/erase-install/wiki/4.-Upgrading-or-reinstalling-macOS-without-wiping-the-system Uses both semantics in this paragraph: https://github.com/grahampugh/erase-install/wiki/4.-Upgrading-or-reinstalling-macOS-without-wiping-the-system#--min-drive-space-nn

How can I prevent mist from being downloaded? We do not have that tool approved, so have to avoid it. Do I need to use --ffi rather than --pkg?

Theile commented 5 months ago

You, seems to be my answer ;-)

grahampugh commented 5 months ago

https://github.com/grahampugh/erase-install/wiki/6.-Use-in-Jamf-Pro explains how to use it in Jamf.

Yes you would have to use --ffi if you want to avoid using Mist.