Difference between revisions of "Dropbox"

From ArchWiki
Jump to: navigation, search
(Move to sub category.)
(dropbox binary not in /usr/bin, for processes to background)
(46 intermediate revisions by 27 users not shown)
Line 1: Line 1:
 
[[Category:Internet Applications]]
 
[[Category:Internet Applications]]
 +
[[de:Dropbox]]
 
[[it:Dropbox]]
 
[[it:Dropbox]]
 +
[[ru:Dropbox]]
 
[[zh-TW:Dropbox]]
 
[[zh-TW:Dropbox]]
[https://www.dropbox.com Dropbox] is a file sharing system that recently introduced a GNU/Linux client.  Use it to transparently sync files across computers and architectures. Simply drop files into your {{ic|~/Dropbox}} folder, and they will automatically sync to your centralized repository.
+
[https://www.dropbox.com Dropbox] is a file sharing system that recently introduced a GNU/Linux client.  Use it to transparently sync files across computers and architectures. Simply drop files into your {{ic|~/Dropbox}} folder, and they will automatically sync to your centralized repository.
  
==Installation==
+
== Installation ==
  
 
{{AUR|dropbox}} can be installed from the [[Arch User Repository|AUR]]. Alternatively, {{AUR|dropbox-experimental}} is also available.
 
{{AUR|dropbox}} can be installed from the [[Arch User Repository|AUR]]. Alternatively, {{AUR|dropbox-experimental}} is also available.
  
 
# After installing the package, you can start Dropbox from your application menu or run {{ic|dropboxd}} from the command-line. The client icon will appear in the system tray.
 
# After installing the package, you can start Dropbox from your application menu or run {{ic|dropboxd}} from the command-line. The client icon will appear in the system tray.
 +
# A pop-up will notify you that Dropbox is running from an unsupported location. Click on Don't ask again since you know that you have installed it from AUR rather than from the official homepage.
 
# Eventually a pop-up will ask you to log in to your Dropbox account or create a new account. Enter your credentials.
 
# Eventually a pop-up will ask you to log in to your Dropbox account or create a new account. Enter your credentials.
 
# After some time you will see a "Welcome to Dropbox" pop-up, which will give you the opportunity to view a short tour of Dropbox.
 
# After some time you will see a "Welcome to Dropbox" pop-up, which will give you the opportunity to view a short tour of Dropbox.
 
# Press the "Finish and go to My Dropbox".
 
# Press the "Finish and go to My Dropbox".
  
For [[KDE]] users, no further steps are required (it is enough to install the above {{AUR|dropbox}} package from the AUR), as KDE saves running applications when logging out and restarts them automatically.
+
For [[KDE]] users, no further steps are required (it is enough to install the above {{AUR|dropbox}} package from the AUR), as KDE saves running applications when logging out and restarts them automatically. Similarly for [[Xfce]] users, dropbox will be restarted automatically next time you login since the {{ic|dropbox.desktop}} file be placed in {{ic|~/.config/autostart}}.
  
===Optional packages===
+
=== Optional packages ===
  
*For a command-line interface, install {{AUR|dropbox-cli}} from the [[Arch User Repository|AUR]].
+
*For a command-line interface, install {{AUR|dropbox-cli}} from the [[AUR]].
 
*For integration with Nautilus, install {{AUR|nautilus-dropbox}} from the AUR. The Nautilus plugin will start Dropbox automatically.
 
*For integration with Nautilus, install {{AUR|nautilus-dropbox}} from the AUR. The Nautilus plugin will start Dropbox automatically.
 +
*For integration with Nemo, install {{AUR|nemo-dropbox-git}} from the AUR.
 
*For integration with [[Thunar]], install {{AUR|thunar-dropbox}} from the AUR.
 
*For integration with [[Thunar]], install {{AUR|thunar-dropbox}} from the AUR.
 
*For [[KDE]] users, there is a KDE client available: {{AUR|kfilebox}} from the AUR.
 
*For [[KDE]] users, there is a KDE client available: {{AUR|kfilebox}} from the AUR.
  
===Automatically Starting Dropbox===
+
=== Automatically starting Dropbox ===
  
Dropbox can be automatically started by adding {{Ic|dropboxd}} to {{ic|~/.xinitrc}} (or {{ic|~/.config/openbox/autostart}}, depending on your setup). Alternatively, you can [[#Daemon|start it as a daemon]].
+
Dropbox can be automatically started by adding {{Ic|dropboxd}} to {{ic|~/.xinitrc}} (or {{ic|~/.config/openbox/autostart}}, depending on your setup). Alternatively, you can [[#Run as daemon with systemd|start it as a daemon]].
  
 
== Alternative to install: use the web interface ==
 
== Alternative to install: use the web interface ==
Line 30: Line 34:
 
If all you need is basic access to the files in your Dropbox, you can use the web interface at https://www.dropbox.com/ to upload and download files to your Dropbox. This can be a viable alternative to running a Dropbox daemon and mirroring all the files on your own machine.
 
If all you need is basic access to the files in your Dropbox, you can use the web interface at https://www.dropbox.com/ to upload and download files to your Dropbox. This can be a viable alternative to running a Dropbox daemon and mirroring all the files on your own machine.
  
==Daemon==
+
== Run as daemon with systemd ==
  
To run Dropbox as a daemon similarly to {{Ic|sshd}} or {{Ic|vsftpd}}, simply do one of the following:
+
Recent versions of Dropbox come with a systemd service file. By default running Dropbox as a daemon does not give you an icon in the system tray, but syncs your files and folders in the background. If you want to have tray support, then you have to copy the service file to {{ic|/etc/systemd/system/dropbox@.service}} and add the environment variable.
  
===dropbox-daemon Method===
+
# echo ".include /usr/lib/systemd/system/dropbox@.service
 +
[Service]
 +
Environment=DISPLAY=:0" > /etc/systemd/system/dropbox@.service
  
Install {{AUR|dropbox-daemon}}
+
Finally, to enable the daemon for your user, so that it will start at login:
and configure your username in {{ic|/etc/conf.d/dropboxd.conf}}
+
# systemctl enable dropbox@<user>
 +
Note that you have to manually start Dropbox the first time after installation, so that it runs through the login and setup screen. Further, you need to uncheck the option '''Start Dropbox on system startup''' in order to prevent Dropbox from being started twice. The daemon can then be used subsequently.
  
This allows you to start or stop Dropbox just like any other service.
+
=== Run as a daemon with systemd user ===
  
# /etc/rc.d/dropboxd start
+
If you have followed the [[systemd/User]] wiki page, you probably want to start dropbox only when you log in or launch your WM/DE. The solution in that case is to create a service in your home directory instead of using the sysadmin account:
# /etc/rc.d/dropboxd stop
+
# /etc/rc.d/dropboxd restart
+
  
Place {{Ic|dropboxd}} in the DAEMONS array in {{ic|/etc/rc.conf}} for it to start at boot.:
+
{{hc|$HOME/.config/systemd/user/dropbox@.service|<nowiki>
DAEMONS=(... '''@dropboxd''' ...)
+
[Unit]
 +
Description=Dropbox as a systemd service
 +
After=xorg.target
  
===Manual Method===
+
[Service]
 +
ExecStart=/home/your_user/.dropbox-dist/dropbox
 +
ExecReload=/bin/kill -HUP $MAINPID
 +
Environment=DISPLAY=%i
  
As root, copy this into a file called {{ic|/etc/rc.d/dropboxd}} and set USER to your username.
+
[Install]
 +
WantedBy=mystuff.target
 +
</nowiki>}}
  
{{bc|<nowiki>
+
They you can start or enable it with:
#!/bin/bash
+
  
USER=yourusername
+
$ systemctl --user {start|enable} dropbox@:0.service
  
. /etc/rc.conf
+
That way you can easily start it in your main display (likely :0) or in another one, without having to hard code it.
. /etc/rc.d/functions
+
  
PID=`pidof -o %PPID /opt/dropbox/dropbox`
+
{{Note|After a lot of trial and error I found that using {{ic|/usr/bin/dropboxd}} didn't start the service and it didn't show any error either (even when running it directly from the terminal worked fine). I believe it has to do that starting it that way systemd doesn't know which user is actually running the daemon.}}
  
case "$1" in
+
== Without Nautilus (another way)==
  start)
+
    stat_busy "Starting Dropbox Service"
+
    LANG=$LOCALE
+
    [ -z "$PID" ] && su -c "/usr/bin/dropboxd &" $USER
+
    if [ $? -gt 0 ]; then
+
      stat_fail
+
    else
+
      add_daemon dropboxd
+
      stat_done
+
    fi
+
    ;;
+
  stop)
+
    stat_busy "Stopping Dropbox Service"
+
    [ ! -z "$PID" ] && kill $PID > /dev/null
+
    if [ $? -gt 0 ]; then
+
      stat_fail
+
    else
+
      rm_daemon dropboxd
+
      stat_done
+
    fi
+
    ;;
+
  restart)
+
    $0 stop
+
    sleep 3
+
    $0 start
+
    ;;
+
  *)
+
    echo "usage: $0 {start|stop|restart}"
+
    ;;
+
esac
+
exit 0
+
</nowiki>}}
+
  
An Organized Way:
+
Another way to use Dropbox without Nautilus but with another file manager like Thunar or Pcmanfm is described below:
{{bc|<nowiki>
+
#!/bin/bash
+
  
. /etc/rc.conf
+
1. Create a fake Nautilus script that will launch Thunar:
. /etc/rc.d/functions
+
$ sudo touch /usr/bin/nautilus && sudo chmod +x /usr/bin/nautilus && sudo nano /usr/bin/nautilus
  
USER=yourusername
+
2. Insert this text into the file, then save and exit:
DROPBOXD_PATH='/usr/bin/dropboxd'
+
#!/bin/bash
DROPBOX_PATH='/opt/dropbox/dropbox'
+
exec thunar $2
 +
exit 0
  
PID=`pidof -o %PPID $DROPBOX_PATH`
+
3. Launch Dropbox:
 +
$ dropboxd
  
case "$1" in
+
4. Click on the Dropbox tray icon to open your Dropbox folder in Thunar.
  start)
+
    stat_busy "Starting Dropbox Service"
+
    if [ $USER = 'yourusername' ]; then
+
        echo "Please edit /etc/rc.d/dropboxd' 'USER' before using this script."
+
        stat_fail
+
    else
+
LANG=$LOCALE
+
        [ -z "$PID" ] && su -c "$DROPBOXD_PATH &" $USER
+
        if [ $? -gt 0 ]; then
+
          stat_fail
+
        else
+
          add_daemon dropboxd
+
          stat_done
+
        fi
+
    fi
+
    ;;
+
  stop)
+
    stat_busy "Stopping Dropbox Service"
+
    [ ! -z "$PID" ] && kill $PID > /dev/null
+
    if [ $? -gt 0 ]; then
+
      stat_fail
+
    else
+
      rm_daemon dropboxd
+
      stat_done
+
    fi
+
    ;;
+
  restart)
+
    $0 stop
+
    sleep 3
+
    $0 start
+
    ;;
+
  *)
+
    echo "usage: $0 {start|stop|restart}"
+
    ;;
+
esac
+
exit 0
+
</nowiki>}}
+
  
