Installing Sabnzbd from source on CORE

I have been running Sabnzbd in a jail via packages up to now. I recently switched to an install from source so as to be able to get updates more quickly.

What follows are the steps on how to install. I tried to keep the file structure as close to that deployed by the package for those familiar with how it’s currently installed. This install assumes that both the config files and the data files are mounted outside the jail. Also, everything was done from the CL

These first steps are done from the Truenas / Freebsd
Create Jail:

iocage create -n sabnzbd -r 13.2-RELEASE ip4_addr=“vnet0|192.168.50.180/24” defaultrouter=“192.168.50.1” vnet=“on” allow_raw_sockets=“1” boot=“on”

Create Directories:

iocage exec sabnzbd mkdir -p /usr/local/sabnzbd
iocage exec sabnzbd mkdir -p /var/run/sabnzbd
iocage exec sabnzbd mkdir -p /media/Downloads/complete
iocage exec sabnzbd mkdir -p /media/Downloads/incomplete
iocage exec sabnzbd mkdir -p /media/complete/movies
iocage exec sabnzbd mkdir -p /media/complete/music
iocage exec sabnzbd mkdir -p /media/complete/tv
iocage exec sabnzbd mkdir -p /media/complete/ebooks
iocage exec sabnzbd mkdir -p /media/incomplete

Change Directory permissions / owners

iocage exec sabnzbd chmod 777 /usr/local/sabnzbd
iocage exec sabnzbd chmod -R 777 /media/Downloads
iocage sabnzbd chmod 777 /var/run/sabnzbd

Create Mount Points: (change the paths to match your setup)

iocage fstab -a sabnzbd /mnt/NASData/downloads/media/complete/ebooks /media/complete/ebooks nullfs rw 0 0
iocage fstab -a sabnzbd /mnt/NASData/downloads/media/complete/movies /media/complete/movies nullfs rw 0 0
iocage fstab -a sabnzbd /mnt/NASData/downloads/media/complete/music /media/complete/music nullfs rw 0 0
iocage fstab -a sabnzbd /mnt/NASData/downloads/media/complete/tv /media/complete/tv nullfs rw 0 0
iocage fstab -a sabnzbd /mnt/NASData/AppsConfig/Sabnzbd/Config /usr/local/sabnzbd nullfs rw 0 0

Now launch the jail
Iocage console sabnzbd

I always chage the repositoty to use the latest instead of quarterly. This is optional if you wish

Change repository from quarterly to latest:

mkdir -p /usr/local/etc/pkg/repos
cp /etc/pkg/FreeBSD.conf /usr/local/etc/pkg/repos/FreeBSD.conf
vi /usr/local/etc/pkg/repos/FreeBSD.conf

Change url: “pkg+http://pkg.FreeBSD.org/${ABI}/quarterly” to
url: “pkg+http://pkg.FreeBSD.org/${ABI}/latest”

Install Programs:

Install supporting requirements

pkg install nano python par2cmdline unrar git py311-pip sqlite3 py311-sqlite3 rust 7-zip

Copy & install Sabnzbd from github

git clone -b master GitHub - sabnzbd/sabnzbd: SABnzbd - The automated Usenet download tool /usr/local/share/sabnzbd/

Install / Upgrade python components

pip install --upgrade pip
pip install wheel
pip install --upgrade -r /usr/local/share/sabnzbd/requirements.txt
pip install --upgrade setuptools

Create User & Group used by sabnzbd

pw groupadd -n _sabnzbd -g 350
pw useradd -n _sabnzbd -c sabnzbd -u 350 -d /nonexistent -s /usr/sbin/nologin

Edit main SABnzbd.py file to call the correct version of python

nano /usr/local/share/sabnzbd/SABnzbd.py

change the shebang line (first line) to

#!/usr/local/bin/python3.11 -OO

Create PID file

nano /var/run/sabnzbd/sabnzbd.pid

Create service file

nano /usr/local/etc/rc.d/sabnzbd

Copy and paste the following

#!/bin/sh
#
# PROVIDE: sabnzbd
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# sabnzbd_enable (bool):        Set to NO by default.
#                       Set it to YES to enable it.
# sabnzbd_conf_dir:     Directory where sabnzbd configuration
#                       data is stored.
#                       Default: /usr/local/sabnzbd
# sabnzbd_user:         The user account sabnzbd daemon runs as what
#                       you want it to be. It uses '_sabnzbd' user by
#                       default. Do not sets it as empty or it will run
#                       as root.
# sabnzbd_group:        The group account sabnzbd daemon runs as what
#                       you want it to be. It uses '_sabnzbd' group by
#                       default. Do not sets it as empty or it will run
#                       as wheel.
# sabnzbd_pidfile:      Set the location of the sabnzbd pidfile

. /etc/rc.subr

name=sabnzbd
rcvar=sabnzbd_enable
load_rc_config ${name}

: ${sabnzbd_enable:=NO}
: ${sabnzbd_user:=_sabnzbd}
: ${sabnzbd_group:=_sabnzbd}
: ${sabnzbd_conf_dir="/usr/local/sabnzbd"}
: ${sabnzbd_pidfile:="/var/run/sabnzbd/sabnzbd.pid"}

pidfile=${sabnzbd_pidfile}

start_precmd="${name}_prestart"
command_interpreter="/usr/local/bin/python3.11"
command="/usr/local/share/sabnzbd/SABnzbd.py"
command_args="--daemon -f ${sabnzbd_conf_dir}/sabnzbd.ini --pidfile ${pidfile}"

sabnzbd_prestart()
{
	PATH=${PATH}:/usr/local/bin:/usr/local/sbin
	export LC_CTYPE="en_US.UTF-8"
	for sabdir in ${sabnzbd_conf_dir} ${pidfile%/*}; do
		if [ ! -d "${sabdir}" ]; then
			install -d -o ${sabnzbd_user} -g ${sabnzbd_group} ${sabdir}
		fi
	done
}

run_rc_command "$1"

Set permissions on service file

chmod +x /usr/local/etc/rc.d/sabnzbd

Add the following to rc.conf

sysrc sabnzbd_enable=YES
sysrc sabnzbd_data_dir=“/config”
sysrc sabnzbd_conf_dir`=“/usr/local/sabnzbd”

Shut down jail then restart
This is needed to restart python with the new changes

Important if you don’t do this, then sab will try to launch using the python3 command and will fail.

If this is to update an existing installation, then you’re done. Sabnzbd will start and be accessible via the IP address assigned

If this is a new installation, continue with the steps below

Update the ini file to change the server location.

First, create the configuration file;

Log back in to the jail, Stop the service and edit the newly created ini file
service sabnzbd stop

nano /usr/local/sabnzbd/sabnzbd.ini

Find the line “host = 127.0.0.1”, and change “127.0.0.1” to “0.0.0.0”.

Find the following:

download_dir = Downloads/incomplete
complete_dir = Downloads/complete

And change to :

download_dir = /media/Downloads/incomplete
complete_dir = /media/Downloads/complete

Restart the service

service sabnzbd start

Sab should now be accessible via your browser on the IP address you set initially. Open a browser and type 192.168.50.180:8080.

Use the wizard to define your configuration settings.

I can’t see download from source commands. Did you forget those?

Sorry, I hit save before I was done. Everything should be there now