http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment
Install Dropbox In An Entirely Text-Based Linux Environment
Ubuntu
Server Install also
contains some notes on getting Dropbox running via the command line.
Contents
Prerequisites
- At least version 2.4 of the C library
- wget
- Python 2.x ≥ 2.5 (we do not offer support for Python 3.0)
- a web browser
Setup process
Short version
- Files are extracted to .dropbox-dist
- Run dropboxd
Alternative
I’ve
prepared a repackaged version of dropboxd and dropbox_cli which can
be installed once per host (or per system) and which have built-in
support for multiple DropBox directories per user. I’ve added in a
“link” command to “dropbox_cli” that gives you 2 minutes to
link your DB account to the specified directory. This is taken from
the v1.1.6 release. You can find it
here: http://portal.nebiogrid.org/devel/dropbox/
Step-by-step version
- Log in to your Linux server so you obtain a shell prompt, and change to your home directory.
cd - Stable 32-bit:
wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"Stable 64-bit:wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64" - Sanity check to make sure we’re not going to clog our home directory.
tar -tzf dropbox.tar.gz - Extract
tar -xvzf dropbox.tar.gz - Make sure the LANG environment variable is set to something other than NULL, e.g. en_US.iso88591. If it is NULL, you’ll get a cryptic error.
- Run dropboxd
~/.dropbox-dist/dropboxd - You should see output like this:
This client is not linked to any account... Please visit https://www.dropbox.com/cli_link?host_id=7d44a557aa58f285f2da0x67334d02c1 to link this machine.
dropboxd
will create a ~/Dropbox folder and start synchronizing it after this
step! Go
to the URL given; you should see a success message at the top of your
screen.
NOTE:
If you want to change the account it is linked to, unlink it from the
first account, then kill the running dropbox process, start it up
again (with “~/.dropbox-dist/dropboxd &”) and obtain the new
host_id with dbreadconfig.py . If you don’t restart the dropbox
client, it will give the same host_id (which for some reason cause me
to be unable to change the account it is linked to).
NOTE: Windowless Installs
If
you are unable to get a normal browser running on this machine (if
its a server for example) then there are three possible solutions:
Use a command-line browser (lynx)
- Get to the client not linked stage of the process above
- Leave that process running..
- … and open a new terminal or screen.
- Navigate to the dropbox website in lynx. lynx https://dropbox.com/
- Log in to your dropbox account
- Now navigate to the link you were provided. To do this; make sure you’re not focused in a text-box (using cursor keys) and press g. You can now paste your client link url and hit enter.
- On this page you will be asked to re-confirm your password… it’s quite a long way down the page.
- Switch back to your other terminal/screen where the linking process is still running and after a second or two it should link!
- Continue these instructions below to start dropbox
Type the link on a computer which has a browser
If
you do not have or cannot install a browser on the computer on which
you wish to install Dropbox, this is the easy workaround which needs
no knowledge of networks.
- Get to the client not linked stage of the process above
- Log into your dropbox account in a browser window on another system.
- Type the URL given in the client not linked stage into the browser
- Enter your dropbox password when prompted
- You should then receive a message to confirm the client has been linked.
- Switch back to your other computer where the linking process is still running and after a second or two it should link!
- Continue these instructions below to start dropbox
Use an SSH tunnel from a computer which has a browser
You
can also create a SOCKS tunnel through SSH from another computer that
has a browser and link the client through that.
From
computer with browser:
ssh -D 9999 username@ip-address-of-computer-to-install-dropbox-on
Now
enable SOCKS proxy in Firefox (or your browser of choice) with host
as ‘localhost’ and port as ‘9999’ and navigate to the link
echoed by dropboxd. Log in to authenticate your client and you’re
done! Use Google for
more help on using SSH as a SOCKS proxy.
dropboxd didn’t give me a link URL!
Notes on Custom Python Scripts
pyDropboxValues
I
have created a (hopefully) ‘better’ version of
dbreadconfig.py here.
You can then replace the call to dbreadconfig.py above with
pyDropboxValues.py _linkurl. I won’t update the instructions above
though till I get feedback that my version works correctly. —
AndrewS 2010-10-15 01:41:03
dbreadconfig.py
- dbreadconfig.py fails on my machine (gutsy) when importing ctypes. Try deleting all the code which uses ctypes, since you only need that for Windows anyway. — TrevorB 2009-03-18 01:52:58
- dbreadconfig.py failed on my Ubuntu 8.04 – I just had to apt-get install gcc and libc6-dev. — Mario
- Also, separately, please put each import statement on a different line so that debugging can go much faster, among other reasons (PEP 8). — jperla
- If dropboxd just exits without any reason, check that you allow enough size for data seg, stack, virtual memory (ulimit -a). — tomle
- Sometimes you need to use python2.6 instead of just python
python2.6 ~/bin/dropbox.py help
- dropbox can also be set up on a shared hosting account, the only difference with this here Dropbox With Daemontools is that rather than creating a new user one has to follow the instruction with the same user available for the hosting account. – luisc
Post-installation
Following
on from that, there are a few different options to run the Dropbox
client on an ongoing basis. You could put the above line in your
server startup scripts, e.g. /etc/rc.local, or maybe just a certain
user’s login scripts.
It
is recommended to download the official
Dropbox CLI to
start the dropbox daemon (as an unprivileged user) and get its
status.
$ mkdir -p ~/bin
$ wget -O ~/bin/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py"
$ chmod 755 ~/bin/dropbox.py
$ ~/bin/dropbox.py help
In
case you get the following error (after trying to run the Dropbox
CLI):
$ ~/bin/dropbox.py help File "/home/username/bin/dropbox.py", line 91 with open(pidfile, "r") as f: ^ SyntaxError: invalid syntax
update
to Python 2.6 and it will go away. Or better try python2.6 rather
than your plain command python as you may already have it installed.
NOTE:
For CentOS users, use either the EPEL or IUS repo to install the
python26.<arch> RPM. The package installs Python 2.6 in
parallel to the distribution default version. This way YUM will not
be effected by the newer version. Once installed update the hash-bang
line to refer to /usr/bin/python26 or /usr/bin/python2.6.
Changing the dropbox folder location
To
move an existing dropbox folder to /foo/bar:
$ dropbox stop $ cp ~/.dropbox/dropbox.db dropbox.db.backup $ wget http://dl.dropbox.com/u/119154/permalink/dropboxdir.py $ chmod +x dropboxdir.py $ mv ~/Dropbox /foo/bar $ ./dropboxdir --setfolder=/foo/bar $ dropbox start
(Do not just
create a new empty directory and setfolder to it – when you restart
dropbox, it will think you’ve deleted all your files, and delete
them from everywhere else too.)
(The
script dropboxdir.py must be located in parent directory to
~/.dropbox-dist/ )
Note: the
script above currently only works for Dropbox 0.7.x and not 1.0.x
– for Dropbox 1.0 you can use this
PHP script
or this
Python script.
Using symbolic links to move the folder location
$ dropbox stop $ mv ~/Dropbox /target/folder $ ln -s /target/folder/Dropbox ~/ $ dropbox start
Suppress LAN Sync broadcasts
To
stop dropbox from sending LAN Sync broadcasts every 30 seconds over
port 17500 (http://forums.dropbox.com/topic.php?id=16253)
see DisableLanSync
Unlink / Relink Dropbox account
You
shouldn’t need to do this, but occasionally it can fix “odd
quirks”, so is often recommended as a troubleshooting tip on the
forums.
To
unlink:
$ dropbox stop $ mv ~/.dropbox ~/.dropbox.old
To
relink:
$ dropbox start
Running on system startup
Some
*nix boxes will let you use “cron” to ensure that dropbox starts
up when the machine boots. I’ve done this by putting
@reboot $HOME/.dropbox-dist/dropboxd
into
my crontab. Do “man 5 crontab” in a console window to see if your
flavor of cron supports that syntax.
You
can also use an init.d or event.d script to automatically run
dropboxd. Click below for the correct script for your Linux
distribution.
+
Debian/Ubuntu
Two
main steps needed:
1.
Create /etc/init.d/dropbox
Change
DROPBOX_USERS to include all users that want to run dropboxd
(separated by spaces), and save the file to /etc/init.d/dropbox. You
need root permission to do it. You might also have to specify the
full path to start-stop-daemon if it is not in your $PATH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/sh#dropbox
serviceDROPBOX_USERS="user1
user2"DAEMON=.dropbox-dist/dropboxstart()
{ echo
"Starting
dropbox..." for
dbuser
in
$DROPBOX_USERS;
do HOMEDIR=`getent
passwd
$dbuser
| cut
-d:
-f6` if
[
-x $HOMEDIR/$DAEMON ]; then HOME="$HOMEDIR"
start-stop-daemon
-b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON fi done}stop()
{ echo
"Stopping
dropbox..." for
dbuser
in
$DROPBOX_USERS;
do HOMEDIR=`getent
passwd
$dbuser
| cut
-d:
-f6` if
[
-x $HOMEDIR/$DAEMON ]; then start-stop-daemon
-o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON fi done}status()
{ for
dbuser
in
$DROPBOX_USERS;
do dbpid=`pgrep
-u $dbuser dropbox` if
[
-z $dbpid ] ; then echo
"dropboxd
for USER $dbuser: not running." else echo
"dropboxd
for USER $dbuser: running (pid $dbpid)" fi done}case
"$1"
in start) start ;; stop) stop ;; restart|reload|force-reload) stop start ;; status) status ;; *) echo
"Usage:
/etc/init.d/dropbox
{start|stop|reload|force-reload|restart|status}" exit
1esacexit
0 |
2.
Make the script executable and add it to the system startup
sudo chmod +x /etc/init.d/dropbox
sudo update-rc.d dropbox defaults
3.
For Debian you might need to add to the very beginning:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
###
BEGIN INIT INFO#
Provides: dropbox#
Required-Start: $local_fs $remote_fs $network $syslog $named#
Required-Stop: $local_fs $remote_fs $network $syslog $named#
Default-Start: 2 3 4 5#
Default-Stop: 0 1 6#
X-Interactive: false#
Short-Description: dropbox service###
END INIT INFO |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#
chkconfig: 345 85 15#
description: Startup script for dropbox daemon##
processname: dropboxd#
pidfile: /var/run/dropbox.pid#
config: /etc/sysconfig/dropbox####
BEGIN INIT INFO#
Provides: dropboxd#
Required-Start: $local_fs $network $syslog#
Required-Stop: $local_fs $syslog#
Should-Start: $syslog#
Should-Stop: $network $syslog#
Default-Start: 2 3 4 5#
Default-Stop: 0 1 6#
Short-Description: Start up the Dropbox file syncing daemon#
Description: Dropbox is a filesyncing sevice provided by
dropbox.com#
This service starts up the dropbox daemon.###
END INIT INFO#
Source function library..
/etc/rc.d/init.d/functions#
To configure, add line with DROPBOX_USERS="user1 user2"
to /etc/sysconfig/dropbox#
Probably should use a dropbox group in /etc/groups instead.[
-f /etc/sysconfig/dropbox
]
&& . /etc/sysconfig/dropboxprog=dropboxdlockfile=${LOCKFILE-/var/lock/subsys/$prog}config=${CONFIG-/etc/sysconfig/dropbox}RETVAL=0start()
{ echo
-n
$"Starting
$prog" if
[
-z $DROPBOX_USERS ] ; then echo
-n
":
unconfigured: $config" echo_failure echo rm
-f
${lockfile} ${pidfile} RETURN=6 return
$RETVAL fi for
dbuser
in
$DROPBOX_USERS;
do daemon
--user $dbuser /bin/sh
-c
"~$dbuser/.dropbox-dist/dropboxd&" done RETVAL=$? echo [
$RETVAL = 0 ] && touch
${lockfile} return
$RETVAL}status()
{ for
dbuser
in
$DROPBOX_USERS;
do dbpid=`pgrep
-u $dbuser dropbox | grep
-v
grep` if
[
-z $dbpid ] ; then echo
"dropboxd
for USER $dbuser: not running." else echo
"dropboxd
for USER $dbuser: running (pid $dbpid)" fi done}stop()
{ echo
-n
$"Stopping
$prog" for
dbuser
in
$DROPBOX_USERS;
do killproc
~$dbuser/.dropbox-dist/dropbox done RETVAL=$? echo [
$RETVAL = 0 ] && rm
-f
${lockfile} ${pidfile}}#
See how we were called.case
"$1"
in start) start ;; status) status ;; stop) stop ;; restart) stop start ;; *) echo
$"Usage:
$prog {start|status|stop|restart}" RETVAL=3esacexit
$RETVAL |
Using Upstart
If
you want to use the newer upstart init present on Ubuntu
installations and are running dropboxd under a sandbox user (say,
dropbox), you can place the following script into /etc/event.d,
naming it dropbox
start on runlevel 2 start on runlevel 3 start on runlevel 4 start on runlevel 5 stop on shutdown respawn script
# Without next line DB does not sync non ASCII characters (ubuntu 10.04-x86_64, db 0.7.110)
export LANG=en_US.UTF-8 cd /home/dropbox exec sudo -H -u dropbox ./.dropbox-dist/dropbox end script
After
creating the file, run initctl and you’re set! Alternatively, if
only one user of the system is running Dropbox, you can run the
script as that user, replacing /home/dropbox with /home/USERNAME and
sudo -H -u dropbox with sudo -H -u USERNAME
If
gives the error about the job not existing, although this time it
says: Unknown job: dropbox
Put
the content of the script on: /etc/init/dropbox.conf
(The
latter version is for Ubuntu 10.4 and, presumably, later versions.)
Fedora/Redhat
Look
above for the Fedora/RedHat init.d
script. Save it to /etc/init.d/dropbox.
Add
the file /etc/sysconfig/dropbox with one line setting the variable
DROPBOX_USERS to include all users that want to run dropboxd in
quotes and separated by spaces.
$ cat /etc/sysconfig/dropbox DROPBOX_USERS="user1 user2"
Fix
file permissions:
$ /bin/chmod 0755 /etc/init.d/dropbox $ /bin/chmod 0644 /etc/sysconfig/dropbox $ /bin/ls -l /etc/init.d/dropbox /etc/sysconfig/dropbox
Fix
SELinux permissions:
$ /usr/bin/chcon -u system_u -t initrc_exec_t /etc/init.d/dropbox
$ /usr/bin/chcon -u system_u -t etc_t /etc/sysconfig/dropbox $ /bin/ls -lZ /etc/init.d/dropbox /etc/sysconfig/dropbox
For
Fedora/RedHat run:
$ chkconfig dropbox on
Verify
it worked. You should see dropbox in the list.
$ chkconfig --list | egrep '3:on|5:on' | less
In
Fedora 15 or other systems using systemd, add the following as the
first line in the init.d script:
#!/bin/sh
Gentoo
Look
above for the Gentoo init.d
scripts.
rc-update add dropbox default
openSuse 11.3
Look
above for the openSuse init.d
scripts.
No comments:
Post a Comment