Make the file executable with
+
{{Note|
# chmod +x /etc/rc.d/dropboxd
+
* In this way there is no need to create a Dropbox daemon in {{ic|/etc/rc.d/}} and to start it at boot via {{ic|/etc/rc.conf}} or to make it start via your session manager: just leave the "Start Dropbox on system startup" option flagged in the Preferences window.
 +
* If you already have Nautilus installed but do not want to use it, don't modify the existing file under {{ic|/usr/bin}}, just change the {{ic|/usr/bin}} for {{ic|/opt/dropbox}} in the step 2 above, like this: {{Ic|$ sudo touch /opt/dropbox/nautilus && sudo chmod +x /opt/dropbox/nautilus && sudo nano /opt/dropbox/nautilus}}. Dropbox will look in this path first!
 +
}}
  
This allows you to start or stop {{Ic|dropboxd}} just like any other service. For example:
+
== Securing your Dropbox ==
  
# /etc/rc.d/dropboxd start
+
If you want to store sensitive data in your Dropbox, you should encrypt it before. Syncing to Dropbox is encrypted, but all files are (for the time being) stored on the server unencrypted just as you put them in your Dropbox.
# /etc/rc.d/dropboxd stop
+
# /etc/rc.d/dropboxd restart
+
  
To start it at boot, add it to your DAEMONS array in rc.conf: {{ic|/etc/rc.conf}}:
+
* Dropbox works with [[TrueCrypt]], and after you initially uploaded the TrueCrypt volume to Dropbox, performance is quite okay, because Dropbox has a working binary diff.
DAEMONS=(... '''@dropboxd''' ...)
+
  
