Resilio Sync on Raspberry Pi

OSMC是一款基于Debian的多媒体操作系统, 通过HDMI连接电视. 可以通过youtube-dl远程下载视频, 再使用rslsync同步回来.

rslsync的功能类似于rsync, 双向数据同步是加密的. 官方提供各平台GUI客户端, 而且提供debian安装包. 在树莓派上安装, 没有任何障碍.

安装软件

# SSH LOGIN
# =========
# - HOST: 192.168.31.177
# - USER: osmc
# - PASS: osmc
# ssh osmc@192.168.31.177

$ echo 'deb http://linux-packages.resilio.com/resilio-sync/deb resilio-sync non-free' | sudo tee /etc/apt/sources.list.d/resilio-sync.list
$ wget -qO- https://linux-packages.resilio.com/resilio-sync/key.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install resilio-sync
$ sudo adduser rslsync osmc
$ sudo adduser osmc rslsync
$ chmod -R g+w /home/osmc
$ chmod 700 /home/osmc/.ssh/
$ chmod 600 /home/osmc/.ssh/authorized_keys
$ chmod g-w /home/osmc
$ rslsync --dump-sample-config
$ sudo vi /etc/resilio-sync/config.json
$ sudo systemctl restart resilio-sync

配置文件

{
    "device_name": "OSMC",
    "listening_port" : 55555,
    "storage_path" : "/var/lib/resilio-sync/",
    "pid_file" : "/var/run/resilio-sync/sync.pid",
    "agree_to_EULA": "yes",

    "webui" :
    {
        "listen" : "0.0.0.0:8888",
        "login": "osmc",
        "password": "osmc"
    }
}

本地设置

  • 打开页面: http://192.168.31.177:8888
  • 创建账号: OSMC (/etc/resilio-sync/config.json)
  • 添加目录: /home/osmc
  • 分享目录: XXX4KIQZOLU7XAEFGXXXTN5D7BXNMSXXX (Read & Write)
/home/
└── osmc/
    ├── Movies/
    ├── Music/
    ├── Pictures/
    └── TV Shows/

远程设置

  • 部署服务: vimagick/rslsync (docker)
  • 打开页面: http://sync.easypi.info:8888
  • 创建目录: /path/to/osmc
  • 关联分享: XXX4KIQZOLU7XAEFGXXXTN5D7BXNMSXXX
  • 创建文件: /path/to/osmc/test
  • 删除文件: /path/to/osmc/test
rslsync:  
  image: vimagick/rslsync
  ports:
    - "8888:8888"
    - "55555:55555"
  volumes:
    - ./data:/data
    - ./rslsync.conf:/etc/rslsync.conf
  restart: always

手机设置

安装BitTorrent Sync => Resilio Sync [将会改名]


OpenWrt移植

  • /lib/ld-linux-armhf.so.3 -> arm-linux-gnueabihf/ld-2.19.so (Copy from OSMC)
  • /usr/bin/rslsync
  • /etc/resilio-sync/config.json
  • /etc/init.d/resilio-sync
{
    "device_name": "OpenWrt",
    "listening_port" : 55555,
    "storage_path" : "/var/lib/resilio-sync/",
    "pid_file" : "/var/run/resilio-sync/sync.pid",
    "agree_to_EULA": "yes",

    "webui" :
    {
        "listen" : "0.0.0.0:8888",
        "login": "root",
        "password": "root"
    }
}
#!/bin/sh /etc/rc.common

# Startup script
# Copyright (C) 2015 OpenWrt.org

USE_PROCD=1  
START=95  
STOP=10

start_service() {

    [ -d /var/run/resilio-sync ] || {
        mkdir -m 0755 -p /var/lib/resilio-sync
        mkdir -m 0755 -p /var/run/resilio-sync
    }

    procd_open_instance
    procd_set_param command /usr/bin/rslsync --nodaemon --config /etc/resilio-sync/config.json
    procd_set_param respawn
    procd_close_instance
}