Skip to main content
Question

Dropbox Symlinks

  • April 16, 2020
  • 4 replies
  • 10 views

Forum|alt.badge.img+7

Hi,

We are using Dropbox and i'm looking for a way to redirect the user folders like Documents etc to redirect to Dropbox.
This makes sure that user folders are always synced and available if something happens to their laptop.
Anyone has some ideas how to achieve this?

4 replies

mark_mahabir
Forum|alt.badge.img+15
  • Jamf Heroes
  • 337 replies
  • April 16, 2020

Have a look here


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 69 replies
  • April 17, 2020

thanks for the blog post.
Will be testing this and hopefully post a working solution


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 69 replies
  • April 17, 2020

Replace by new reply... see below


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 69 replies
  • April 17, 2020

Couple of little changes made it better.
But now I have to go to the Finder Preferences to enable the desktop, etc again.
Anyone has an easy fix for that?
Another thing I need to build in, is if a user runs this on a new laptop it should keep the files on Dropbox and copy anything that is in the local desktop to Dropbox again.
'mv' doesn't seems to be able to do that, any options for that? (maybe: if target exists; then rsync source target, remove source ??)

Set Dropbox Folder

DBCompany="$4"
DBFolder="Dropbox ("$4")"

Find the user

consoleuser=$(/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 + " ");')

Create Folder to store Home folders

mkdir "/Users/$consoleuser/$DBFolder/LocalMac"
chown -R $consoleuser "/Users/$consoleuser/$DBFolder/LocalMac"

Moving folders

mv "/Users/$consoleuser/Desktop" "/Users/$consoleuser/$DBFolder/LocalMac"
mv "/Users/$consoleuser/Documents" "/Users/$consoleuser/$DBFolder/LocalMac"

Create links

ln -s "/Users/$consoleuser/$DBFolder/LocalMac/Desktop" "/Users/$consoleuser/Desktop"