== Systemd ==
+
* Another possibility is to use [[EncFS]], which has the advantage that all files are encrypted separately, i.e. you do not have to determine in advance the size of the content you want to encrypt and your encrypted directory grows and shrinks while you add/delete/modify files in it. You can also mount an encrypted volume at startup using the {{ic|-S}} option of {{Ic|encfs}} to avoid having to input the passphrase, but note that your encrypted files are not secure from someone who has direct access to your computer.
  
Unfortunately, systemd service files cannot read the executable path from the environment. This means configuring the path to the dropbox binary in a .conf file (as done above) will not work.
+
=== Setup EncFS with Dropbox ===
  
However, if you're ok with a little hardcoding...
+
Follow the Wiki instructions to install [[EncFS]].
  
{{hc|/etc/systemd/system/dropboxd.service|<nowiki>
+
Assuming you have set your Dropbox directory as {{ic|~/Dropbox}}:
[Unit]
+
Description=Dropbox
+
After=local-fs.target network.target
+
  
[Service]
+
Create a folder.  Files you want synced to Dropbox will go in here.
User=your-username
+
$ mkdir ~/Private
ExecStart=/path/to/dropboxd
+
  
[Install]
+
Run the following and enter a password when asked:
WantedBy=multi-user.target
+
$ encfs ~/Dropbox/Encrypted ~/Private
</nowiki>}}
+
  
Start it
+
Your secure folder is ready for use; creating any file inside {{ic|~/Private}} will automatically encrypt it into {{ic|~/Dropbox/Encrypted}}, which will then be synced to your cloud storage.
# systemctl start dropboxd.service
+
  
