Skip to content

Instantly share code, notes, and snippets.

@lbrooney
Last active July 29, 2025 11:08
Show Gist options
  • Select an option

  • Save lbrooney/cc11cce1a81592f7bdf8292d19f0e40e to your computer and use it in GitHub Desktop.

Select an option

Save lbrooney/cc11cce1a81592f7bdf8292d19f0e40e to your computer and use it in GitHub Desktop.
TrueNAS Audiobookshelf Install Guide
# I will be writing this from the perspective of a TrueNAS user, but should be somewhat applicable for users of FreeBSD
# AT THE TIME OF WRITING, tone (https://github.com/sandreas/tone) is not ported to FreeBSD, so you'll miss out on it's
# capabilities which I think is getting metadata from files, the app SEEMS to run fine without it but YMMV
# READ THE README(and the Dockerfile) OF THE PROJECT, REQUIREMENTS MAY CHANGE BETWEEN WHEN YOU READ THIS AND WHEN I WROTE IT
# At the time of writing, based off the Dockerfile on the repository these are the packages you need explicitly for Audiobookshelf are:
"curl", "ffmpeg", "node16"
# You can choose between your preferred package manager, if you don't know, just go with "npm-node16"
# Here's all the packages you'll need, with nano for text editing, this will just tell iocage what packages we want installed by default
echo '{"pkgs":["curl","ffmpeg","node16","npm-node16","nano"]}' > /tmp/pkg.json
# next create the iocage !!! CHANGE <IPADDR> TO WHAT YOU WANT, CHANGE <ROUTER> TO YOUR DEFAULT ROUTER !!!
sudo iocage create -n "audiobookshelf" -p /tmp/pkg.json -r 13.2-RELEASE ip4_addr="vnet0|<IPADDR>/24" defaultrouter="<ROUTER>" vnet="on" allow_raw_sockets="1" boot="on"
# remove the tmp pkg
rm /tmp/pkg.json
# next create a place for audiobookshelf settings to go
sudo iocage exec audiobookshelf mkdir -p /config/audiobookshelf/config
sudo iocage exec audiobookshelf mkdir -p /config/audiobookshelf/metadata
# create a folder outside your jail so your metadata/settings are safe if ever need to migrate/delete the jail
# personally I store them in folder called apps which stores configs for all my services
mkdir -p /mnt/<NAME_OF_POOL>/apps/audiobookshelf
# mount the folder
sudo iocage fstab -a audiobookshelf /mnt/<NAME_OF_POOL>/apps/audiobookshelf /config/audiobookshelf nullfs rw 0 0
# next I'm going to console into the iocage, but you can continue to use exec
sudo iocage console audiobookshelf
# next we are going to download audiobookshelf, you have to options
# bleeding edge: clone the repository, you'll need git, updates easy as you can just git pull, probably unstable or broken
# release: stable, what the rest of guide will assume is being used
## INSTALL
# go to https://github.com/advplyr/audiobookshelf/releases/latest, scroll to assets right click your preferred archive format and click copy link
# you can cd to your preferred install directory, I'm going to stick with ~
# !!! FOR THE FOLLOWING SECTION I USE <VERSION_NUM> TO BE AGNOSTIC, CHANGE COMMANDS TO YOUR VERSION !!!
# I'm going with zip
fetch https://github.com/advplyr/audiobookshelf/archive/refs/tags/v<VERSION_NUM>.zip
unzip audiobookshelf-<VERSION_NUM>.zip
# It will extract to a folder whose name is the audiobookshelf-number version
# next will install the package requirements and compile the app
cd audiobookshelf-<VERSION_NUM>
npm run client
npm ci --omit=dev
# next if we really wanted to, we can run the app and see that it's only accessible from that jail(local host)
node prod
# we can fix that by doing
node prod --host 0.0.0.0
# now we can access it at <IP_ADDR>:3333, it works!! Anybody on the local network can access it!
# but now we'll have to pass in command line args for each thing, it just becomes a mess, I guess we could make an bash script
# HOWEVER there's a better way, PM2, a process manager for Node apps, bonus points is that it'll autorestart our app if it every crashes
npm install -g pm2
mkdir -p /usr/local/etc/rc.d/
pm2 startup
# PM2 has a nice little config we can setup that will set all the environment variables for us
nano /config/audiobookshelf/ecosystem.config.js
# Adjust the script path and any other settings you'd like
# notice I use index.js for this, so the port will now be 80, but if you want 3333 you can swap back to prod.js or uncomment port
module.exports = {
apps : [{
name : "audiobookshelf",
script : "/root/audiobookshelf-<VERSION_NUM>/index.js",
env: {
"NODE_ENV": "production",
"HOST": "0.0.0.0",
//"PORT": "3333",
"CONFIG_PATH": "/config/audiobookshelf/config",
"METADATA_PATH": "/config/audiobookshelf/metadata",
//"AUDIOBOOKSHELF_UID": "0", // ROOT
//"AUDIOBOOKSHELF_GID": "0", // WHEEL
"SOURCE": "FreeBSD",
//"ROUTER_BASE_PATH": "",
}
}]
}
# Now save and exit nano and run the app
pm2 start /config/audiobookshelf/ecosystem.config.js
pm2 save
# you can the app's status with
pm2 status
# you can see the app's node output with(you can get <PM2_ID> from status, it's on the left side)
pm2 logs <PM2_ID>
# CTRL+C to get out of logs, your app will stay running
# Now it should work, mount your audiobook or ebook folders, then add them as libaries
# Helpful(?) note: When creating library don't use the Browse for Folder button, just manually type in the folder path
# now if you want to make this work outside of your network, use a reverse proxy
# they have some sample configs: https://github.com/advplyr/audiobookshelf#reverse-proxy-set-up
## UPDATING
# Back up your settings/metadata
# Read the patch notes to see if there's any breaking changes
# Follow the above install notes and update the path in the ecosystem.config.js
# Then run the following commands
pm2 stop audiobookshelf
pm2 delete audiobookshelf
pm2 start /config/audiobookshelf/ecosystem.config.js
pm2 save
I HOPE THIS WAS HELPFUL AND WILL SURE YOU WELL!!! Apologies if the formatting is bad.
Also thank you to SleepingPanda(github.com/SleepingPanda) his guides inspired this one
@jakepog
Copy link

