Forked from wassupdoc/gist:f57e65d2a5f52101a5ec6f65355e85c2
Last active
November 9, 2020 13:53
-
-
Save msnelling/c38024481daebbc63ee5f2245a0b2e2f to your computer and use it in GitHub Desktop.
Freenas iocage Resilio install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export JAIL_IP="10.1.1.19" | |
export DEFAULT_GW_IP="10.1.1.1" | |
export CONFIG_PATH="/mnt/tank/apps/rslsync/config" | |
export DATA_PATH="/mnt/tank/apps/rslsync/data" | |
export INTERFACE="vnet0" | |
export RELEASE="12.2-RELEASE" | |
# make temp file that will cause iocage to install some packages | |
echo '{"pkgs":["bash", "nano", "ca_root_nss"]}' > /tmp/pkg.json | |
# create jail | |
iocage create -n "rslsync" -p /tmp/pkg.json -r ${RELEASE} ip4_addr="${INTERFACE}|${JAIL_IP}/24" defaultrouter="${DEFAULT_GW_IP}" 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 /var/db/rslsync | |
iocage exec rslsync mkdir -p /media | |
# map config and data storage outside of jail | |
iocage fstab -a rslsync ${CONFIG_PATH} /var/db/rslsync nullfs rw 0 0 | |
iocage fstab -a rslsync ${DATA_PATH} /media 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 "nano /usr/local/etc/sync.conf" | |
##Paste the following | |
{ | |
"storage_path" : "/var/db/rslsync", | |
"use_upnp" : false, | |
"download_limit" : 0, | |
"upload_limit" : 0, | |
"webui" : | |
{ | |
"listen" : "0.0.0.0:8888" | |
} | |
} | |
# change ownership of config and data directories | |
iocage exec rslsync chown -R rslsync:rslsync /media /var/db/rslsync | |
# create the run command directory and file | |
iocage exec rslsync mkdir /usr/local/etc/rc.d | |
iocage exec rslsync "nano /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 /usr/local/etc/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment