Install Bit Torrent Sync On Ubuntu

by admin admin Date: 15-01-2014 torrent ubuntu sync server share


There are some great tools for syncing files over the internet available to us, but one stands out from the rest in regards of technology used and possible use cases.

A public beta version was released in June this year and now it’s available for Windows, Mac, Linux, FreeBSD, Android and iOS. Today we are going to setup BitTorrent Sync on Ubuntu Server. You may need btsync on your server for Backing up configuration and database files, Access code repositories or Create a synchronized documents network folder for your company.

 

 

  1. Go to a temporary folder
    $ cd /tmp
  2. Download the correct version of BitTorrent Sync, depending on your system (i386 or x64)
    $ wget -O btsync.tar.gz http://download-lb.utorrent.com/endpoint/btsync/os/linux-i386/track/stable
    OR
    $ wget -O btsync.tar.gz http://download-lb.utorrent.com/endpoint/btsync/os/linux-x64/track/stable
  3. Unpack the downloaded compressed tar
    $ tar -xf btsync.tar.gz
  4. Now we move the executable to our /usr/local/bin directory
    $ sudo mv btsync /usr/local/bin/
  5. Create a default sync folder
    $ mkdir ~/.sync
  6. We need to create a confguration file for btsync by dumping a sample configuration file
    $ btsync --dump-sample-config > ~/.btsync
  7. Edit the configuration file with
    $ nano ~/.btsync
    and change "storage_path" to reflect the sync folder we created above (Eg /home/yourusername/.sync) and add a username and a password to secure btsync admin panel. Make sure you uncomment the lines containing login information so they are read by btsync
  8. To be able to easily control btsync daemon we need to create a service init.d script and make it executable
    $ sudo touch /etc/init.d/btsync
    $ sudo chmod +x /etc/init.d/btsync
  9. Paste the following content in our /etc/init.d/btsync script and make sure you change the user variable with your username.
    $ sudo nano /etc/init.d/btsync

     

    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:   btsync
    # Required-Start: $syslog $remote_fs
    # Required-Stop:  $syslog $remote_fs
    # Should-Start:   $local_fs
    # Should-Stop:    $local_fs
    # Default-Start:  2 3 4 5
    # Default-Stop:   0 1 6
    # Short-Description:  btsync - Bittorent SyncApp
    # Description:    btsync - Bittorent SyncApp
    ### END INIT INFO
    
    user="yourusername" # YOU MUST REPLACE THIS BY YOUR USER
    
    group=`id -ng "$user"`
    
    # the full path to the filename where you store your btsync configuration
    config="`su -c 'echo $HOME' $user`/.btsync"
    
    # set of options to run with
    options=""
    
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/local/bin/btsync
    DAEMON_ARGS="--config $config"
    NAME=btsync
    DESC=btsync
    
    RUNDIR=/var/run/syncapp
    PIDFILE=$RUNDIR/syncapp.pid
    
    test -x $DAEMON || exit 0
    
    if [ -r /etc/default/$NAME ]
    then
      . /etc/default/$NAME
    fi
    
    set -e
    
    case "$1" in
      start)
      echo -n "Starting $DESC: "
      mkdir -p $RUNDIR
      touch $PIDFILE
      chown $user:$group $RUNDIR $PIDFILE
      chmod 755 $RUNDIR
    
      if [ -n "$ULIMIT" ]
      then
        ulimit -n $ULIMIT
      fi
    
      if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid $user:$group --exec $DAEMON -- $DAEMON_ARGS
      then
        echo "$NAME."
      else
        echo "failed"
      fi
      ;;
      stop)
      echo -n "Stopping $DESC: "
      if start-stop-daemon --stop --retry forever/TERM/1 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
      then
        echo "$NAME."
      else
        echo "failed"
      fi
      rm -f $PIDFILE
      sleep 1
      ;;
    
      restart|force-reload)
      ${0} stop
      ${0} start
      ;;
    
      status)
      echo -n "$DESC is "
      if start-stop-daemon --stop --quiet --signal 0 --name ${NAME} --pidfile ${PIDFILE}
      then
        echo "running"
      else
        echo "not running"
        exit 1
      fi
      ;;
    
      *)
      echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
      exit 1
      ;;
    esac
    
    exit 0
  10. Lets make our init.d script start with the server
    $ cd /etc/init.d/ && sudo update-rc.d btsync defaults
  11. Start btsync daemon with the following command and go to http://yourserverip:8888 to add folders you want to synchronize
    $ sudo service btsync start

 

 
by admin admin Date: 15-01-2014 torrent ubuntu sync server share hits : 7836  
 
 
 
 

Related Posts