DNS 325 - Funplug 0.7 : Setup your NAS as a Permanent BTSync Peer

Contents[Hide]

dropcap-dns325-btsync

BitTorrent Sync is a young p2p tool which opens some fantastic possibilities. It may revolutionize the way you'll handle your private file sharing as it allows you to share & synchronize your files across multiple devices (PC, tablet, smartphone, ...) on the net in almost real time.

Some examples of the possibilities opened by BTSync are described in the article BTSync - How peer-to-peer may Simplify your Life.

Like with any p2p network, BTSync needs to get some accessible peers to start synchronisation.

So, to allow synchronisation to be done at any time, you can setup a permanent BTSync peer on a NAS running 24/24. As your NAS is always connected, it will handle all your devices connexions whenever they need it.

This article explains how to install a BTSync client on a DNS-325. It will transform it as a permanent BTSync network peer. Any device (PC, smartphone, tablet, ...) will then be able to synchronize any time. You will have then created your self hosted Dropbox or Google Drive replacement.

It has been tested on a DNS-325 running firmware 1.04. As a pre-requisite, funplug 0.7 must be installed on your DNS-325.

1. Main Principles

BTSync binary is available for ARM devices, but after some tests, it appeared that it has some slight constraints in terms of working environment in comparison to other builds.

So, as a result of these constraints, installation on DNS-325 won't really follow Linux best practices, with executable, configuration file, PID & application internal located in the same directory structure.

Obviously, your synchronised data files will be hosted wherever you want in any sub-directory of Volume_1 or Volume_2. If needed, these data will be accessible like any other data on the NAS via network shares.

On a DNS-325, all data handled thru network shares are owned by nobody:allgroup, whatever local user account is accessing these data.

So, BTSync process will have to run as nobody, allowing the process to read and write all synchronised data as they may also be accessed via some network shares.

This setup will allow you to manage your data files indifferently thru BTSync process and network shares.

To avoid uPnP permanent indexing that may end-up eating your NAS limited memory,, uPnP has been disabled in the default configuration.

BTSync process will listen on :

  • 8888 for web connections
  • 8889 for p2p connections

On DNS-320B, if BTSync daemon runs under nobody, it won't access the full fileystem and it won't be able generate secret keys.
To make it run on DNS-320B, you need to run BTSync damon under root account.
So, replace nobody by root on any command or configuration file, and it will work !

2. Installation

Complete installation will be done under /ffp/home/btsync.

As explained earlier, this directory will host the executable, the configuration file and all application internal data.

It will be owned by nobody:allgroup to allow BTSync process to run as user nobody.

Latest stable BTSync executable will be downloaded from http://www.bittorrent.com/. But, as at the time of this article version 1.4 seems to be still buggy, it is advisable to download latest v1.3. This version can be downloaded from http://syncapp.bittorrent.com/1.3.109/ and is which is supposed to be fully compatible with 1.4 clients.

In case you want to try it, latest 1.4 version is available from http://syncapp.bittorrent.com/1.4.111/.

Following commands will setup a complete BTSync environment on the DNS-325 :

DNS 325 console
# mkdir -p /ffp/home/btsync
# wget -O btsync.tar.gz http://syncapp.bittorrent.com/1.3.109/btsync_arm-1.3.109.tar.gz
# tar -zxvf btsync.tar.gz -C /ffp/home/btsync && rm btsync.tar.gz
# chmod +x /ffp/home/btsync/btsync
# wget --no-check-certificate -O /ffp/home/btsync/btsync.conf https://raw.githubusercontent.com/NicolasBernaerts/dns325-scripts/master/btsync/btsync.conf
# chown -R nobody:allaccount /ffp/home/btsync

Do not forget to edit /ffp/home/btsync/btsync.conf and to change your administration login and password.

/ffp/home/btsync/btsync.conf
{
  "device_name"    : "DNS-325",
  "listening_port" : 8889,
  "storage_path"   : "/ffp/home/btsync",
  "pid_file"       : "/ffp/home/btsync/btsync.pid",
  "use_upnp"       : false,
  "download_limit" : 0,
  "upload_limit"   : 0,
  "webui" :
  {
    "listen"   : "0.0.0.0:8888",
    "login"    : "admin",
    "password" : "password"
  }
}

Basic setup is now complete. You can start and test BTSync in its final environment :

DNS 325 console
# su -c "/ffp/home/btsync/btsync --nodaemon --config /ffp/home/btsync/btsync.conf" nobody
By using this application, you agree to our Privacy Policy, Terms of Use and End User License Agreement.
http://www.bittorrent.com/legal/privacy
http://www.bittorrent.com/legal/terms-of-use
http://www.bittorrent.com/legal/eula

[20140906 10:14:01.391] total physical memory -1 max disk cache 2097152
[20140906 10:14:01.392] Installing 'sync.lng' to '/ffp/home/btsync/sync.lng'.
Loading config file version 1.3.109
...

btsync process will start to populate /ffp/home/btsync with its own non public data files.

You should now be able to connect to http://ip.of.dns.325:8888/.

Just type your administration login / password.

In the web interface, you can check thru menu preferences that you default configuration has been taken into account.

dns325-btsync-config

You can stop the running process with CTRL+C.

3. Startup Script

To allow BTSync to start at every boot, we need to create a startup script under /ffp/start/btsync.sh.

Startup script will simply handle BTSync process launch under user nobody.

/ffp/start/btsync.sh
#!/ffp/bin/sh
#
# BTSync startup script
#
# History :
#  08/09/2014, V1.0 - Creation by N. Bernaerts

# PROVIDE: btsync
# REQUIRE: LOGIN

. /ffp/etc/ffp.subr

name="btsync"
start_cmd="btsync_start"
stop_cmd="btsync_stop"
restart_cmd="btsync_restart"

# set environment
BTSYNC_CMD="/ffp/home/btsync/btsync"
BTSYNC_PID="/ffp/home/btsync/btsync.pid"
BTSYNC_CONF="/ffp/home/btsync/btsync.conf"
BTSYNC_USER="nobody"

btsync_start()
{
  # start btsync with default configuration under user nobody
  su -c "$BTSYNC_CMD --config $BTSYNC_CONF" $BTSYNC_USER
}

btsync_stop()
{
  # kill running instance from PID
  kill $(cat $BTSYNC_PID)

  # delete PID file
  rm $BTSYNC_PID
}

btsync_restart()
{
  # kill running instance from PID
  kill $(cat $BTSYNC_PID)

  # delete PID file
  rm $BTSYNC_PID

  # start btsync with default configuration under user nobody
  su -c "$BTSYNC_CMD --config $BTSYNC_CONF" $BTSYNC_USER
}

# run the command given as parameter
run_rc_command "$1"

You can now start BTSync daemon :

DNS 325 console
# wget --no-check-certificate -O /ffp/start/btsync.sh https://raw.githubusercontent.com/NicolasBernaerts/dns325-scripts/master/btsync/btsync.sh
# sh /ffp/start/btsync.sh start

If everything is running fine you should be able to connect to http://ip.of.dns.325:8888/.

To automatically start BTSync at boot, just make the script executable :

DNS 325 console
# chmod +x /ffp/start/btsync.sh

You are now having a 24h/24 BTSync peer running on your DNS-325.

Only remaining action is to create and/or declare your BTSync peers.

 dns325-btsync-synchro

 

Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus