script to mount shared files on mac with OS Monterey

pollokd
New Contributor

I am looking to update our script which mounts shared files using Monterey.  I believe the issue is python being out of date - any suggestions would be helpful.  Here is our current script for Big Sur... 

 

#!/bin/sh

LoggedInUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')

su "$LoggedInUser" -c '/usr/local/bin/dockutil --add smb://fs1.vcs.local/Shared\ Files --label 'Shared Files' --position end'

 

If this is not where this post belongs, please let me know

2 REPLIES 2

a_hebert
Contributor

Try this 

 

#!/bin/sh

LoggedInUser=$(ls -l /dev/console | cut -d " " -f4)

su "$LoggedInUser" -c '/usr/local/bin/dockutil --add smb://fs1.vcs.local/Shared\ Files --label 'Shared Files' --position end'

Bol
Valued Contributor

If you are using the latest dockutil package (rebuilt in swift) which removes python dependancy, try dropping the su to impersonate the logged in user.

I found updating their dock plist alone, was what now worked for me.

https://community.jamf.com/t5/jamf-pro/dockutil-script-revised-for-monterey/m-p/263826/highlight/tru...