Posted on 09-17-2018 03:50 AM
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
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
Posted on 09-17-2018 04:34 AM
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...
Posted on 09-17-2018 05:36 AM
@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
Posted on 09-17-2018 06:25 AM
# 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
Posted on 09-17-2018 08:12 AM
No luck, sorry
Posted on 09-17-2018 11:10 AM
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"