Btsync

De WikiMar
Dreceres ràpides: navegació, cerca

How to install in all server systems (Ubuntu, Fedora,..)

3 Folders:

  • /home/rsync/btsync: contains the shared folders
  • /home/rsync/.btsync: contains the database
  • /home/rsync/btsync_x64: contains the binary program


su rsync
cd /home/rsync
mkdir btsync
mkdir .btsync
mkdir btsync_x64
cd btsync_x64
wget https://download-cdn.getsync.com/stable/linux-x64/BitTorrent-Sync_x64.tar.gz
tar -xf BitTorrent-Sync_x64.tar.gz

/home/rsync/btsync.sh

#!/bin/bash

/home/rsync/btsync_x64/btsync --config /home/rsync/btsync.conf

/home/rsync/btsync.conf

{
  "device_name": "subcube - My Sync Device",
  "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" : "/home/rsync/.btsync",

/* set location of pid file */
// "pid_file" : "/var/run/btsync/btsync.pid",
 "pid_file" : "/home/rsync/btsync.pid",


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

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

/* proxy configuration */
// "proxy_type" : "socks4", // Valid types: "socks4", "socks5", "http_connect". Any other value means no proxy
// "proxy_addr" : "192.168.1.2", // IP address of proxy server.
// "proxy_port" : 1080,
// "proxy_auth" : false, // Use authentication for proxy. Note: only username/password for socks5 (RFC 1929) is supported, and it is not really secure
// "proxy_username" : "user",
// "proxy_password" : "password",

  "webui" :
  {
    "listen" : "0.0.0.0:8889" // remove field to disable WebUI

/* preset credentials. Use password or password_hash */
  ,"login" : "nom"
  ,"password" : "contrasenya"
//  ,"password_hash" : "some_hash" // password hash in crypt(3) format
//  ,"allow_empty_password" : false // Defaults to true
/* ssl configuration */
  ,"force_https" : true // disable http
//  ,"ssl_certificate" : "/path/to/cert.pem"
//  ,"ssl_private_key" : "/path/to/private.key"

/* directory_root path defines where the WebUI Folder browser starts (linux only). Default value is / */
  ,"directory_root" : "/home/rsync/btsync"

/* dir_whitelist defines which directories can be shown to user or have folders added (linux only)
   relative paths are relative to directory_root setting */
//  ,"dir_whitelist" : [ "/home/user/MySharedFolders/personal", "work" ]
  }

/* !!! if you set shared folders in config file WebUI will be DISABLED !!!
   shared directories specified in config file  override the folders previously added from WebUI. */
/*,
  "shared_folders" :
  [
    {
      "secret" : "MY_SECRET_1", // required field - use --generate-secret in command line to create new secret
      "dir" : "/home/user/bittorrent/sync_test", // * required field
      "use_relay_server" : true, //  use relay server when direct connection fails
      "use_tracker" : true,
      "use_dht" : false,
      "search_lan" : true,
      "use_sync_trash" : true, // enable SyncArchive to store files deleted on remote devices
      "overwrite_changes" : false, // restore modified files to original version, ONLY for Read-Only folders
      "known_hosts" : // specify hosts to attempt connection without additional search
      [
        "192.168.1.2:44444"
      ]
    }
  ]
*/

/* Advanced preferences can be added to config file. Info is available at http://sync-help.bittorrent.com */
, "check_for_updates" : false

}


Autostart on Fedora

/etc/systemd/system/btsync.service

[Unit]
Description=BitTorrent Sync for user rsync

[Service]
Type=simple
User=rsync
ExecStart=/home/rsync/btsync_x64/btsync --nodaemon --config /home/rsync/btsync.conf
WorkingDirectory=/home/rsync/

[Install]
WantedBy=multi-user.target

Start service:

systemctl start btsync

Autostart service after boot:

systemctl enable btsync

Status:

systemctl status btsync

More info: http://forum.bittorrent.com/topic/23948-btsync-fedora-at-startup-and-working-start-stop-service/

Autostart on Ubuntu

/etc/init.d/btsync

#! /bin/sh
### BEGIN INIT INFO
# Provides:          btsync
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
# /etc/init.d/btsync
#

# Carry out specific functions when asked to by the system
case "$1" in
start)
    /home/rsync/btsync_x64/btsync --config /home/rsync/btsync.conf
    ;;
stop)
    killall btsync
    ;;
*)
    echo "Usage: /etc/init.d/btsync {start|stop}"
    exit 1
    ;;
esac

exit 0


sudo chmod 755 /etc/init.d/btsync
sudo update-rc.d btsync defaults
sudo service btsync start

More info: http://forum.bittorrent.com/topic/24362-btsync-auto-start-script-ubuntu-1204/