How to change the Dropbox default directory location

As stated in the Dropbox documentation, is not a good idea to use it over a mounted partition. This is a problem in case your /home doesn’t reside physically on your host. In this post I will show how to change the Dropbox default directory location. I did it on CentOS7 and I guess that can work on Fedora and also on Debian based OS (I’m assuming that you are using a 64bit device).

Choose the new destination

I choose to store my Dropbox files in the /media folder. Prepare your new home executing those commands:

sudo mkdir -p /media/dropbox-youruser/
sudo chown youruser /media/dropbox-youruser/
sudo chmod 700 /media/dropbox-youruser/

Install Dropbox

Dropbox will be installed in the /opt directory

cd /tmp/
curl -Lo dropbox-linux-x86_64.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64
sudo mkdir -p /opt/dropbox
sudo tar xzfv dropbox-linux-x86_64.tar.gz --strip 1 -C /opt/dropbox

Now we need to run manually the dropbox deamon for the first time in order to authenticate it.

export HOME=/media/dropbox-youruser/; /opt/dropbox/dropboxd

Insert you Dropbox user and password in the browser, done!
Now you know the trick, changing the env var HOME to our new location allow us to play Dropbox.

Keep it syncing at each startup

That’s not the end! Unless if you want to run manually the daemon at each startup! Dropbox comes with the option:

☐ Start Dropbox on System startup

But this will not fetch the proper env home We will create instead a systemd deamon to keep it alive

sudo vim /etc/systemd/system/dropbox.service
[Unit]
Description=Dropbox daemon

After=syslog.target network.target sockets.target


[Service]
Restart=always

Environment=HOME=/media/dropbox-youruser/


ExecStart=/opt/dropbox/dropboxd

Save and quit then:

sudo systemctl daemon-reload
sudo systemctl start dropbox

Then run this command to configure the service to start when your device boots:

sudo systemctl enable dropbox

Discovering Jekyll

I decided to give a chance to Jekyll after I realized that you can deploy it for free on Github! This is also my first post on this blog, I would report here the procedure I did to start with Jekyll. This will be useful when I will write the second post!

The Jekyll environment

I created a Docker image to recreate the develompent environment every time.
I know, there is already an Offcial Jekyll Docker image but it’s so heavy!
I created a Dockerfile starting from Alpine:

FROM alpine:3.7

LABEL maintainer="marco.bore@gmail.com"


RUN apk add --update curl vim \

    build-base \
    python \
    libxslt-dev libffi-dev \
    ruby-dev ruby-io-console ruby-irb ruby-json ruby-rake \
    && gem install --no-document jekyll bundle

EXPOSE 4000

The last line is the most important:

  • allows you to connect to the container throught port 4000.

Build and run the container

When I have more that 3 docker options I usually create a run.sh file.

#!/bin/bash

echo 'Building container...'
docker build -t cnt-jekyll .
docker run -it --rm \

   --name=jekyll \

   -v `pwd`/file:/file \

   -w "/file" \

   -h jekyll \

   cnt-jekyll \

   /bin/sh

The most important parameter is:

  • -v that mount the local ./file/ directory inside the container You can now develop your Jekyll website in this directory without loosing your work in case the container stops.

Serve Jekyll

bundle install
bundle exec jekyll serve --host 0.0.0.0 

Pleaset notice that if you don’t specify the --host option, you will reach Jekyll just from the container inside.

You can now reach Jekyll typing in the browser jekyll.ip.inthe.dockerbridge:4000

My personal impression

Pro:

  • At every change the static website is rebuild
  • Is easy to understart the content structure

Contra:

  • Why I need to install python to use pygments?
  • I took some time to get Jekyll up and running