https://wiki.archlinux.org/api.php?action=feedcontributions&user=Tuvistavie&feedformat=atomArchWiki - User contributions [en]2024-03-28T13:13:20ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Dropbox&diff=223041Dropbox2012-09-14T12:03:46Z<p>Tuvistavie: Add filesystem monitoring problem fix</p>
<hr />
<div>[[Category:Internet Applications]]<br />
[[it:Dropbox]]<br />
[[zh-TW:Dropbox]]<br />
[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.<br />
<br />
==Installation==<br />
<br />
{{AUR|dropbox}} can be installed from the [[Arch User Repository|AUR]]. Alternatively, {{AUR|dropbox-experimental}} is also available.<br />
<br />
# 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.<br />
# Eventually a pop-up will ask you to log in to your Dropbox account or create a new account. Enter your credentials.<br />
# 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.<br />
# Press the "Finish and go to My Dropbox".<br />
<br />
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.<br />
<br />
===Optional packages===<br />
<br />
*For a command-line interface, install {{AUR|dropbox-cli}} from the [[Arch User Repository|AUR]].<br />
*For integration with Nautilus, install {{AUR|nautilus-dropbox}} from the AUR. The Nautilus plugin will start Dropbox automatically.<br />
*For integration with [[Thunar]], install {{AUR|thunar-dropbox}} from the AUR.<br />
*For [[KDE]] users, there is a KDE client available: {{AUR|kfilebox}} from the AUR.<br />
<br />
===Automatically Starting Dropbox===<br />
<br />
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]].<br />
<br />
== Alternative to install: use the web interface ==<br />
<br />
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.<br />
<br />
==Daemon==<br />
<br />
To run Dropbox as a daemon similarly to {{Ic|sshd}} or {{Ic|vsftpd}}, simply do one of the following:<br />
<br />
===dropbox-daemon Method===<br />
<br />
Install {{AUR|dropbox-daemon}}<br />
and configure your username in {{ic|/etc/conf.d/dropboxd.conf}}<br />
<br />
This allows you to start or stop Dropbox just like any other service.<br />
<br />
# /etc/rc.d/dropboxd start<br />
# /etc/rc.d/dropboxd stop<br />
# /etc/rc.d/dropboxd restart<br />
<br />
Place {{Ic|dropboxd}} in the DAEMONS array in {{ic|/etc/rc.conf}} for it to start at boot.:<br />
DAEMONS=(... '''@dropboxd''' ...)<br />
<br />
===Manual Method===<br />
<br />
As root, copy this into a file called {{ic|/etc/rc.d/dropboxd}} and set USER to your username.<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
USER=yourusername<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
PID=`pidof -o %PPID /opt/dropbox/dropbox`<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "Starting Dropbox Service"<br />
LANG=$LOCALE<br />
[ -z "$PID" ] && su -c "/usr/bin/dropboxd &" $USER<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
add_daemon dropboxd<br />
stat_done<br />
fi<br />
;;<br />
stop)<br />
stat_busy "Stopping Dropbox Service"<br />
[ ! -z "$PID" ] && kill $PID > /dev/null<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
rm_daemon dropboxd<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
sleep 3<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
;;<br />
esac<br />
exit 0<br />
</nowiki>}}<br />
<br />
An Organized Way:<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
USER=yourusername<br />
DROPBOXD_PATH='/usr/bin/dropboxd'<br />
DROPBOX_PATH='/opt/dropbox/dropbox'<br />
<br />
PID=`pidof -o %PPID $DROPBOX_PATH`<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "Starting Dropbox Service"<br />
if [ $USER = 'yourusername' ]; then<br />
echo "Please edit /etc/rc.d/dropboxd' 'USER' before using this script."<br />
stat_fail<br />
else<br />
LANG=$LOCALE<br />
[ -z "$PID" ] && su -c "$DROPBOXD_PATH &" $USER<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
add_daemon dropboxd<br />
stat_done<br />
fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy "Stopping Dropbox Service"<br />
[ ! -z "$PID" ] && kill $PID > /dev/null<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
rm_daemon dropboxd<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
sleep 3<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
;;<br />
esac<br />
exit 0<br />
</nowiki>}}<br />
<br />
Make the file executable with<br />
# chmod +x /etc/rc.d/dropboxd<br />
<br />
This allows you to start or stop {{Ic|dropboxd}} just like any other service. For example:<br />
<br />
# /etc/rc.d/dropboxd start<br />
# /etc/rc.d/dropboxd stop<br />
# /etc/rc.d/dropboxd restart<br />
<br />
To start it at boot, add it to your DAEMONS array in rc.conf: {{ic|/etc/rc.conf}}:<br />
DAEMONS=(... '''@dropboxd''' ...)<br />
<br />
== Systemd ==<br />
<br />
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.<br />
<br />
However, if you're ok with a little hardcoding...<br />
<br />
{{hc|/etc/systemd/system/dropboxd.service|<nowiki><br />
[Unit]<br />
Description=Dropbox<br />
After=local-fs.target network.target<br />
<br />
[Service]<br />
User=your-username<br />
ExecStart=/path/to/dropboxd<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Start it<br />
# systemctl start dropboxd.service<br />
<br />
Enable it at boot<br />
# systemctl enable dropboxd.service<br />
<br />
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:<br />
<br />
{{hc|/etc/systemd/system/dropboxd.service|<nowiki><br />
[Unit]<br />
Description=Dropbox<br />
After=local-fs.target network.target<br />
<br />
[Service]<br />
User=your-username<br />
Environment="DISPLAY=:0"<br />
ExecStart=/path/to/dropboxd<br />
<br />
[Install]<br />
WantedBy=graphical.target<br />
</nowiki>}}<br />
<br />
==Without Nautilus (Another Way)==<br />
<br />
Another way to use Dropbox without Nautilus but with another file manager like Thunar or Pcmanfm is described below:<br />
<br />
1. Create a fake Nautilus script that will launch Thunar:<br />
$ sudo touch /usr/bin/nautilus && sudo chmod +x /usr/bin/nautilus && sudo nano /usr/bin/nautilus<br />
<br />
2. Insert this text into the file, then save and exit:<br />
#!/bin/bash<br />
exec thunar $2<br />
exit 0<br />
<br />
3. Launch Dropbox<br />
$ dropboxd<br />
<br />
4. Click on the Dropbox tray icon to open your Dropbox folder in Thunar.<br />
<br />
{{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.}}<br />
<br />
{{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!}}<br />
<br />
==Securing Your Dropbox==<br />
<br />
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.<br />
<br />
* 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.<br />
<br />
* 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.<br />
<br />
==Multiple Dropbox Instances==<br />
<br />
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.<br />
<br />
The basic principle and general how-to are described in the [http://wiki.dropbox.com/TipsAndTricks/MultipleInstancesOnUnix Dropbox Wiki].<br />
<br />
{{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.}}<br />
<br />
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.<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash <br />
<br />
#******************************* <br />
# Multiple dropbox instances <br />
#******************************* <br />
<br />
dropboxes=(.dropbox-personal .dropbox-work) <br />
<br />
for dropbox in ${dropboxes[@]} <br />
do <br />
if ! [ -d $HOME/$dropbox ];then <br />
mkdir $HOME/$dropbox <br />
fi <br />
HOME=$HOME/$dropbox/ /usr/bin/dropbox start -i <br />
done <br />
</nowiki>}}<br />
<br />
==Dropbox on Laptops==<br />
<br />
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.<br />
<br />
In every network profile you use, add the appropriate commands:<br />
{{bc|<nowiki><br />
POST_UP="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user"<br />
PRE_DOWN="any other code; killall dropbox"<br />
</nowiki>}}<br />
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.<br />
<br />
If you have connectivity problem with [[NetworkManager]], [https://bbs.archlinux.org/viewtopic.php?pid=790905, this thread] on forum should be useful.<br />
<br />
==Known Issues==<br />
===Connecting...===<br />
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: <br />
<br />
#!/bin/sh<br />
<br />
# Copyright 2008 Evenflow, Inc., 2010 Dropbox<br />
#<br />
# Environment script for the dropbox executable.<br />
<br />
start_dropbox() {<br />
PAR=$(dirname $(readlink -f $0))<br />
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH<br />
LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH <br />
<br />
TMP1=`ps ax|grep dropbox|grep -v grep`<br />
if [ -n "$TMP1" ]; then<br />
kill -9 $(pidof dropbox) >/dev/null 2>&1<br />
fi<br />
exec $PAR/dropbox $@ &<br />
}<br />
<br />
do_dropbox() {<br />
start_dropbox >/dev/null 2>&1<br />
while [ 1 ]; do<br />
sleep 5<br />
ERROR="$(net_test)"<br />
if [ -n "$ERROR" ]; then<br />
LAST_ERROR=1<br />
else<br />
if [ -n "$LAST_ERROR" ]; then<br />
# Connection seems to be up but last cycle was down<br />
LAST_ERROR=""<br />
start_dropbox >/dev/null 2>&1<br />
fi<br />
fi<br />
done<br />
<br />
}<br />
<br />
net_test() {<br />
TMP1="$(ip addr |grep "inet " |grep -v "127.0.0.1")"<br />
[ -z "$TMP1" ] && echo "error"<br />
}<br />
<br />
do_dropbox<br />
<br />
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.<br />
If none of the specified hosts are available, the script will wait and try again (albeit not forever).<br />
The way the script increments the waiting time is quite messy, but the logic goes like this:<br />
<br />
Start with a wait time of 5 seconds.<br />
<br />
Multiply by 1.5.<br />
<br />
Do this as long as the wait time is less than 1500 seconds (25 minutes), and the check_net()<br />
function returns non-zero values (failure).<br />
<br />
#!/bin/bash<br />
<br />
# Copyright 2008 Evenflow, Inc., 2010 Dropbox<br />
#<br />
# Environment script for the dropbox executable.<br />
<br />
WAIT_TIME=5 #initial time to wait between checking the internet connection<br />
#HOSTS="www.google.com www.wikipedia.org 8.8.8.8 208.67.222.222"<br />
HOSTS="www.google.com www.wikipedia.org "<br />
<br />
PAR=$(dirname $(readlink -f $0))<br />
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH<br />
LD_LIBRARY_PATH=$PAR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH<br />
<br />
#non-zero exit code iff none of the hosts could be reached<br />
check_net() {<br />
local ret=1<br />
for i in $HOSTS; do<br />
#ping -w2 -c2 $i > /dev/null 2>&1 && ret=0 && break<br />
curl -o /dev/null $i > /dev/null 2>&1 && ret=0 && break<br />
done<br />
echo $ret<br />
}<br />
<br />
#if dropbox is running; kill it. Then start dropbox<br />
start_dropbox() {<br />
local tmp=`ps ax|grep -E "[0-9] $PAR/dropbox"|grep -v grep`<br />
if [ -n "$tmp" ]; then<br />
kill -9 $(pidof dropbox) > /dev/null 2>&1<br />
fi<br />
exec $PAR/dropbox $@ > /dev/null 2>&1 &<br />
}<br />
<br />
#loop over: start dropbox iff check_net returns 0<br />
#loop (and with it, the entire script) terminates when dropbox has been restarted,<br />
#+ or the waiting time has exeeded 1500 seconds (it grows 50% with each iteration of the loop)<br />
attempt_startup() {<br />
while [ $WAIT_TIME -lt 1500 ] ; do<br />
if [ $(check_net) -eq 0 ]; then<br />
start_dropbox<br />
exit<br />
fi<br />
sleep $WAIT_TIME<br />
#WAIT_TIME=$(($WAIT_TIME+$WAIT_TIME/2))<br />
let "WAIT_TIME += WAIT_TIME/2"<br />
done<br />
}<br />
<br />
start_dropbox<br />
attempt_startup &<br />
<br />
===Dropbox does not start - "This is usually because of a permission error"===<br />
<br />
====Check permissions====<br />
Make sure that you own Dropbox's directories before running the application. This includes<br />
*{{ic|~/.dropbox}} - Dropbox's configuration directory<br />
*{{ic|~/Dropbox}} - Dropbox's download directory (default)<br />
You can ensure this by changing their owner with {{ic|chown -R}}.<br />
<br />
This error could also be caused by {{ic|/var}} being full.<br />
<br />
====Re-linking your account====<br />
[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<br />
# mv ~/.dropbox ~/.dropbox.old<br />
and restarting Dropbox.<br />
<br />
====Errors caused by running out of space====<br />
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:<br />
{{bc|<br />
Exception: Not a valid FileCache file<br />
}}<br />
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.<br />
<br />
====Locale caused errors====<br />
Try starting {{Ic|dropboxd}} with this code:<br />
<br />
LANG=$LOCALE<br />
dropboxd<br />
<br />
(You can also use a different value for LANG; it must be in the format "en_US.UTF-8")<br />
This helps when running from a Bash script or Bash shell where {{ic|/etc/rc.d/functions}} has been loaded<br />
<br />
====Filesystem monitoring problem====<br />
If you have a lot of files to sync in your Dropbox folder, you might get the following error:<br />
<br />
Unable to monitor filesystem<br />
Please run: echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches and restart Dropbox to correct the problem.<br />
<br />
This can be fixed easily by adding<br />
<br />
fs.inotify.max_user_watches = 100000<br />
<br />
to {{ic|/etc/sysctl.conf}} and restarting your computer.<br />
<br />
<br />
==Alternatives==<br />
*[https://one.ubuntu.com/ Ubuntu One] - {{Pkg|ubuntuone-client}}<br />
*[https://spideroak.com/ Spider Oak] - {{AUR|spideroak}}<br />
*[http://kdropbox.deuteros.es/ KFileBox] - {{AUR|kfilebox}}<br />
*[https://www.wuala.com/ Wuala] - {{AUR|wuala}}</div>Tuvistavie