Dropbox is a wonderful file sharing and syncing platform. Its ease of use and and availability on different platforms and devices has made it much popular. At the end of the HowTo article you will be able to use Dropbox on your Headless using line.

Installing Dropbox via Command Line

Dropbox daemon runs pretty well on 32-bit and 64-bit servers. I have tested this on RHEL ( ) & Ubuntu. To , run the following command in your Linux terminal.

For 32-bit:

cd ~ && wget -O – “https://www.dropbox.com/download?plat=lnx.x86” | tar xzf –

For 64-bit:

cd ~ && wget -O – “https://www.dropbox.com/download?plat=lnx.x86_64” | tar xzf –

Now, run the Dropbox daemon from the newly created .dropbox-dist folder
# ~/.dropbox-dist/dropboxd &

If you’re running Dropbox on your server for the first time, you’ll be asked to copy and paste a link in a working browser to create a new account or add your server to an existing account. Once you do, your Dropbox folder will be created in your home directory.

 

Dropbox.py Script

Theres a fantastic python script to control your dropbox daemon. To install and use it follow this steps

[root@server ~]# wget https://www.dropbox.com/download?dl=packages/dropbox.py -O /sbin/dropbox.py

[root@server ~]# chmod a+x /sbin/dropbox.py

[root@server ~]# dropbox.py status
Uploading 1 file (256.2 kB/sec, 1 hr left)

[root@server Dropbox]# dropbox.py filestatus
.dropbox:            up to date
.dropbox.cache:      unwatched
myfiles:              syncing
Getting Started.pdf: up to date
Photos:              up to date

[root@server Dropbox]# dropbox.py help
Dropbox command-line interface

commands:

Note: use dropbox help to view usage for a specific command.

status       get current status of the dropboxd
help         provide help
puburl       get public url of a file in your dropbox
stop         stop dropboxd
running      return whether dropbox is running
start        start dropboxd
filestatus   get current sync status of one or more files
ls           list directory contents with current sync status
autostart    automatically start dropbox at login
exclude      ignores/excludes a directory from syncing
lansync      enables or disables LAN sync

You will now see a directory named Dropbox. Any thing that you wish dropbox to backup/upload to cloud just put it in here.

# ls Dropbox
# dropbox lansync n
# dropbox autostart y

Lets create a startup script. Replace “keenan” with your linux account username on line 4. I found this script here.

# vi /etc/init.d/dropbox

#!/bin/sh
# dropbox service
# Replace with linux users you want to run Dropbox clients for
DROPBOX_USERS="keenan"
DAEMON=.dropbox-dist/dropbox
start() {
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 1
esac
exit 0

Make this script executable. And enter this in rc.local so it starts automatically when system boots.

# chmod 755 /etc/init.d/dropbox
# vi /etc/rc.local
 
Enter this line just above exit 0/etc/init.d/dropbox start

Print Friendly

Comments

comments

Bài viết liên quan