Inicio > linux > Instalar como servicio dropbox en ambiente Linux

Instalar como servicio dropbox en ambiente Linux

Fuente: http://archive.ianwinter.co.uk/2011/05/16/centos-and-dropbox/

Fuente: http://ubuntuservergui.com/ubuntu-server-guide/install-dropbox-ubuntu-server

Una vez hecho todos los pasos, incorporar a crontab el arranque automático de dropbox como servicio

@reboot <ruta usuario dropbox>/.dropbox-dist/dropboxd

Just because I can really I setup Dropbox syncing on one of my CentOS 5 servers. It’s a little bit of a faff, but, not that hard. The official guide is online, but, this is a shorten version and might not cover everything but it worked on my headless VM just fine.

First up su to whichever user you want to install Dropbox as. You’ll need two terminal’s open so fire them both up now. You’ll also need lynx, gcc and python installed so if you don’t have, sort that out with yum.

In your home directory grab the correct binary for you (x86 or x86_64).

Now unpack it and start it up in your first terminal window.

1
2
tar xvfz dropbox.tar.gz
~/.dropbox-dist/dropboxd

Now in your second terminal go to http://dropbox.com using lynx (lynx http://dropbox.com) and login, then using the key shortcut “g” paste in the URL that your first window should now be prompted you to go to. This is to register the machine with your Dropbox account. You’ll need to scroll down the page to re-enter your password. Once done the first window should say hello to you and it’ll quit.

Next up sort out the init.d script. Put the following in /etc/init.d/dropbox and chown 755 it when you’re done.

01
02
03
04
05
06
07
08
09
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
# 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/dropbox
prog=dropboxd
lockfile=${LOCKFILE-/var/lock/subsys/$prog}
config=${CONFIG-/etc/sysconfig/dropbox}
RETVAL=0
start() {
    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 "/home/$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 /home/$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=3
esac
exit $RETVAL

Edit /etc/sysconfig/dropbox and add the following line to match your linux account where you’ve installed Dropbox.

1
DROPBOX_USERS="linux_user_name"

Make sure it starts on boot.

1
chkconfig dropbox on.

That’s it. Enjoy.

  • Jan van der Lugt • a day ago

    Great script! Better yet, only grep if $dbuser occurs at the start of the line and ends with a semicolon (to avoid matching of a partial username). Same fix for stopping.

    45c45,46
    < daemon –user $dbuser /bin/sh -c “/home/$dbuser/.dropbox-dist/dropboxd&”

    > dbuser_home=`cat /etc/passwd | grep “^$dbuser:” | cut -d”:” -f6`
    > daemon –user $dbuser /bin/sh -c “$dbuser_home/.dropbox-dist/dropboxd&”
    67c68,69
    < killproc /home/$dbuser/.dropbox-dist/dropbox

    > dbuser_home=`cat /etc/passwd | grep “^$dbuser:” | cut -d”:” -f6`
    > killproc $dbuser_home/.dropbox-dist/dropbox

  • Reply
  • Share ›
  • Avatar
    Simon Inglis • 8 months ago

    Thanks for the script. Here’s a minor improvement to handle user home directories that aren’t under /home (as is the case with my Jenkins install)

    45c45,46
    dbuser_home=`cat /etc/passwd | grep “$dbuser” | cut -d”:” -f6`
    > daemon –user $dbuser /bin/sh -c “$dbuser_home/.dropbox-dist/dropboxd&”

  • Reply
  • Share ›
  • Avatar
    steve • a year ago

    merci!
    Put the above in /etc/init.d/dropbox and chmod 755 it when you’re done.
    not chown;
    thank you!

  • Reply
  • Share ›
  • Avatar
    Robert Son Hedler • a year ago

    Thank you very much, it works very well!!!

Categorías:linux Etiquetas: ,
  1. Aún no hay comentarios.
  1. No trackbacks yet.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: