facelordgists
1/10/2014 - 1:28 AM

Setup Dropbox on Debian 64bit

Setup Dropbox on Debian 64bit

  1. Install Dropbox

  2. Add this line to ~/.profile

     export PATH=$HOME/bin:$PATH
    
  3. Create /etc/init.d/dropbox

  4. Add the contents of the file below

  5. Make the script executable and add it to the system startup

     sudo chmod +x /etc/init.d/dropbox 
     sudo update-rc.d dropbox defaults
    
  6. You can safely ignore the following messages

     update-rc.d: using dependency based boot sequencing
     insserv: warning: script 'dropbox' missing LSB tags and overrides
    
  7. You can restart your server to test it. Use with caution though. I'd only do this on a dev box.

    1. Restart your Debian box
    2. shutdown -r now
    3. Test if it worked:
    4. ~/bin/dropbox.py status

Give www-data user read and write access to Dropbox files

Install Access Control List

sudo apt-get install acl

Give www-data user read, write & execute access to dropbox files

setfacl -Rm u:www-data:rwx /root/Dropbox

Set as default, recursively to inherit these settings on newly created files

setfacl -dRm u:www-data:rwx /root/Dropbox

If thumbnail generation isn't working

Install the GD Library

apt-get install php5-gd

To allow a bash script executed by PHP to perform sudo commands

  • Start by creating an entry in the sudoers list. You can name it whatever you want, "Webserver" can be named anything because any file in this directory is automatically included.

      visudo -f /etc/sudoers.d/Webserver
    
  • Add the following to it:

      www-data ALL = (root) NOPASSWD: /var/www/kirby-farm/conf/parse_clients.sh
    
  • press control + x then type Y and hit enter

#!/bin/sh
#located at /etc/init.d/dropbox
#dropbox service
DROPBOX_USERS="root"
 
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