Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SleepingPanda/72037116cdd17e2e0cc67ee4196fbc88 to your computer and use it in GitHub Desktop.
Save SleepingPanda/72037116cdd17e2e0cc67ee4196fbc88 to your computer and use it in GitHub Desktop.
TrueNAS Jail Setup Guide for Radarr
## Make a handy json file to automatically install the needed packages for Radarr to run
echo '{"pkgs":["libunwind","icu","libinotify","openssl","mediainfo","sqlite3","ca_root_nss","libiconv","nano","curl","wget"]}' > /tmp/pkg.json
## Create the jail using that json file we created earlier.
## I use 12.2-RELEASE as it's the most recent at the time of writing.
## Replace <IP>, <MASK> and <GATEWAY> with your own.
iocage create -n "radarr" -p /tmp/pkg.json -r 12.2-RELEASE ip4_addr="vnet0|<IP>/<MASK>" defaultrouter="<GATEWAY>" vnet="on" allow_mlock="1" allow_raw_sockets="1" boot="on"
## Delete the now useless file we created at the beginning.
rm /tmp/pkg.json
## Check to see if your jail was created and running properly.
iocage list
## Make the directory Radarr will save its data to.
## Replace <DIR> with your own.
iocage exec radarr mkdir -p /config
iocage fstab -a radarr /<DIR> /config nullfs rw 0 0
## Make the directories Radarr needs for managing files and do the same as before.
iocage exec radarr mkdir -p /downloads
iocage fstab -a radarr /<DIR> /downloads nullfs rw 0 0
iocage exec radarr mkdir -p /movies
iocage fstab -a radarr /<DIR> /movies nullfs rw 0 0
## Make an rcd init directory for Radarr to automatically startup when the server is turned on.
iocage exec radarr mkdir -p /usr/local/etc/rc.d
## Download the latest master version of Radarr from their github project releases page (https://github.com/Radarr/Radarr/releases).
## Extract the files and then delete the tar.
iocage exec radarr "fetch https://github.com/Radarr/Radarr/releases/download/v3.1.1.4954/Radarr.master.3.1.1.4954.freebsd-core-x64.tar.gz -o /usr/local/share"
iocage exec radarr "tar -xzvf /usr/local/share/Radarr.master.3.1.1.4954.freebsd-core-x64.tar.gz -C /usr/local/share"
iocage exec radarr rm /usr/local/share/Radarr.master.3.1.1.4954.freebsd-core-x64.tar.gz
## Create the Radarr user.
## Give ownership of the extracted files and the config directory to the new user account.
iocage exec radarr "pw user add radarr -c radarr -u 352 -d /nonexistent -s /usr/bin/nologin"
iocage exec radarr chown -R radarr:radarr /usr/local/share/Radarr /config
## Make the rcd file (<JAILS DIR> is wherever your iocage jails are located).
nano /<JAILS DIR>/iocage/jails/radarr/root/usr/local/etc/rc.d/radarr
*** COPY AND PASTE BELOW ***
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: radarr
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# radarr_enable: Set to YES to enable radarr
# Default: NO
# radarr_user: The user account used to run the radarr daemon.
# This is optional, however do not specifically set this to an
# empty string as this will cause the daemon to run as root.
# Default: radarr
# radarr_group: The group account used to run the radarr daemon.
# This is optional, however do not specifically set this to an
# empty string as this will cause the daemon to run with group wheel.
# Default: radarr
# radarr_data_dir: Directory where radarr configuration
# data is stored.
# Default: /var/db/radarr
. /etc/rc.subr
name=radarr
rcvar=${name}_enable
load_rc_config $name
: ${radarr_enable:="NO"}
: ${radarr_user:="radarr"}
: ${radarr_group:="radarr"}
: ${radarr_data_dir:="/config"}
pidfile="${radarr_data_dir}/${name}radarr.pid"
pidfile_child="${radarr_data_dir}/${name}_child.pid"
command="/usr/sbin/daemon"
start_precmd=${name}_precmd
radarr_precmd() {
if [ ! -d ${radarr_data_dir} ]; then
install -d -o ${radarr_user} -g ${radarr_group} ${radarr_data_dir}
fi
export XDG_CONFIG_HOME=${radarr_data_dir}
rc_flags="-r -f -p ${pidfile_child} -P ${pidfile} /usr/local/share/Radarr/Radarr --data=${radarr_data_dir} --nobrowser >> /dev/null 2>&1 ${rc_flags}"
}
run_rc_command "$1"
*** END PASTE ***
## Give the newly created rcd file execution priveleges.
iocage exec radarr chmod u+x /usr/local/etc/rc.d/radarr
## Create the Radarr service and input the necessary details for the service to run.
iocage exec radarr sysrc radarr_enable=YES radarr_data_dir=/config radarr_user=radarr radarr_group=radarr
## Start the newly created service.
iocage exec radarr service radarr start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment