Bittorrent Sync

Marvell Kirkwood based
Post Reply
OyaNET
Posts: 3
Joined: Thu Apr 25, 2013 7:25 am

Bittorrent Sync

Post by OyaNET » Thu Apr 25, 2013 7:35 am

Hello folks,

I'm running an NSA325 for a few months at home, and I've found it really great.

Today I have read an article (http://torrentfreak.com/bittorrents-sec ... ic-130423/) stating that the developers of Bittorrent technology have developed a software to synchronize content between own computers, and after a testing period the technology is now open to public. (ref: http://labs.bittorrent.com/experiments/sync.html#)
They also have code for ARM-based NASes downloadable here: http://btsync.s3-website-us-east-1.amaz ... arm.tar.gz
I'm wondering if anyone can direct me how to install it on the NSA 325 - possibly as a plugin or whatever we call it officially - I'm currently running the original firmware.
BR
Thanks
Oya

barmalej2
Posts: 2398
Joined: Sun Apr 29, 2012 5:24 pm

Re: Bittorrent Sync

Post by barmalej2 » Thu Apr 25, 2013 9:17 am

Simple. Download, extract and run:

Code: Select all

root@NSA310:~# cd /ffp/bin
root@NSA310:~# wget http://btsync.s3-website-us-east-1.amazonaws.com/btsync_arm.tar.gz
--13:13:04--  http://btsync.s3-website-us-east-1.amazonaws.com/btsync_arm.tar.gz
           => `btsync_arm.tar.gz'
Resolving btsync.s3-website-us-east-1.amazonaws.com... 207.171.163.223
Connecting to btsync.s3-website-us-east-1.amazonaws.com[207.171.163.223]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,425,182 [application/x-gzip]

100%[=================================================================================================>] 1,425,182    343.56K/s    ETA 00:00

13:13:09 (290.59 KB/s) - `btsync_arm.tar.gz' saved [1425182/1425182]

root@NSA310:~# tar xvzf btsync_arm.tar.gz
root@NSA310:~# rm btsync_arm.tar.gz
root@NSA310:~# ./btsync
root@NSA310:~# export LD_LIBRARY_PATH=/lib:/usr/lib:/ffp/lib
root@NSA310:~# ldd btsync
        librt.so.1 => /usr/lib/librt.so.1 (0x40005000)
        libdl.so.2 => /lib/libdl.so.2 (0x40014000)
        libm.so.6 => /lib/libm.so.6 (0x4001f000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x400c9000)
        libc.so.6 => /lib/libc.so.6 (0x400e9000)
        ld-linux.so.3 => /lib/ld-linux.so.3 (0x40215000)
root@NSA310:~# ps fj -C btsync
 PPID   PID  PGID   SID TTY      TPGID STAT   UID   TIME COMMAND
    1 23443 23443 23443 ?           -1 Ssl      0   0:00 ./btsync
root@NSA310:~# kill 23443
root@NSA310:~# ps fj -C btsync
 PPID   PID  PGID   SID TTY      TPGID STAT   UID   TIME COMMAND
root@NSA310:~#
root@NSA310:~# ./btsync --help
BitTorrent Sync 1.0.116
Usage:
          btsync [--config <path>] [--nodaemon] [--generate-secret] [--dump-sample-config] [--help] [--get-ro-secret <secret>]
Options:
        --config - location and name of configuration file
        --nodaemon - do not use daemon mode
        --generate-secret - generate shared secret
        --get-ro-secret - get read only secret for existing master secret
        --dump-sample-config - dump sample config file
        --help - print this message and exit
For autostart, you need a basic script placed in /ffp/start/ directory.

OyaNET
Posts: 3
Joined: Thu Apr 25, 2013 7:25 am

Re: Bittorrent Sync

Post by OyaNET » Thu Apr 25, 2013 12:54 pm

Thank you Barmalej,
Will give it a run tonight.

aTan
Posts: 29
Joined: Wed Apr 03, 2013 7:17 pm

Re: Bittorrent Sync

Post by aTan » Fri Apr 26, 2013 2:35 pm

Here is my /ffp/start/btsync.sh and config. btsync is in /ffp/opt/btsync/bin/ and btsync.conf is in /ffp/etc/.

btsync.sh

Code: Select all

#!/ffp/bin/sh

# PROVIDE: btsync
# REQUIRE: LOGIN

. /ffp/etc/ffp.subr

name="btsync"
command="/ffp/opt/btsync/bin/btsync"
restart_cmd="btsync_restart"
start_cmd="btsync_start"
stop_cmd="btsync_stop"

btsync_flags="--config /ffp/etc/btsync.conf"

btsync_start()
{
        echo "Running ${command} ${btsync_flags}"
        ${command} ${btsync_flags}
}

btsync_stop()
{
        killall btsync
}

btsync_restart()
{
        killall btsync
        ${command} ${btsync_flags}
}

run_rc_command "$1"
btsync.conf

Code: Select all

{
  "device_name": "My Bittorrent Sync",
  "listening_port" : 0,                       // 0 - randomize port

/* storage_path dir contains auxilliary app files
   if no storage_path field: .sync dir created in the directory
   where binary is located.
   otherwise user-defined directory will be used
*/
  "storage_path" : "/mnt/HD_a2/.sync",

  "pid_file" : "/ffp/var/run/btsync.pid",


  "check_for_updates" : true,
  "use_upnp" : true,                              // use UPnP for port mapping


/* limits in kB/s
   0 - no limit
*/
  "download_limit" : 0,
  "upload_limit" : 0,

/* remove "listen" field to disable WebUI
   remove "login" and "password" fields to disable credentials check
*/
  "webui" :
  {
    "listen" : "0.0.0.0:8880",
    "login" : "login",
    "password" : "password"
  }
}
NSA-325, 4.80, FFP 0.7.

x3cut3
Posts: 2
Joined: Tue May 14, 2013 11:37 am

Re: Bittorrent Sync

Post by x3cut3 » Tue May 14, 2013 11:46 am

I got it kind of running despite that I could not do that on my nsa325:
(export LD_Library_Path may have worked)
root@NSA310:~# export LD_LIBRARY_PATH=/lib:/usr/lib:/ffp/lib
root@NSA310:~# ldd btsync
librt.so.1 => /usr/lib/librt.so.1 (0x40005000)
libdl.so.2 => /lib/libdl.so.2 (0x40014000)
libm.so.6 => /lib/libm.so.6 (0x4001f000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x400c9000)
libc.so.6 => /lib/libc.so.6 (0x400e9000)
ld-linux.so.3 => /lib/ld-linux.so.3 (0x40215000)
now it won't save files, but it sends files to other computer (dispite that btsync syncs the folder, but those stay empty).

what can I do about that?

Mijzelf
Posts: 6251
Joined: Mon Jun 16, 2008 10:45 am

Re: Bittorrent Sync

Post by Mijzelf » Tue May 14, 2013 2:56 pm

(export LD_Library_Path may have worked)
That LD_LIBRARY_PATH in this case only makes ldd working. Ldd is an FFP program, and so by default it only searches in /ffp/lib. But all used libs are in /lib and /usr/lib, so the binary should start fine without it.

And about not writing, you could add the --nodaemon flag to see if it spawns some usable error message.

x3cut3
Posts: 2
Joined: Tue May 14, 2013 11:37 am

Re: Bittorrent Sync

Post by x3cut3 » Tue May 14, 2013 8:59 pm

ok, my mistake: the test file was somehow hidden, when I opened the folder with windows, maybe because it was a .dat file?

it worked fine from the beginning.
I hope that the workload goes down from 98% after indexing everything.

c3rb3ru5
Posts: 3
Joined: Mon Mar 23, 2015 5:57 pm

Re: Bittorrent Sync

Post by c3rb3ru5 » Mon Mar 23, 2015 6:18 pm

Hello,

I actually try to run bittorrent sync on my Zyxel NSA 325 with firmware version 4.71 (AALS.0). I installed ffp and the package of bittorrent sync for zyxel. But when I try to open the Web-UI of the bittorrent sync package with http://myNASip:8888, the browser start to load, but can not open the Web-UI, I mention other users also have the same problem. So I started to configure bittorrent sync with terminal (I am mac-user).

Code: Select all

c3rb3ru5:~ USER$ ssh root@10.0.0.5
root@10.0.0.5's password:
== Welcome at FFP version 0.7/arm, running on NSA325v2 g-server, firmware V4.71(AALS.0)
== root@g-server:~# cd /ffp/sbin/
root@g-server:/ffp/sbin# wget http://example.com/BitTorrent-Sync_arm.tar.gz
--21:06:16--  http://example.com/BitTorrent-Sync_arm.tar.gz => `BitTorrent-Sync_arm.tar.gz' Resolving example.com... 79.17.141.51
Connecting to example.com[79.17.141.51]:80... connected. HTTP request sent, awaiting response... 200 OK Length: 4,967,740
[application/x-gzip]  100%[====================================>] 4,967,740  1.05M/s ETA 00:00  21:06:22 (965.44 KB/s) - `BitTorrent-Sync_arm.tar.gz' saved [4967740/4967740]
root@g-server:/ffp/sbin# tar -zxvf BitTorrent-Sync_arm.tar.gz
LICENSE.TXT
README
btsync
root@g-server:/ffp/sbin# ./btsync
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
BitTorrent Sync forked to background. pid = 29346. default port = 8888
root@g-server:/ffp/sbin# killall btsync
btsync: no process found
root@g-server:/ffp/sbin#
nano btsync.conf
-sh: nano: command not found
root@g-server:/ffp/sbin# chmod a+x ./btsync
root@g-server:/ffp/sbin# chown root:root ./btsync
root@g-server:/ffp/sbin# cd /ffp/start/
root@g-server:/ffp/start# nano btsync.sh
-sh: nano: command not found
root@g-server:/ffp/start# /usr/bin/nano~/.profil
-sh: /usr/bin/nano: No such file or directory
root@g-server:/ffp/start# sudo nano btsync.conf
-sh: sudo: command not found
root@g-server:/ffp/start# $ sudo nano btsync.conf
-sh: $: command not found
root@g-server:/ffp/start# nano btsync.conf
-sh: nano: command not found
root@g-server:/ffp/start# Connection to 10.0.0.5 closed by remote host.
As you can see I have the problem that the current shell of my zyxel can not execute the command nano. Why do I need the nano command? Because I want to compile the btsync.sh and the btsync.conf file:

btsync.sh (should go to /ffp/start/btsync.sh)

Code: Select all

#!/ffp/bin/sh

# PROVIDE: btsync
# REQUIRE: LOGIN

. /ffp/etc/ffp.subr

name="btsync"
command="/ffp/opt/btsync/bin/btsync"
restart_cmd="btsync_restart"
start_cmd="btsync_start"
stop_cmd="btsync_stop"

btsync_flags="--config /ffp/etc/btsync.conf"

btsync_start()
{
        echo "Running ${command} ${btsync_flags}"
        ${command} ${btsync_flags}
}

btsync_stop()
{
        killall btsync
}

btsync_restart()
{
        killall btsync
        ${command} ${btsync_flags}
}

run_rc_command "$1"
btsync.conf (should go to /ffp/etc/)
{
"device_name": "My Bittorrent Sync",
"listening_port" : 0, // 0 - randomize port

/* storage_path dir contains auxilliary app files
if no storage_path field: .sync dir created in the directory
where binary is located.
otherwise user-defined directory will be used
*/
"storage_path" : "/mnt/HD_a2/.sync",

"pid_file" : "/ffp/var/run/btsync.pid",


"check_for_updates" : true,
"use_upnp" : true, // use UPnP for port mapping


/* limits in kB/s
0 - no limit
*/
"download_limit" : 0,
"upload_limit" : 0,

/* remove "listen" field to disable WebUI
remove "login" and "password" fields to disable credentials check
*/
"webui" :
{
"listen" : "0.0.0.0:8880",
"login" : "login",
"password" : "password"
}
}
I have asked google several times, but I could not find any solution how to enable nano in my shell. To be honest I am an absolut newbie, so I would be very happy about any tipps or step by step instructions.

I also have an own idea: When I start my terminal I am able to use the command nano and I am able to create a new text file (.sh & .conf). So I would like to do the following steps:
1) I create the files btsync.sh and btsync.conf on my terminal in GUI
2) I save these two files on my Macbook
3) I start a new shell seasion on my zyxel and load the new created files (from my macbook) two the regarding directory on my zyxel

My problems:

1) How do I save the created files to my desktop? ( command?)
2) How do I tell my shell to take the created files and load them in the regarding directory? (command?)
3) Do I have any logical issues in this idea?

When I have created and saved the files to the right directory bittorrent sync should run:
Is that right or do I have write any other commands in my shell?

Code: Select all

root@NSA310:~# ./btsync --help
BitTorrent Sync 1.0.116
Usage:
          btsync [--config <path>] [--nodaemon] [--generate-secret] [--dump-sample-config] [--help] [--get-ro-secret <secret>]
Options:
        --config - location and name of configuration file
        --nodaemon - do not use daemon mode
        --generate-secret - generate shared secret
        --get-ro-secret - get read only secret for existing master secret
        --dump-sample-config - dump sample config file
        --help - print this message and exit
I want to use the app bittorrent sync for my macbook, so I need a secret key for sync folder, how do I get this secret key?
root@NSA310:~# ./btsync --generate-secret
Is that right?

I would be very happy about any answers, if possible please format your answer structured and step by step. Thank you very much!

With best regards.

Matthias

barmalej2
Posts: 2398
Joined: Sun Apr 29, 2012 5:24 pm

Re: Bittorrent Sync

Post by barmalej2 » Tue Mar 24, 2015 6:19 am

Well, I am not MAC user, so I can't much advise, but imho GUI (graphical user interface) is much more comfortable on PC than terminal. You can use any editor, which supports linux line endings, for creating text and script files: vim , emacs or whatever is available for OSX. As example this one:
http://www.barebones.com/products/textwrangler/
I don't now for sure, but might be that your standart MAC editor also is suitable.
For uploading files to NAS securely, you can use any free sftp (ftp via SSH) client:
https://cyberduck.io/
http://rsug.itd.umich.edu/software/fugu/
http://filezilla-project.org/
Now zyxel provides own btsync-zypkg (package). You can easily install it through web-interface and easily upgrade , just replacing btsync binary file and rebooting NAS.
Latest btsync version 2.0.93 is avalaible at https://download-cdn.getsyncapp.com/sta ... arm.tar.gz

c3rb3ru5
Posts: 3
Joined: Mon Mar 23, 2015 5:57 pm

Re: Bittorrent Sync

Post by c3rb3ru5 » Sun Mar 29, 2015 5:51 pm

Firstable many many thanks to barmalej2, you improved my situation very well! I changed the binary file of bittorrent, as you told me. Nevertheless I got new problems:

1) When I restart (on/off-button) my zyxel NSA-325v2 I am not able to open the web-UI of bittorrent sync with http://10.0.0.5:8888. When my zyxel goes into the energy saving mode and restarts itself, I am able to open the Web-Ui of bittorrent sync. I am also using polkast, I think bittorrent sync collides with polkast port configuration.

How can I change the port 8888 of bittorrent sync?
Can I configure the port change over my terminal?

Code: Select all

root@10.0.0.5's password: 
== Welcome at FFP version 0.7/arm, running on NSA325v2 g-server, firmware V4.71(AALS.0) ==
root@g-server:~# cd /ffp/sbin/
root@g-server:/ffp/sbin# ./btsync --help

BitTorrent Sync 2.0.93
Usage:
	  btsync [ options ... ]
Options:
	--nodaemon                Do not daemonize
	--dump-sample-config      Print a sample configuration file
	--log <file>              Set log file
	--webui.listen <IP>:<port> Set the webui listening interface
	--generate-secret         Generate a read/write key
	--get-ro-secret <r/w key> Get the read-only key associated to a read/write key
	--help                    Print this message
	--config <path>           Use a configuration file
root@g-server:/ffp/sbin# 
If yes, how do I use "<>"? Do I have to write e.g.: ./btsync --config <user/folder/subfolder> or do I have to write ./btsync --config user/folder/subfolder?

2) I have added the folder 'documents' from my zyxel to the web-UI of bittorrent sync. The folder has approximately a size of 350 GB and many subfolders. I let the index process run for a night, but on the next day the process seemed to be frozen. But when I added the sync app to my macbook everything was correct indexed. I am also using the iphone app, I have added the folder "documents", but there are many folders which are not incomplete indexed. Please note I do not use the option "sync all", because I do not have that memory space, I use the option "connected", to decide later which file I want to do download.

Does anyone have the same problem with frozen indexing or incomplete indexing on the iphone app?

3) When I am not in my wifi and I am connected to the my telecom provider's 3G-network, the bittorrent sync app writes "mobile data network is not enabled". But I am sure I have everything enabled, because all other data-services still work fine on my iphone. I also have done the following steps seen on http://help.getsync.com/customer/portal ... ync-speed-

Does anyone have the same problem and is not able to connect bittorrent sync to 3G-network?

Many thanks!

With best regards

Matthias

barmalej2
Posts: 2398
Joined: Sun Apr 29, 2012 5:24 pm

Re: Bittorrent Sync

Post by barmalej2 » Sun Mar 29, 2015 7:41 pm

Look at the your start script:
command="/ffp/opt/btsync/bin/btsync"
btsync_flags="--config /ffp/etc/btsync.conf"

btsync_start()
{
echo "Running ${command} ${btsync_flags}"
${command} ${btsync_flags}
}
--config arg specifies full path to btsync.conf file.
If you want specify custom port, then edit btsync_flags line the following (oneliner):

Code: Select all

btsync_flags="--config /ffp/etc/btsync.conf --webui.listen $(ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'):8889"
If you want investigate why is btsync web-interface not available and who has taken port 8888, run from command line:

Code: Select all

lsof -i :8888

Code: Select all

netstat -tulpn | grep :8888

c3rb3ru5
Posts: 3
Joined: Mon Mar 23, 2015 5:57 pm

Re: Bittorrent Sync

Post by c3rb3ru5 » Fri Apr 03, 2015 1:20 pm

Hello,

big thanks again to barmalej2!
Now zyxel provides own btsync-zypkg (package). You can easily install it through web-interface and easily upgrade , just replacing btsync binary file and rebooting NAS.
Latest btsync version 2.0.93 is avalaible at https://download-cdn.getsyncapp.com/sta ... arm.tar.gz
Could you explain it more detailed, or tell me what I have done wrong?

What I did:

1) I installed ffp, so my package list contained btsync_1.2.73_arm_003.zpkg
2) I installed btsync_1.2.73_arm_003.zpkg over my zyxel-web-UI
3) I run ftp with filezilla and opened directory /admin/zy-pkgs
4) I deleted the old version btsync_1.2.73_arm_003.zpkg and added the new version btsync_2.0.93_arm_003.zpkg
5) I disconnected my modem from the internet and opened the Web-UI, there I deinstalled the old version and tried to reinstall, but it failed with the text "unknown"

Is there anyone how can tell me how to install btsync_2.0.93_arm_003.zpkg over the Web-UI? If it is possible with a short step-by-step instruction, I am an absolut newbie!

Many thanks!

barmalej2
Posts: 2398
Joined: Sun Apr 29, 2012 5:24 pm

Re: Bittorrent Sync

Post by barmalej2 » Fri Apr 03, 2015 2:38 pm

Do you renamed BitTorrent-Sync_arm.tar.gz to btsync_1.2.73_arm_003.zpkg?
That is mistake. BitTorrent-Sync_arm.tar.gz is not zyxel provided package-zpkg and has totally different structure. You can't just simply rename and install it.
Remove your btsync_2.0.93_arm_003.zpkg. Then retrieve zyxel packages list again and install old version. Download BitTorrent-Sync_arm.tar.gz, extract it on your PC and copy the btsync binary file using filezilla to /usr/local/zy-pkgs/bin/ directory, where it overwrites the previous version. Reboot NAS.
You can do the same on your box directly (download and overwrite currently installed btsync binary) :

Code: Select all

cd /tmp

Code: Select all

wget https://download-cdn.getsyncapp.com/stable/linux-arm/BitTorrent-Sync_arm.tar.gz

Code: Select all

tar -xf BitTorrent-Sync_arm.tar.gz -C /usr/local/zy-pkgs/bin btsync

Code: Select all

rm BitTorrent-Sync_arm.tar.gz

Code: Select all

reboot
P.S. Web UI is only used to install current available (old) zyxel btsync package. Zyxel provided btsync package has nothing common with FFP.

Post Reply