jakepog commented Oct 26, 2024

Thanks for the excellent script! Unfortunately this no longe works for Audiobookshelf v2.15.x as it includes nusqlite3, for which a binary is not available for FreeBSD - according to the error logs.

ERROR: [Binary] Failed to download library libnusqlite3 version 1.2 to /root/audiobookshelf/audiobookshelf-2.15.1 Error: [NunicodeDownloader] Platform freebsd-x64 not supported

I tried to compile it myself, but cannot find a sqlite3 development package. Suggestions?

@Baenwort
Copy link

Baenwort commented Jan 3, 2025

Thanks for the excellent script! Unfortunately this no longe works for Audiobookshelf v2.15.x as it includes nusqlite3, for which a binary is not available for FreeBSD - according to the error logs.

ERROR: [Binary] Failed to download library libnusqlite3 version 1.2 to /root/audiobookshelf/audiobookshelf-2.15.1 Error: [NunicodeDownloader] Platform freebsd-x64 not supported

I tried to compile it myself, but cannot find a sqlite3 development package. Suggestions?

Have you tried using libsqlite3 instead? I wonder if we're just going to be stuck at 2.14 until someone more skillful figures something out?

@jakepog
Copy link

jakepog commented Jan 3, 2025

I added these lines into.env and 2.17.5 runs fine in a FreeBSD 13.4 jail. Just without the helpful features that nusqlite3 brings.
// "NUSQLITE3_PATH": "", "SKIP_BINARIES_CHECK": 1

@sbramin
Copy link

sbramin commented Jul 29, 2025

FYI, I messed around with this in a vanilla jail on fbsd 14.3 and it would load a UI but get stuck on a spinning wheel. Went back to v2.13.4 and works perfectly, I could have probably tried a later version but got bored of playing with it.

Only change to above guide is I am using node20 as thats what they recommend for the build.

And I needed to set ffmpeg paths in the ecosystem.config.js

  "FFMPEG_PATH":        "/usr/local/bin/ffmpeg",
  "FFPROBE_PATH":        "/usr/local/bin/ffprobe",

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