microsoft / shell-intune-samples

Sample shell scripts for Intune admins.
MIT License
670 stars 222 forks source link

Function "waitForProcess" require improvement #19

Closed 3apa3a-b-ta3e closed 3 years ago

3apa3a-b-ta3e commented 3 years ago

Currently it uses this check to determinate if process is running or not ps aux | grep "$processName" | grep -v grep which is generally fine, but when it checks for just curl there might be issues, coz other processes (like Google Drive) may use same word curl in their full command line, so script will never ends waiting for curl exit :-(

3apa3a-b-ta3e commented 3 years ago

Well, actually we can fix it by passing /curl to that function (inside downloadApp)

theneiljohnson commented 3 years ago

Hmm, that's interesting, can you share the output from ps aux | grep "curl" with Google Drive running?

3apa3a-b-ta3e commented 3 years ago

It produced A LOT of output, but source of my issue is here /Applications/Google Drive.app/Contents/MacOS/crashpad_handler --annotation=curl_proxy_authentication=on (to be honest - there is much more cli options, just posting relevant one)

theneiljohnson commented 3 years ago

Thanks, i'll take a look tomorrow and see if I can make it a little more robust.

theneiljohnson commented 3 years ago

I've pushed out some updates. I've basically just changed the grep to look for 'curl -f' which should appear on all of the download calls from these scripts.

I've tested against Google Drive and it seems to behave. Let me know if you have any issues and thanks for bringing it to my attention.