Skip to content

Instantly share code, notes, and snippets.

@wassupdoc
Last active November 25, 2020 10:58
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save wassupdoc/f57e65d2a5f52101a5ec6f65355e85c2 to your computer and use it in GitHub Desktop.
Save wassupdoc/f57e65d2a5f52101a5ec6f65355e85c2 to your computer and use it in GitHub Desktop.
Freenas iocage Resilio install
# make temp file that will cause iocage to install some packages
echo '{"pkgs":["ca_root_nss"]}' > /tmp/pkg.json
# create jail
iocage create -n "rslsync" -p /tmp/pkg.json -r 11.3-RELEASE ip4_addr="vnet0|YOURRESILIOIP/24" defaultrouter="ROUTERIP" vnet="on" allow_raw_sockets="1" boot="on"
# remove the temp file
rm /tmp/pkg.json
#make our iocage directories
iocage exec rslsync mkdir -p /config
iocage exec rslsync mkdir -p /mnt/syncdata
# map config and data storage outside of jail
iocage fstab -a rslsync /mnt/RESILIODATA /mnt/syncdata nullfs rw 0 0
iocage fstab -a rslsync /mnt/RESILIOCONFIG /config nullfs rw 0 0
# link python
iocage exec rslsync ln -s /usr/local/bin/python2.7 /usr/bin/python
iocage exec rslsync ln -s /usr/local/bin/python2.7 /usr/bin/python2
# download and unpack resilio from website
iocage exec rslsync mkdir /usr/local/rslsync
iocage exec rslsync "fetch https://download-cdn.resilio.com/stable/FreeBSD-x64/resilio-sync_freebsd_x64.tar.gz -o /usr/local/rslsync/"
iocage exec rslsync "tar -xzvf /usr/local/rslsync/resilio-sync_freebsd_x64.tar.gz -C /usr/local/rslsync/"
iocage exec rslsync rm /usr/local/rslsync/resilio-sync_freebsd_x64.tar.gz
# add rslsync user using pid:uid used by rslsync in the past
iocage exec rslsync "pw user add rslsync -c rslsync -u 817 -d /nonexistent -s /usr/bin/nologin"
#create config file
iocage exec rslsync "ee /config/sync.conf"
##Paste the following
{
"webui": {
"ssl_certificate": "",
"force_https": false,
"ssl_private_key": "",
"listen": "0.0.0.0:8888"
},
"storage_path": "/config"
}
# Link the rslsync config file to one from config directory outside of jail
iocage exec rslsync ln -s /config/sync.conf /usr/local/etc/sync.conf
# change ownership of config and data directories
iocage exec rslsync chown -R rslsync:rslsync /mnt/syncdata /config
# create the run command directory and file
iocage exec rslsync mkdir /usr/local/etc/rc.d
iocage exec rslsync "ee /usr/local/etc/rc.d/rslsync"
##paste the following
#!/bin/sh
#
# PROVIDE: resilio
# REQUIRE: LOGIN DAEMON NETWORKING
# KEYWORD: shutdown
#
# To enable Resilio, add this line to your /etc/rc.conf:
#
# resilio_enable="YES"
#
# And optionally these line:
#
# resilio_user="username" # Default is "root"
# resilio_bin="/path/to/resilio" # Default is "/usr/local/share/rslsync"
. /etc/rc.subr
name="rslsync"
rcvar="resilio_enable"
load_rc_config $name
required_files=$resilio_bin
: ${resilio_enable:="NO"}
: ${resilio_user:="rslsync"}
: ${resilio_bin:="/usr/local/sbin/rslsync"}
command=$resilio_bin
command_args="--config /config/sync.conf"
run_rc_command "$1"
#move the executable from rslsync to sbin
iocage exec rslsync mv /usr/local/rslsync/rslsync /usr/local/sbin/
# make the run command file executable
iocage exec rslsync chmod u+x /usr/local/etc/rc.d/rslsync
#enable start up of rslsync and start
iocage exec rslsync sysrc "resilio_enable="YES""
iocage exec rslsync service rslsync start
@RabbyEfty123
Copy link

@LordDrakath
Copy link

Thank you for putting this together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment