Chinaunix首页 | 论坛 | 博客
  • 博客访问: 368734
  • 博文数量: 100
  • 博客积分: 1894
  • 博客等级: 上尉
  • 技术积分: 951
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-11 23:17
文章分类

全部博文(100)

文章存档

2018年(3)

2014年(2)

2013年(7)

2012年(10)

2011年(8)

2010年(6)

2009年(63)

2008年(1)

分类: LINUX

2014-03-05 17:06:48

1. 环境
server: restore
client: recovery

2. 在server和client都安装btsync
mkdir /opt/btsync
wget -O btsync_x64.tar.gz
tar zxvf btsync_x64.tar.gz

3. server 配置

mkdir /opt/btsync_share

vim /etc/init.d/btsync 

点击(此处)折叠或打开


  1. #!/bin/sh


  2. # Description: starts and stops the bitsync service


  3. CONF=/opt/btsync/btsync.conf
  4. PROC=/opt/btsync/btsync
  5. PIDFILE=/opt/btsync/btsync.pid


  6. start() {
  7.   PID1=$(pidof btsync)
  8.   if [ -z $PID1 ]; then
  9.     echo "Starting BitSync Service: "
  10.     $PROC --config ${CONF}
  11.   else
  12.     echo " BitSync service is already running at pid : ${PID1}"
  13.   fi
  14.   return $?
  15. }


  16. stop() {
  17.   PID1=$(pidof btsync)
  18.   if [ ! -z ${PID1} ]; then
  19.     kill -9 ${PID1}
  20.     echo "Stopped BitSync service: "
  21.   else
  22.     echo "Failed"
  23.   fi
  24.   return $?
  25. }


  26. status() {
  27.   PID1=$(pidof btsync)
  28.   PID2=$(cat ${PIDFILE})
  29.   if [ ! -z ${PID1} ] && [ ${PID1} -eq ${PID2} ]; then
  30.     echo "BitSync is running ... (${PID1})"
  31.   else
  32.     echo "BitSync is not running ..."
  33.   fi
  34.   return $?
  35. }


  36. case "$1" in
  37.   start)
  38.     start
  39. ;;
  40.   stop)
  41.     stop
  42. ;;
  43.   status)
  44.     status
  45. ;;
  46.   restart)
  47.     stop
  48.     sleep 1
  49.     start
  50. ;;
  51. *)
  52.   echo $"Uasge: $0 {start|stop|restart|status}"
  53.   exit 2
  54. esac

chmod +x /etc/init.d/btsync


vim btsync.conf 

点击(此处)折叠或打开

  1. {
  2. "device_name": "restore",
  3. "listening_port" : 8889, // 0 - randomize port

  4. "check_for_updates" : false,
  5. "use_upnp" : false,
  6. "storage_path" : "/opt/btsync",
  7. "pid_file" : "/opt/btsync/btsync.pid",
  8. "download_limit" : 0, // 0 - no limit
  9. "upload_limit" : 0,

  10. "webui" :
  11. {
  12.   "listen" : "0.0.0.0:8888",
  13.   "login" : "admin",
  14.   "password" : "btsync"
  15. }
  16. ,

  17. "folder_rescan_interval" : 60,
  18. "lan_encrypt_data" : false,
  19. "lan_use_tcp" : true
  20. }
/etc/init.d/btsync start

打开Web UI:
用户名: admin
密码: btsync

点击 "Add Folder",
在 "Path" 中输入 "/opt/btsync_share"
点击 "Generate" 得到 "Secret" 为 "A2WLYG2HAEJMSZLJPQZJQCW42QU6WXQBC"


4. Client 配置

 创建配置文件,在client.

cd /opt/btsync

mkdir /opt/btsync_share

vim btsync.conf 


点击(此处)折叠或打开

  1. {
  2. "device_name": "recovery",
  3. "listening_port" : 8889, // 0 - randomize port
  4. "check_for_updates" : false,
  5. "use_upnp" : false,

  6. "storage_path" : "/opt/btsync",
  7. "pid_file" : "/opt/btsync/btsync.pid",
  8. "download_limit" : 0, // 0 - no limit
  9. "upload_limit" : 0,

  10. "webui" :
  11. {
  12.   "listen" : "0.0.0.0:8888",
  13.   "login" : "admin",
  14.   "password" : "btsync"
  15. }

  16. ,
  17. "shared_folders" :
  18. [
  19.   {
  20.     "secret" : "A2WLYG2HAEJMSZLJPQZJQCW42QU6WXQBC", // * required field
  21.     "dir" : "/opt/btsync_share", // * required field
  22.     "use_sync_trash" : false,
  23.     "use_relay_server" : false,
  24.     "use_tracker" : false,
  25.     "search_lan" : true,
  26.     "known_hosts" :
  27.     [
  28.       "recovery:8889"
  29.     ]
  30.   }
  31. ]

  32. ,
  33. "folder_rescan_interval" : 60,
  34. "lan_encrypt_data" : false, // Encryption is very painful in terms of speed. Disabling it for LAN to increase the speed.
  35. "lan_use_tcp" : true
  36. }

vim /etc/init.d/btsync 

点击(此处)折叠或打开


  1. #!/bin/sh


  2. # Description: starts and stops the bitsync service


  3. CONF=/opt/btsync/btsync.conf
  4. PROC=/opt/btsync/btsync
  5. PIDFILE=/opt/btsync/btsync.pid


  6. start() {
  7.   PID1=$(pidof btsync)
  8.   if [ -z $PID1 ]; then
  9.     echo "Starting BitSync Service: "
  10.     $PROC --config ${CONF}
  11.   else
  12.     echo " BitSync service is already running at pid : ${PID1}"
  13.   fi
  14.   return $?
  15. }


  16. stop() {
  17.   PID1=$(pidof btsync)
  18.   if [ ! -z ${PID1} ]; then
  19.     kill -9 ${PID1}
  20.     echo "Stopped BitSync service: "
  21.   else 
  22.     echo "Failed"
  23.   fi
  24.   return $?
  25. }


  26. status() {
  27.   PID1=$(pidof btsync)
  28.   PID2=$(cat ${PIDFILE})
  29.   if [ ! -z ${PID1} ] && [ ${PID1} -eq ${PID2} ]; then
  30.     echo "BitSync is running ... (${PID1})"
  31.   else
  32.     echo "BitSync is not running ..."
  33.   fi
  34.   return $?
  35. }


  36. case "$1" in
  37.   start)
  38.     start
  39. ;;
  40.   stop)
  41.     stop
  42. ;;
  43.   status)
  44.     status
  45. ;;
  46.   restart)
  47.     stop
  48.     sleep 1
  49.     start
  50. ;;
  51. *)
  52.   echo $"Uasge: $0 {start|stop|restart|status}"
  53.   exit 2
  54. esac

chmod +x /etc/init.d/btsync

5. 在server 的 /opt/btsync_share中放置一些文件,就可以查看同步的状态了。
打开Web UI:




阅读(2286) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~