Skip to main content
Question

Dockutil - hidden smb share

  • September 17, 2018
  • 5 replies
  • 25 views

Forum|alt.badge.img+3

Has anyone used dockutil to mount a hidden SMB share

Using the $ to define the hidden share in the script is causing issues, is there another way to do this?

I have pasted the script in below

!/bin/bash

sleep 10

username=defaults read /Library/Preferences/com.apple.loginwindow.plist lastUserName

configureDefaultDock() {

if [ -e /usr/local/bin/dockutil ];
then

su $username -c '/usr/local/bin/dockutil --add smb://afpserver.college.farnborough/$username$ --label "My Media Drive" --position end'

else echo "dockutil not installed, skipping initial dock setup..."
fi

}

configureDefaultDock

exit 0

5 replies

dsavageED
Forum|alt.badge.img+8
  • New Contributor
  • September 17, 2018

I don't have time to check at the moment but i'd suspect something like:

su $username -c '/usr/local/bin/dockutil --add "smb://afpserver.college.farnborough/${username}$" --label "My Media Drive" --position end'

Note too that your label won't stick, it will likely link as "${username}$", if it links...

If it doesn't then linking to the mount point might be the next best option:

su $username -c '/usr/local/bin/dockutil --add "/Volumes/${username}$" --label "My Media Drive" --position end'

Again the label won't stick...


Forum|alt.badge.img+7
  • Contributor
  • September 17, 2018

@dsavageED Thanks. Unfortunately neither worked. I understand the second option would only work if the volume is mounted which it wont be at the time.

Thanks

Joe


Forum|alt.badge.img+19
  • Contributor
  • September 17, 2018
# dockutil --add <path to item> | <url> [--label <label>] [ folder_options ] [ position_options ] [--no-restart] [ plist_location_specification ]

/usr/local/bin/dockutil --add smb://afpserver.college.farnborough/$username$ --label "My Media Drive" --position end /Users/$username/Library/Preferences/com.apple.dock.plist

Source:
https://github.com/kcrawford/dockutil


Forum|alt.badge.img+7
  • Contributor
  • September 17, 2018

@ryan.ball

No luck, sorry


Forum|alt.badge.img+19
  • Contributor
  • September 17, 2018

Quoting might help

loggedInUser=$(/usr/bin/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 + "
");')
userHome=$(/usr/bin/dscl . read "/Users/$loggedInUser" NFSHomeDirectory | awk '{print $NF}')

/usr/local/bin/dockutil --add "smb://afpserver.college.farnborough/$loggedInUser" --label "My Media Drive" --position end "$userHome/Library/Preferences/com.apple.dock.plist"