Enable it at boot
+
To mount your EncFS folder on every boot, follow the instructions in the [[EncFS#User_friendly_mounting|EncFS]] wiki page.
# systemctl enable dropboxd.service
+
  
If you want to start dropbox only in a graphical environment and see to dropbox icon in the task bar, change the dropbox configuration file in this way:
+
== Multiple Dropbox instances ==
  
{{hc|/etc/systemd/system/dropboxd.service|<nowiki>
+
If you need to separate or distinguish your data, personal and work usage for example, you can subscribe to Dropbox with different email addresses and have multiple directories synced to different instances.
[Unit]
+
Description=Dropbox
+
After=local-fs.target network.target
+
  
[Service]
+
The basic principle and general how-to are described in the [http://www.dropboxwiki.com/Multiple_Instances_On_Unix Dropbox Wiki].
User=your-username
+
Environment="DISPLAY=:0"
+
ExecStart=/path/to/dropboxd
+
  
[Install]
+
{{Note|When dealing with multiple instances you have to select the Dropbox destination folder, which the Dropbox installer asks in the last step; usage examples may be {{ic|/home/dropbox-personal}}, {{ic|/home/dropbox-work}}, and so on.}}
WantedBy=graphical.target
+
</nowiki>}}
+
  
==Without Nautilus (Another Way)==
+
For convenience, here is a script that I use to accomplish the task: just add a dir in the "dropboxes" list to have another instance of Dropbox, referring to the dir, loaded at script startup.
  
Another way to use Dropbox without Nautilus but with another file manager like Thunar or Pcmanfm is described below:
+
{{bc|<nowiki>
 +
#!/bin/bash
  
1. Create a fake Nautilus script that will launch Thunar:
+
#*******************************
    $ sudo touch /usr/bin/nautilus && sudo chmod +x /usr/bin/nautilus && sudo nano /usr/bin/nautilus
+
# Multiple dropbox instances
 +
#*******************************
  
2. Insert this text into the file, then save and exit:
+
dropboxes=(.dropbox-personal .dropbox-work)
    #!/bin/bash
+
                                                                                                       
    exec thunar $2
+
for dropbox in ${dropboxes[@]}; do
    exit 0
+
    if ! [ -d $HOME/$dropbox ];then
 +
        mkdir $HOME/$dropbox
 +
    fi
 +
    HOME=$HOME/$dropbox/ /opt/dropbox/dropbox start -i &
 +
done
 +
</nowiki>}}
  
3. Launch Dropbox
+
== Dropbox on laptops ==
    $ dropboxd
+
  
4. Click on the Dropbox tray icon to open your Dropbox folder in Thunar.
+
Dropbox itself is pretty good at dealing with connectivity problems. If you have a laptop and roam between different network environments, Dropbox will have problems reconnecting if you do not restart it.
  
{{Note|In this way there is no need to create a Dropbox daemon in {{ic|/etc/rc.d/}} and to start it at boot via {{ic|/etc/rc.conf}} or to make it start via your session manager: just leave the "Start Dropbox on system startup" option flagged in the Preferences window.}}
+
=== Using netcfg ===
  
{{Note|If you already have Nautilus installed but do not want to use it, neither modify the existing file under {{ic|/usr/bin}}, just change the {{ic|/usr/bin}} for {{ic|/opt/dropbox}} in the step 2 above, like this: {{Ic|$ sudo touch /opt/dropbox/nautilus && sudo chmod +x /opt/dropbox/nautilus && sudo nano /opt/dropbox/nautilus}}. Dropbox will look in this path first!}}
+
The easiest way to solve this with [[netcfg]] is to use POST_UP and PRE_DOWN. In every network profile you use (or in the [[Netcfg#Per-interface_configuration]]), add the appropriate commands:
 +
{{bc|<nowiki>
 +
POST_UP="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user"
 +
PRE_DOWN="any other code; killall dropbox"
 +
</nowiki>}}
 +
Obviously, ''your_user'' has to be edited and ''any other code'' can be omitted if you do not have any. The above will make sure that Dropbox is running only if there is a network profile active.
  
==Securing Your Dropbox==
+
=== Using netctl ===
  
If you want to store sensitive data in your Dropbox, you should encrypt it before. Syncing to Dropbox is encrypted, but all files are (for the time being) stored on the server unencrypted just as you put them in your Dropbox.
+
For [[netctl]], use {{ic|ExecUpPost}} and {{ic|ExecDownPre}} respectively in every network profile you use, or for example in {{ic|/etc/netctl/interfaces/wlan0}} to start Dropbox automatically whenever profile on {{ic|wlan0}} is active. Add '|| true' to your command to make sure [[netctl]] will bring up your profile, although Dropbox fails to start.
 +
{{bc|<nowiki>
 +
ExecUpPost="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user || true"
 +
ExecDownPre="any other code; killall dropbox"
 +
</nowiki>}}
 +
Obviously, {{ic|your_user}} has to be edited and {{ic|any other code;}} can be omitted if you do not have any. The above will make sure that Dropbox is running only if there is a network profile active.
  
* Dropbox works with [[TrueCrypt]], and after you initially uploaded the TrueCrypt volume to Dropbox, performance is quite okay, because Dropbox has a working binary diff.
+
=== Using NetworkManager ===
  
* Another possibility is to use [[EncFS]], which has the advantage that all files are encrypted separately, i.e. you do not have to determine in advance the size of the content you want to encrypt and your encrypted directory grows and shrinks while you add/delete/modify files in it. You can also mount an encrypted volume at startup using the {{ic|-S}} option of {{Ic|encfs}} to avoid having to input the passphrase, but note that your encrypted files are not secure from someone who has direct access to your computer.
+
If you have connectivity problem with [[NetworkManager]], [https://bbs.archlinux.org/viewtopic.php?pid=790905, this thread] on forum should be useful. Another good script to solve the problem, can be found [https://bbs.archlinux.org/viewtopic.php?pid=1012343#p1012343 here].
  
==Multiple Dropbox Instances==
+
== Troubleshooting ==
  
If you need to separate or distinguish your data, personal and work usage for example, you can subscribe to Dropbox with different email addresses and have multiple directories synced to different instances.
+
=== Dropbox keeps saying Downloading files ===
  
The basic principle and general how-to are described in the [http://wiki.dropbox.com/TipsAndTricks/MultipleInstancesOnUnix Dropbox Wiki].
+
But in fact now files are synced with your box. This problem is likely to appear when your Dropbox folder is located on a NTFS partition whose mount path contains spaces. See more in the [[https://bbs.archlinux.org/viewtopic.php?id=153368 forums]]. To resolve the problem pay attention to your entry in {{ic|/etc/fstab}}. Avoid spaces in the mount path and set write permissions:
  
{{Note|When dealing with multiple instances you have to select the Dropbox destination folder, which the Dropbox installer asks in the last step; usage examples may be {{ic|/home/dropbox-personal}}, {{ic|/home/dropbox-work}}, and so on.}}
+
UUID=01CD2ABB65E17DE0 /run/media/username/Windows ntfs-3g uid=username,gid=users 0 0
  
For convenience, here is a script that I use to accomplish the task: just add a dir in the "dropboxes" list to have another instance of Dropbox, referring to the dir, loaded at script startup.
+
=== Change the Dropbox location from the installation wizard ===
  
{{bc|<nowiki>
+
Some users experience the problem during setting-up Dropbox that they cannot select a Dropbox folder other than {{ic|/home/username/Dropbox}}. In this case when the window for changing the path is shown , hit {{ic|Ctrl+l}}, enter the location (e.g. /mnt/data/Dropbox) and click on the '"Choose" or "Open" button.
#!/bin/bash                                                                                             
+
                                                                                                       
+
#*******************************                                                                       
+
# Multiple dropbox instances                                                                           
+
#*******************************                                                                       
+
                                                                                                       
+
dropboxes=(.dropbox-personal .dropbox-work)                                                           
+
                                                                                                       
+
for dropbox in ${dropboxes[@]}                                                                        
+
do                                                                                                     
+
    if ! [ -d $HOME/$dropbox ];then                                                                   
+
        mkdir $HOME/$dropbox                                                                           
+
    fi                                                                                                 
+
    HOME=$HOME/$dropbox/ /usr/bin/dropbox start -i                                                     
+
done 
+
</nowiki>}}
+
  
==Dropbox on Laptops==
+
=== Context menu entries in file manager do not work ===
  
Dropbox itself is pretty good at dealing with connectivity problems. If you have a laptop and roam between different network environments, Dropbox will have problems reconnecting if you do not restart it. The easiest way to solve this with [[netcfg]] is to use POST_UP and PRE_DOWN.
+
Several file managers such as Thunar, Nautilus or its fork Nemo come with extensions that provide context menu entries for files and folders inside your Dropbox. Most of them will result in a browser action such as opening the file or folder in dropbox.com or sharing the link. If you experience these entries to not working, then you are likely to have not set the {{ic|$BROWSER}} variable which Dropbox requires. You can check that by
  
In every network profile you use, add the appropriate commands:
+
$ echo $BROWSER
{{bc|<nowiki>
+
 
POST_UP="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user"
+
To set your {{ic|$BROWSER}} variable open {{ic|~/.profile}} and replace {{ic|chromium}} with your default browser:
PRE_DOWN="any other code; killall dropbox"
+
 
</nowiki>}}
+
if [ -n "$DISPLAY" ]; then
Obviously, your_user has to be edited and 'any other code;' can be omitted if you do not have any. The above will make sure that Dropbox is running only if there is a network profile active.
+
        BROWSER=chromium
 +
fi
 +
 
 +
=== Connecting... ===
  
If you have connectivity problem with [[NetworkManager]], [https://bbs.archlinux.org/viewtopic.php?pid=790905, this thread] on forum should be useful.
+
{{Note|It seems that this issue has been fixed in later versions of dropbox (sometime before 1.6.0-2). It might be reasonable to test before installing one of the following scripts}}
 +
{{Poor writing|[[#Dropbox on Laptops|Dropbox on laptops]] is better workarround}}
  
==Known Issues==
+
It may happen that Dropbox cannot connect successfully because it was loaded before an Internet connection was established. To solve the problem the content of the file {{ic|/opt/dropbox/dropboxd}} needs to be replaced with the following:
===Connecting...===
+
It may happen that Dropbox cannot connect successfully because it was loaded before an Internet connection was established. To solve the problem the content of the file {{ic|/opt/dropbox/dropboxd}} needs to be replaced with the following:  
+
  
 
  #!/bin/sh
 
  #!/bin/sh
Line 284: Line 211:
 
  PAR=$(dirname $(readlink -f $0))
 
  PAR=$(dirname $(readlink -f $0))
 
  OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
 
  OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
  LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH  
+
  LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH
 
   
 
   
  TMP1=`ps ax|grep dropbox|grep -v grep`
+
  TMP1=$(ps ax|grep dropbox|grep -v grep)
 
  if [ -n "$TMP1" ]; then
 
  if [ -n "$TMP1" ]; then
  kill -9 $(pidof dropbox) >/dev/null 2>&1
+
        kill -9 $(pidof dropbox) >/dev/null 2>&1
 
  fi
 
  fi
 
  exec $PAR/dropbox $@ &
 
  exec $PAR/dropbox $@ &
Line 296: Line 223:
 
  start_dropbox >/dev/null 2>&1
 
  start_dropbox >/dev/null 2>&1
 
  while [ 1 ]; do
 
  while [ 1 ]; do
  sleep 5
+
        sleep 5
  ERROR="$(net_test)"
+
        ERROR="$(net_test)"
  if [ -n "$ERROR" ]; then
+
        if [ -n "$ERROR" ]; then
    LAST_ERROR=1
+
                LAST_ERROR=1
  else
+
        else
    if [ -n "$LAST_ERROR" ]; then
+
                if [ -n "$LAST_ERROR" ]; then
      # Connection seems to be up but last cycle was down
+
                # Connection seems to be up but last cycle was down
      LAST_ERROR=""
+
                        LAST_ERROR=""
      start_dropbox >/dev/null 2>&1
+
                  start_dropbox >/dev/null 2>&1
    fi
+
                  fi
  fi
+
        fi
 
  done
 
  done
 
 
  }
 
  }
 
   
 
   
Line 318: Line 244:
 
  do_dropbox
 
  do_dropbox
  
Following is an alternative script that will check for an actual Internet connection by using {{pkg|curl}} to check if any entry in a list of hosts and IP addresses is available.
+
Following is an alternative script that will check for an actual Internet connection by using {{Pkg|curl}} to check if any entry in a list of hosts and IP addresses is available.
 
If none of the specified hosts are available, the script will wait and try again (albeit not forever).
 
If none of the specified hosts are available, the script will wait and try again (albeit not forever).
 
The way the script increments the waiting time is quite messy, but the logic goes like this:
 
The way the script increments the waiting time is quite messy, but the logic goes like this:
Line 355: Line 281:
 
  #if dropbox is running; kill it. Then start dropbox
 
  #if dropbox is running; kill it. Then start dropbox
 
  start_dropbox() {
 
  start_dropbox() {
  local tmp=`ps ax|grep -E "[0-9] $PAR/dropbox"|grep -v grep`
+
  local tmp=$(ps ax|grep -E "[0-9] $PAR/dropbox"|grep -v grep)
 
         if [ -n "$tmp" ]; then
 
         if [ -n "$tmp" ]; then
 
                 kill -9 $(pidof dropbox) > /dev/null 2>&1
 
                 kill -9 $(pidof dropbox) > /dev/null 2>&1
Line 380: Line 306:
 
  attempt_startup &
 
  attempt_startup &
  
===Dropbox does not start - "This is usually because of a permission error"===
+
{{Tip|When you update Dropbox via your preferred AUR helper, the file will (usually) be reverted to the default one. You can prevent this with {{ic|chattr +i /opt/dropbox/dropboxd}} which will make the file immutable. To reverse this action simply use {{ic|chattr -i /opt/dropbox/dropboxd}}. }}
 +
 
 +
=== Dropbox does not start - "This is usually because of a permission error" ===
 +
 
 +
==== Check permissions ====
  
====Check permissions====
 
 
Make sure that you own Dropbox's directories before running the application. This includes
 
Make sure that you own Dropbox's directories before running the application. This includes
 
*{{ic|~/.dropbox}} - Dropbox's configuration directory
 
*{{ic|~/.dropbox}} - Dropbox's configuration directory
Line 390: Line 319:
 
This error could also be caused by {{ic|/var}} being full.
 
This error could also be caused by {{ic|/var}} being full.
  
====Re-linking your account====
+
==== Re-linking your account ====
 +
 
 
[https://www.dropbox.com/help/72 Dropbox's FAQ] suggests that this error may be caused by misconfiguration and is fixed by (re)moving the current configuration folder
 
[https://www.dropbox.com/help/72 Dropbox's FAQ] suggests that this error may be caused by misconfiguration and is fixed by (re)moving the current configuration folder
 
  # mv ~/.dropbox ~/.dropbox.old
 
  # mv ~/.dropbox ~/.dropbox.old
 
and restarting Dropbox.
 
and restarting Dropbox.
  
====Errors caused by running out of space====
+
==== Errors caused by running out of space ====
 +
 
 
A common error that might happen is that there is no more available space on your {{ic|/tmp}} and {{ic|/var}} partitions. If this happens, Dropbox will crash on startup with the following error in its log:
 
A common error that might happen is that there is no more available space on your {{ic|/tmp}} and {{ic|/var}} partitions. If this happens, Dropbox will crash on startup with the following error in its log:
{{bc|
+
 
Exception: Not a valid FileCache file
+
Exception: Not a valid FileCache file
}}
+
 
 
A detailed story of such an occurrence can be found in the [https://bbs.archlinux.org/viewtopic.php?pid=973458 forums]. Make sure there is enough space available before launching Dropbox.
 
A detailed story of such an occurrence can be found in the [https://bbs.archlinux.org/viewtopic.php?pid=973458 forums]. Make sure there is enough space available before launching Dropbox.
  
====Locale caused errors====
+
==== Locale caused errors ====
 +
 
 
Try starting {{Ic|dropboxd}} with this code:
 
Try starting {{Ic|dropboxd}} with this code:
  
Line 411: Line 343:
 
This helps when running from a Bash script or Bash shell where {{ic|/etc/rc.d/functions}} has been loaded
 
This helps when running from a Bash script or Bash shell where {{ic|/etc/rc.d/functions}} has been loaded
  
==Alternatives==
+
==== Filesystem monitoring problem ====
*[https://one.ubuntu.com/ Ubuntu One] - {{Pkg|ubuntuone-client}}
+
 
*[https://spideroak.com/ Spider Oak] - {{AUR|spideroak}}
+
If you have a lot of files to sync in your Dropbox folder, you might get the following error:
*[http://kdropbox.deuteros.es/ KFileBox] - {{AUR|kfilebox}}
+
 
*[https://www.wuala.com/ Wuala] - {{AUR|wuala}}
+
Unable to monitor filesystem
 +
Please run: echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches and restart Dropbox to correct the problem.
 +
 
 +
This can be fixed easily by adding
 +
 
 +
fs.inotify.max_user_watches = 100000
 +
 
 +
to {{ic|/etc/sysctl.conf}} and then reload the kernel parameters
 +
 
 +
# sysctl -p
 +
 
 +
=== Proxy settings ===
 +
 
 +
The easiest way to set Dropbox's proxy settings is by defining them manually in the Proxies tab of the Preferences window. Alternatively, you can also set it to 'Auto-detect' and then export your proxy server to the http_proxy env variable prior to starting Dropbox (HTTP_PROXY is also usable)
 +
env http_proxy=http://your.proxy.here:port /usr/bin/dropboxd
 +
or
 +
export http_proxy=http://your.proxy.here:port
 +
/usr/bin/dropboxd
 +
 
 +
Take note, Dropbox will only use proxy settings of the form http://your.proxy.here:port, not your.proxy.here:port as some other applications do.
 +
 
 +
== Alternatives ==
 +
 
 +
* [[Ubuntu One]] - {{Pkg|ubuntuone-client}}
 +
* [https://spideroak.com/ Spider Oak] - {{AUR|spideroak}}
 +
* [http://kdropbox.deuteros.es/ KFileBox] - {{AUR|kfilebox}}
 +
* [https://www.wuala.com/ Wuala] - {{AUR|wuala}}

Revision as of 22:47, 14 July 2013

Dropbox is a file sharing system that recently introduced a GNU/Linux client. Use it to transparently sync files across computers and architectures. Simply drop files into your ~/Dropbox folder, and they will automatically sync to your centralized repository.

Installation

dropboxAUR can be installed from the AUR. Alternatively, dropbox-experimentalAUR is also available.

  1. After installing the package, you can start Dropbox from your application menu or run dropboxd from the command-line. The client icon will appear in the system tray.
  2. A pop-up will notify you that Dropbox is running from an unsupported location. Click on Don't ask again since you know that you have installed it from AUR rather than from the official homepage.
  3. Eventually a pop-up will ask you to log in to your Dropbox account or create a new account. Enter your credentials.
  4. After some time you will see a "Welcome to Dropbox" pop-up, which will give you the opportunity to view a short tour of Dropbox.
  5. Press the "Finish and go to My Dropbox".

For KDE users, no further steps are required (it is enough to install the above dropboxAUR package from the AUR), as KDE saves running applications when logging out and restarts them automatically. Similarly for Xfce users, dropbox will be restarted automatically next time you login since the dropbox.desktop file be placed in ~/.config/autostart.

Optional packages

  • For a command-line interface, install dropbox-cliAUR from the AUR.
  • For integration with Nautilus, install nautilus-dropboxAUR from the AUR. The Nautilus plugin will start Dropbox automatically.
  • For integration with Nemo, install nemo-dropbox-gitAUR from the AUR.
  • For integration with Thunar, install thunar-dropboxAUR from the AUR.
  • For KDE users, there is a KDE client available: kfileboxAUR from the AUR.

Automatically starting Dropbox

Dropbox can be automatically started by adding dropboxd to ~/.xinitrc (or ~/.config/openbox/autostart, depending on your setup). Alternatively, you can start it as a daemon.

Alternative to install: use the web interface

If all you need is basic access to the files in your Dropbox, you can use the web interface at https://www.dropbox.com/ to upload and download files to your Dropbox. This can be a viable alternative to running a Dropbox daemon and mirroring all the files on your own machine.

Run as daemon with systemd

Recent versions of Dropbox come with a systemd service file. By default running Dropbox as a daemon does not give you an icon in the system tray, but syncs your files and folders in the background. If you want to have tray support, then you have to copy the service file to /etc/systemd/system/dropbox@.service and add the environment variable.

# echo ".include /usr/lib/systemd/system/dropbox@.service
[Service]
Environment=DISPLAY=:0" > /etc/systemd/system/dropbox@.service

Finally, to enable the daemon for your user, so that it will start at login:

# systemctl enable dropbox@<user>

Note that you have to manually start Dropbox the first time after installation, so that it runs through the login and setup screen. Further, you need to uncheck the option Start Dropbox on system startup in order to prevent Dropbox from being started twice. The daemon can then be used subsequently.

Run as a daemon with systemd user

If you have followed the systemd/User wiki page, you probably want to start dropbox only when you log in or launch your WM/DE. The solution in that case is to create a service in your home directory instead of using the sysadmin account:

$HOME/.config/systemd/user/dropbox@.service
[Unit]
Description=Dropbox as a systemd service
After=xorg.target

[Service]
ExecStart=/home/your_user/.dropbox-dist/dropbox
ExecReload=/bin/kill -HUP $MAINPID
Environment=DISPLAY=%i

[Install]
WantedBy=mystuff.target

They you can start or enable it with:

$ systemctl --user {start|enable} dropbox@:0.service

That way you can easily start it in your main display (likely :0) or in another one, without having to hard code it.

Note: After a lot of trial and error I found that using /usr/bin/dropboxd didn't start the service and it didn't show any error either (even when running it directly from the terminal worked fine). I believe it has to do that starting it that way systemd doesn't know which user is actually running the daemon.

Without Nautilus (another way)

Another way to use Dropbox without Nautilus but with another file manager like Thunar or Pcmanfm is described below:

1. Create a fake Nautilus script that will launch Thunar:

$ sudo touch /usr/bin/nautilus && sudo chmod +x /usr/bin/nautilus && sudo nano /usr/bin/nautilus

2. Insert this text into the file, then save and exit:

#!/bin/bash
exec thunar $2
exit 0

3. Launch Dropbox:

$ dropboxd

4. Click on the Dropbox tray icon to open your Dropbox folder in Thunar.

Note:
  • In this way there is no need to create a Dropbox daemon in /etc/rc.d/ and to start it at boot via /etc/rc.conf or to make it start via your session manager: just leave the "Start Dropbox on system startup" option flagged in the Preferences window.
  • If you already have Nautilus installed but do not want to use it, don't modify the existing file under /usr/bin, just change the /usr/bin for /opt/dropbox in the step 2 above, like this: $ sudo touch /opt/dropbox/nautilus && sudo chmod +x /opt/dropbox/nautilus && sudo nano /opt/dropbox/nautilus. Dropbox will look in this path first!

Securing your Dropbox

If you want to store sensitive data in your Dropbox, you should encrypt it before. Syncing to Dropbox is encrypted, but all files are (for the time being) stored on the server unencrypted just as you put them in your Dropbox.

  • Dropbox works with TrueCrypt, and after you initially uploaded the TrueCrypt volume to Dropbox, performance is quite okay, because Dropbox has a working binary diff.
  • Another possibility is to use EncFS, which has the advantage that all files are encrypted separately, i.e. you do not have to determine in advance the size of the content you want to encrypt and your encrypted directory grows and shrinks while you add/delete/modify files in it. You can also mount an encrypted volume at startup using the -S option of encfs to avoid having to input the passphrase, but note that your encrypted files are not secure from someone who has direct access to your computer.

Setup EncFS with Dropbox

Follow the Wiki instructions to install EncFS.

Assuming you have set your Dropbox directory as ~/Dropbox:

Create a folder. Files you want synced to Dropbox will go in here.

$ mkdir ~/Private

Run the following and enter a password when asked:

$ encfs ~/Dropbox/Encrypted ~/Private

Your secure folder is ready for use; creating any file inside ~/Private will automatically encrypt it into ~/Dropbox/Encrypted, which will then be synced to your cloud storage.

To mount your EncFS folder on every boot, follow the instructions in the EncFS wiki page.

Multiple Dropbox instances

If you need to separate or distinguish your data, personal and work usage for example, you can subscribe to Dropbox with different email addresses and have multiple directories synced to different instances.

The basic principle and general how-to are described in the Dropbox Wiki.

Note: When dealing with multiple instances you have to select the Dropbox destination folder, which the Dropbox installer asks in the last step; usage examples may be /home/dropbox-personal, /home/dropbox-work, and so on.

For convenience, here is a script that I use to accomplish the task: just add a dir in the "dropboxes" list to have another instance of Dropbox, referring to the dir, loaded at script startup.

#!/bin/bash

 #*******************************
 # Multiple dropbox instances
 #*******************************

 dropboxes=(.dropbox-personal .dropbox-work)
                                                                                                         
 for dropbox in ${dropboxes[@]}; do
     if ! [ -d $HOME/$dropbox ];then
         mkdir $HOME/$dropbox
     fi
     HOME=$HOME/$dropbox/ /opt/dropbox/dropbox start -i &
 done

Dropbox on laptops

Dropbox itself is pretty good at dealing with connectivity problems. If you have a laptop and roam between different network environments, Dropbox will have problems reconnecting if you do not restart it.

Using netcfg

The easiest way to solve this with netcfg is to use POST_UP and PRE_DOWN. In every network profile you use (or in the Netcfg#Per-interface_configuration), add the appropriate commands:

POST_UP="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user"
PRE_DOWN="any other code; killall dropbox"

Obviously, your_user has to be edited and any other code can be omitted if you do not have any. The above will make sure that Dropbox is running only if there is a network profile active.

Using netctl

For netctl, use ExecUpPost and ExecDownPre respectively in every network profile you use, or for example in /etc/netctl/interfaces/wlan0 to start Dropbox automatically whenever profile on wlan0 is active. Add '|| true' to your command to make sure netctl will bring up your profile, although Dropbox fails to start.

ExecUpPost="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user || true"
ExecDownPre="any other code; killall dropbox"

Obviously, your_user has to be edited and any other code; can be omitted if you do not have any. The above will make sure that Dropbox is running only if there is a network profile active.

Using NetworkManager

If you have connectivity problem with NetworkManager, this thread on forum should be useful. Another good script to solve the problem, can be found here.

Troubleshooting

Dropbox keeps saying Downloading files

But in fact now files are synced with your box. This problem is likely to appear when your Dropbox folder is located on a NTFS partition whose mount path contains spaces. See more in the [forums]. To resolve the problem pay attention to your entry in /etc/fstab. Avoid spaces in the mount path and set write permissions:

UUID=01CD2ABB65E17DE0 /run/media/username/Windows ntfs-3g uid=username,gid=users 0 0

Change the Dropbox location from the installation wizard

Some users experience the problem during setting-up Dropbox that they cannot select a Dropbox folder other than /home/username/Dropbox. In this case when the window for changing the path is shown , hit Ctrl+l, enter the location (e.g. /mnt/data/Dropbox) and click on the '"Choose" or "Open" button.

Context menu entries in file manager do not work

Several file managers such as Thunar, Nautilus or its fork Nemo come with extensions that provide context menu entries for files and folders inside your Dropbox. Most of them will result in a browser action such as opening the file or folder in dropbox.com or sharing the link. If you experience these entries to not working, then you are likely to have not set the $BROWSER variable which Dropbox requires. You can check that by

$ echo $BROWSER

To set your $BROWSER variable open ~/.profile and replace chromium with your default browser:

if [ -n "$DISPLAY" ]; then
        BROWSER=chromium
fi

Connecting...

Note: It seems that this issue has been fixed in later versions of dropbox (sometime before 1.6.0-2). It might be reasonable to test before installing one of the following scripts

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Dropbox on laptops is better workarround (Discuss in Talk:Dropbox#)

It may happen that Dropbox cannot connect successfully because it was loaded before an Internet connection was established. To solve the problem the content of the file /opt/dropbox/dropboxd needs to be replaced with the following:

#!/bin/sh

# Copyright 2008 Evenflow, Inc., 2010 Dropbox
#
# Environment script for the dropbox executable.

start_dropbox() {
PAR=$(dirname $(readlink -f $0))
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH

TMP1=$(ps ax|grep dropbox|grep -v grep)
if [ -n "$TMP1" ]; then
        kill -9 $(pidof dropbox) >/dev/null 2>&1
fi
exec $PAR/dropbox $@ &
}

do_dropbox() {
start_dropbox >/dev/null 2>&1
while [ 1 ]; do
        sleep 5
        ERROR="$(net_test)"
        if [ -n "$ERROR" ]; then
                LAST_ERROR=1
        else
                if [ -n "$LAST_ERROR" ]; then
                # Connection seems to be up but last cycle was down
                        LAST_ERROR=""
                 start_dropbox >/dev/null 2>&1
                 fi
        fi
done
}

net_test() {
TMP1="$(ip addr |grep "inet " |grep -v "127.0.0.1")"
[ -z "$TMP1" ] && echo "error"
}

do_dropbox

Following is an alternative script that will check for an actual Internet connection by using curl to check if any entry in a list of hosts and IP addresses is available. If none of the specified hosts are available, the script will wait and try again (albeit not forever). The way the script increments the waiting time is quite messy, but the logic goes like this:

Start with a wait time of 5 seconds.

Multiply by 1.5.

Do this as long as the wait time is less than 1500 seconds (25 minutes), and the check_net() function returns non-zero values (failure).

#!/bin/bash

# Copyright 2008 Evenflow, Inc., 2010 Dropbox
#
# Environment script for the dropbox executable.

WAIT_TIME=5 #initial time to wait between checking the internet connection
#HOSTS="www.google.com www.wikipedia.org 8.8.8.8 208.67.222.222"
HOSTS="www.google.com www.wikipedia.org "

PAR=$(dirname $(readlink -f $0))
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
LD_LIBRARY_PATH=$PAR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH

#non-zero exit code iff none of the hosts could be reached
check_net() {
        local ret=1
        for i in $HOSTS; do
                #ping -w2 -c2 $i > /dev/null 2>&1 && ret=0 && break
                curl -o /dev/null $i > /dev/null 2>&1 && ret=0 && break
        done
        echo $ret
}

#if dropbox is running; kill it. Then start dropbox
start_dropbox() {
local tmp=$(ps ax|grep -E "[0-9] $PAR/dropbox"|grep -v grep)
        if [ -n "$tmp" ]; then
                kill -9 $(pidof dropbox) > /dev/null 2>&1
        fi
        exec $PAR/dropbox $@ > /dev/null 2>&1 &
}

#loop over: start dropbox iff check_net returns 0
#loop (and with it, the entire script) terminates when dropbox has been restarted,
#+ or the waiting time has exeeded 1500 seconds (it grows 50% with each iteration of the loop)
attempt_startup() {
        while [ $WAIT_TIME -lt 1500  ] ; do
                if [ $(check_net) -eq 0 ]; then
                        start_dropbox
                        exit
                fi
                sleep $WAIT_TIME
                #WAIT_TIME=$(($WAIT_TIME+$WAIT_TIME/2))
                let "WAIT_TIME += WAIT_TIME/2"
        done
}

start_dropbox
attempt_startup &
Tip: When you update Dropbox via your preferred AUR helper, the file will (usually) be reverted to the default one. You can prevent this with chattr +i /opt/dropbox/dropboxd which will make the file immutable. To reverse this action simply use chattr -i /opt/dropbox/dropboxd.

Dropbox does not start - "This is usually because of a permission error"

Check permissions

Make sure that you own Dropbox's directories before running the application. This includes

  • ~/.dropbox - Dropbox's configuration directory
  • ~/Dropbox - Dropbox's download directory (default)

You can ensure this by changing their owner with chown -R.

This error could also be caused by /var being full.

Re-linking your account

Dropbox's FAQ suggests that this error may be caused by misconfiguration and is fixed by (re)moving the current configuration folder

# mv ~/.dropbox ~/.dropbox.old

and restarting Dropbox.

Errors caused by running out of space

A common error that might happen is that there is no more available space on your /tmp and /var partitions. If this happens, Dropbox will crash on startup with the following error in its log:

Exception: Not a valid FileCache file

A detailed story of such an occurrence can be found in the forums. Make sure there is enough space available before launching Dropbox.

Locale caused errors

Try starting dropboxd with this code:

LANG=$LOCALE
dropboxd

(You can also use a different value for LANG; it must be in the format "en_US.UTF-8") This helps when running from a Bash script or Bash shell where /etc/rc.d/functions has been loaded

Filesystem monitoring problem

If you have a lot of files to sync in your Dropbox folder, you might get the following error:

Unable to monitor filesystem
Please run: echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches and restart Dropbox to correct the problem.

This can be fixed easily by adding

fs.inotify.max_user_watches = 100000

to /etc/sysctl.conf and then reload the kernel parameters

# sysctl -p

Proxy settings

The easiest way to set Dropbox's proxy settings is by defining them manually in the Proxies tab of the Preferences window. Alternatively, you can also set it to 'Auto-detect' and then export your proxy server to the http_proxy env variable prior to starting Dropbox (HTTP_PROXY is also usable)

env http_proxy=http://your.proxy.here:port /usr/bin/dropboxd

or

export http_proxy=http://your.proxy.here:port
/usr/bin/dropboxd

Take note, Dropbox will only use proxy settings of the form http://your.proxy.here:port, not your.proxy.here:port as some other applications do.

Alternatives