Skip to content

Instantly share code, notes, and snippets.

@briangonzalez
Last active January 5, 2020 18:59
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save briangonzalez/6903025 to your computer and use it in GitHub Desktop.
Save briangonzalez/6903025 to your computer and use it in GitHub Desktop.
Installing Dropbox on CentOS

Setup Dropbox for system startup

The following instructions will get you setup to run Dropbox at system start. Below, also find instructions on how to install the Dropbox CLI.

# Login as root and go into home dir.
sudo su && cd ~

# Download Dropbox depending on architecture (uname -a) and unpack.
# You will need to repeat this "download and unpack" step for all users
# on your machine that need Dropbox.
wget -O dropbox.tar.gz https://www.dropbox.com/download/?plat=lnx.x86      # 32 bit
wget -O dropbox.tar.gz https://www.dropbox.com/download/?plat=lnx.x86_64   # 64 bit
tar xvfz dropbox.tar.gz

# Create init file.
touch /etc/init.d/dropbox
chmod 0755 /etc/init.d/dropbox

# Create config file, which will contain info about which system.
# users to start Dropbox on. 
# Add to this file:
#    DROPBOX_USERS="user1 user2 user3"
touch /etc/sysconfig/dropbox

# Add Dropbox to startup.
chkconfig dropbox on

# Edit /etc/init.d/dropbox and paste in the contents of init.d below.
vi /etc/init.d/dropbox

# Start Dropbox -- note that you will be prompted to link this machine.
service dropbox start

# => This client is not linked to any account...
# => Please visit https://www.dropbox.com/cli_link?host_id=123456 to link this machine.

Install Dropbox CLI

Here are the instructions on how to install the Dropbox CLI.

# Download Dropbox CLI
wget -O /usr/bin/dropbox.py "https://www.dropbox.com/download?dl=packages/dropbox.py"

# Make is executable.
chmod a+x /usr/bin/dropbox.py

# Run it to see options.
dropbox.py
# 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
# normal users
daemon --user $dbuser /bin/sh -c "/home/$dbuser/.dropbox-dist/dropboxd&"
# hint for root
# 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 /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
@chrisgraham
Copy link

paste in the contents of init.d below.
-->
paste in the contents of init.sh below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment