Get the most out of your Centmin Mod LEMP stack
Become a Member

Dropbox CentOS installer Addon (maybe discussion) ?

Discussion in 'Add Ons' started by eva2000, Jun 16, 2014.

  1. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,137
    Local Time:
    3:42 AM
    Nginx 1.13.x
    MariaDB 5.5
    Anyone interested in a Dropbox installer for CentOS for Centmin Mod usage ? By default Dropbox free accounts give you 2.5GB of free space. Might be enough for syncing some server files as a backup ?

    Referral Link
    My Dropbox referral link if you haven't created a Dropbox account yet https://db.tt/RSWa3cqn

    Never used Dropbox like this before myself, but it seems it was pretty easy to setup by following guide at http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-centos-gui-required. I had to modify the /etc/init.d/dropbox script a tad to properly use with root user to get the start, stop and status options working. I also added an additional option to the /etc/init.d/dropbox script to report the Dropbox version number as well as syncing status output.

    Right now, very rough early draft of the Dropbox installer just does the default and setup /root/Dropbox as the default syncing folder. Need to figure out how to change the default syncing folder's path :)

    Code:
    ls -lah /root/Dropbox/
    total 16K
    drwx------   3 root root 4.0K Jun  8 23:17 .
    dr-xr-x---. 10 root root 4.0K Jun  8 22:25 ..
    -rwxr-xr-x   1 root root   49 Jun  8 23:06 .dropbox
    drwxr-xr-x   3 root root 4.0K Jun  8 23:16 .dropbox.cache
    -rw-r--r--   1 root root    0 Jun  8 23:17 text2.txt
    Example of the /etc/init.d/dropbox script setup as follows:

    Code:
    service dropbox status
    dropboxd for USER root: running (pid 29680)
    
    service dropbox
    Usage: dropboxd {start|status|stop|restart|version|syncstatus}
    
    service dropbox version
    Dropbox 2.8.3
    
    service dropbox syncstatus
    Syncing "1.8.31.3.tar.gz" (5 mins left)
    Uploading "1.8.31.3.tar.gz" (368.2 KB/sec, 5 mins left)
    
    Code:
    touch /etc/sysconfig/dropbox
    
    echo "DROPBOX_USERS=\"root\"" > /etc/sysconfig/dropbox
    
    touch /etc/init.d/dropbox
    chmod 755 /etc/init.d/dropbox
    
    cat > "/etc/init.d/dropbox" <<EOF
    # 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
            dbuser_home=`cat /etc/passwd | grep "^\$dbuser:" | cut -d":" -f6`
            if [[ "\$dbuser" = 'root' ]]; then
                daemon --user \$dbuser /bin/sh -c "~/.dropbox-dist/dropboxd&"
            else
                daemon --user \$dbuser /bin/sh -c "\$dbuser_home/.dropbox-dist/dropboxd&"
            fi
        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
            dbuser_home=`cat /etc/passwd | grep "^\$dbuser:" | cut -d":" -f6`
            if [[ "\$dbuser" = 'root' ]]; then
                killproc ~/.dropbox-dist/dropbox
            else
                killproc \$dbuser_home/.dropbox-dist/dropbox
            fi
        done
        RETVAL=\$?
        echo
        [ \$RETVAL = 0 ] && rm -f \${lockfile} \${pidfile}
    }
    
    ver() {
        echo 'Dropbox '`cat ~/.dropbox-dist/VERSION`
    }
    
    syncinfo() {
        ~/bin/dropbox.py status
    }
    
    # See how we were called.
    case "\$1" in
        start)
            start
            ;;
        status)
            status
            ;;
        stop)
            stop
            ;;
        restart)
            stop
            start
            ;;
        version)
            ver
            ;;
        syncstatus)
            syncinfo
            ;;
        *)
            echo \$"Usage: \$prog {start|status|stop|restart|version|syncstatus}"
            RETVAL=3
    esac
    exit \$RETVAL
    EOF
    
    service dropbox start
    chkconfig dropbox on
     
    Last edited: Jun 16, 2014
  2. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,137
    Local Time:
    3:42 AM
    Nginx 1.13.x
    MariaDB 5.5
  3. pamamolf

    pamamolf Well-Known Member

    2,724
    242
    63
    May 31, 2014
    Ratings:
    +433
    Local Time:
    8:42 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    Not need it, space to small :)
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,137
    Local Time:
    3:42 AM
    Nginx 1.13.x
    MariaDB 5.5
    Well Dropbox do have paid upgrades for 100+GB storage and/or referral link bonuses for 500MB per referral up to 16GB, so with 32 referral/invites you can have 2.5 + 16 = 18.5GB free space.

    Also with Dropbox with Android and other clients you can also sync files between your server and mobile devices.

    But there's also free own hosted ownCloud alternative too https://community.centminmod.com/resources/how-to-install-owncloud-on-centmin-mod-nginx.1/ :)
     
    • Like Like x 1