声明:本文主要参考《Resilio Sync in a FreeNAS Jail》,感谢作者。

  使用resilio sync的同学可能已经发现,最新版的freenas中已经没有resilio sync插件了,而且jail中使用pkg search也找不到安装包。那么怎么才能使用resilio Sync呢?在网上搜索了一番,发现国外已经有人发过这样的教程(请看开头的声明),不过是英文版的,这里将主要过程介绍给大家(根据本人实际操作,步骤略有修改)。

  一、新建一个jail

  如果不会请参考《使用JAIL自建服务教程之一:JAIL创建和优化》。

  二、安装resilio sync

  1、安装ca_root_nss(为了使用https获取resilio程序)

pkg install ca_root_nss

  2、建立开机启动目录

mkdir /usr/local/etc/rc.d

  3、新建自动运行脚本:

nano /usr/local/etc/rc.d/rslsync
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: rslsync
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# rslsync_enable (bool):        Set to NO by default.
#                               Set it to YES to enable it.
# rslsync_user:                 The user account rslsync daemon runs as
#                               what you want it to be. It uses 'rslsync'
#                               user by default. Do not sets it as empty or it
#                               will run as root.
# rslsync_group:                The group account rslsync daemon runs as
#                               what you want it to be. It uses 'rslsync'
#                               group by default. Do not sets it as empty or it
#                               will run as wheel.

. /etc/rc.subr
name="rslsync"
rcvar="${name}_enable"
load_rc_config ${name}

: ${rslsync_enable:="NO"}
: ${rslsync_user:="rslsync"}
: ${rslsync_group:="rslsync"}

pidfile="/var/run/rslsync/rslsync.pid"
command="/usr/local/bin/rslsync"
command_args="--config /usr/local/etc/rslsync.conf"

start_precmd=rslsync_prestart
rslsync_prestart() {
        if [ ! -d ${pidfile%/*} ]; then
                install -d -o ${rslsync_user} -g ${rslsync_group} ${pidfile%/*}
        fi
}

run_rc_command "$1"

  保存退出,然后设置脚本权限:

chmod u+x /usr/local/etc/rc.d/rslsync

  4、下载resilio

cd /usr/local/bin
fetch https://download-cdn.resilio.com/stable/FreeBSD-x64/resilio-sync_freebsd_x64.tar.gz
tar -xzvf resilio-sync_freebsd_x64.tar.gz
rm resilio-sync_freebsd_x64.tar.gz

  如果在fetch软件时显示超时,你也可以手动下载这个文件之后自己上传到/usr/local/bin目录中。(下载链接:https://pan.baidu.com/s/1zeoOVm1ujQBkCjYhweO35g,提取码:n95o)

  5、建立配置文件

  先创建一个配置样本:

nano /usr/local/etc/rslsync.conf.sample
{
   "device_name": "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 current working directory */
 "storage_path" : "/var/db/rslsync",

/* set location of pid file */
 "pid_file" : "/var/run/rslsync/rslsync.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",

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

/* directory_root_policy defines how directory_root is used (linux only).
   Valid values are:
     "all" - accepts directory_root and its subdirectories for 'getdir' and 'adddir' actions
     "belowroot" - accepts directory_root's subdirectories for 'getdir' and 'adddir' actions,
     but denies attempts to use 'adddir' to create directories directly within directory_root
   Default value is "all". */
//  "directory_root_policy" : "all",

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

/* preset credentials. Use password or password_hash */
//  ,"login" : "admin"
//  ,"password" : "password" // (not recommended, better use 'password_hash_unified')
//  ,"password_hash" : "" // (not recommended) Works on *nix only!
// Use either 'password_hash' or 'password_hash_unified' (recommended), but not both of them!
//  ,"password_hash_unified" : "" // Works on all platforms.
//  ,"password_hash_salt_unified" : "" // Salt for unified password's hash. Works on all platforms.
//  ,"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"

/* 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/resilio/sync_test", // * required field
      "use_relay_server" : true, // use relay server when direct connection fails
      "use_tracker" : true,
      "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
      "selective_sync" : false, // add folder in selective sync mode
      "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 "https://help.getsync.com/hc/en-us/articles/207371636"
For example see folder_rescan_interval below */
//, "folder_rescan_interval" : 600

}

  再复制一份为配置文件:

cp /usr/local/etc/rslsync.conf.sample /usr/local/etc/rslsync.conf

  6、设置挂载点

mkdir /var/db/rslsync    //此为配置文件中的"storage_path"

  停止jail,将主机中用于同步的目录挂载至“/var/db/rslsync”和“/media”,其中“rslsync”目录存放配置和运行文件,“media”目录作为数据存储目录(在resilio程序运行后管理界面中设置),然后再启动jail。

  然后新建用户,设置权限:

pw user add rslsync -c rslsync -u 817 -d /nonexistent -s /usr/bin/nologin    //新建rslsync用户和群组
chown -R rslsync:rslsync /var/db/rslsync /media    //设置目录权限

 7、启动rslsync服务

sysrc rslsync_enable="YES"
service rslsync start

  看到如上图所示,启动成功。在浏览器中输入jail的IP:8888,可以看到如下界面:

  至此,resilio sync安装完成,如何使用它不在本文讨论范围,网上教程很多,请自行学习。

3 对 “使用JAIL自建服务教程之五:安装Resilio Sync”的想法;

  1. 博主 你好 感谢 帮忙翻译 英文的 文件 我之前也找到了,我已经尝试了很多次 但用ip:8888 的方式 显示的还是 无法访问此网站 不知道需要如何排查故障可以给我个联系方式 指导下不

发表评论

电子邮件地址不会被公开。 必填项已用*标注