Samba server and MacOS client

In order to setup a samba server, you can follow the RaspberryPi guide for it.

Make sure to add permissions to the shared folder on the server, so that the SMB daemon will have permissions to write on it.

In addition, I found that when mounting the share on a MacOS computer, there were weird errors about files being in use and the like. The problem is that MacOS Finder adds a special .DS_Store file to every folder and it produced a conflict when updating the contents of the file.

In order to solve it, just add this to your share:

veto files = /._*/.DS_Store/.Trashes/.TemporaryItems/

delete veto files = yes

The second line allows vetoed files to be deleted. Otherwise, already existing vetoed files would be stuck on the drive. (Note that “._*” prevents HFS+/APFS extended attributes from being stored on the SMB drive.)

From now on, .DS_Store and other conflicting files will not be created on the server.

Rclone for Dropbox on RaspberryPi (and other headless server)

Dropbox does not maintain their client for RaspberryPi, so you should find other ways to use it. There are some non-official clients, but I prefer using rclone, since it allows some interesting features for me:

  • Mount the remote as a local filesystem. This way I can expose a single Dropbox account to multiple users, for example, using the mounted Dropbox folder as an external storage in a Nextcloud server.
  • Sync files from and to Dropbox with different parameters, like limited bandwidth, parallel requests, etc.
  • It allows configuring the number of concurrent request to the remote, so you can speed up or reduce it accordingly to your requirements. In the case of Dropbox, a limit of 8-10 concurrent requests is enough to keep down the limit.

There is a guide on the rclone web site on how to configure a Dropbox remote, by creating a new Dropbox App. Follow the guidelines there but do not complete the authorization stage.

For a headless server the process is a little bit more tricky and requires you create a remote SSH tunnel to redirect a local port to your desktop running the ssh client. This way you will be able to run the OAuth2 workflow and authorize your remote headless server to access your Dropbox account.

In your desktop (or client) computer, run:

ssh -L localhost:53682:localhost:53682 your-user-name@your-remote-server.example.com

It will then open a session to your remote server that will tunnel requests on port 53682 to your desktop computer on port 53682.

Then run the following command on the remote-server:

rclone config reconnect remote-name:

Make sure you include the semicolon at the end, or rclone will complain. Here it is a sample of the output:

Already have a token - refresh?
y) Yes (default)
n) No
y/n> y

Use web browser to automatically authenticate rclone with remote?
 * Say Y if the machine running rclone has a web browser you can use
 * Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.

y) Yes (default)
n) No
y/n> y

2024/04/13 16:45:53 NOTICE: Make sure your Redirect URL is set to "http://localhost:53682/" in your custom config.
2024/04/13 16:45:53 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=nqmnwer1qn1m3n41m22n3413
2024/04/13 16:45:53 NOTICE: Log in and authorize rclone for access
2024/04/13 16:45:53 NOTICE: Waiting for code...

The command does not finish and it is waiting for you to complete the authorization flow on your desktop computer.

Now copy the URL that shows in the output and paste it in to a browser on your desktop computer: http://127.0.0.1:53682/auth?state=nqmnwer1qn1m3n41m22n3413

It will redirect you to a Dropbox Oauth screen. Log in, and then review the notice that shows about the authorization you are giving.

Once you complete the authorization, the access code is automatically fed into rclone configuration. If you have a look at the command on your remote server, you will see the rclone command has completed with a message like:

2024/04/13 16:45:53 NOTICE: Make sure your Redirect URL is set to "http://localhost:53682/" in your custom config.
2024/04/13 16:45:53 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=y01AK5m1jqC22vEm9DsMlw
2024/04/13 16:45:53 NOTICE: Log in and authorize rclone for access
2024/04/13 16:45:53 NOTICE: Waiting for code...
2024/04/13 16:46:13 NOTICE: Got code