audio bookshelf
Running audiobookshelf inside a FreeBSD jail.
I am using bastille for jail management but its not important. Setup a new jail and mount your audio files inside the jail, due to the way my disks are setup I am also mounting the config and metadata directories into the jail. So /mnt/audio /mnt/config and /mnt/metadata live outside the jail.
Once your jail is setup and the mounts exist, exec into the jail and run the following. At the time of writting this, I am running FreeBSD 14.3-RELEASE. The port 3333 is being exposed outside the jail.
I am running a version that is ~9 months old, as it was the last version to not require nusqlite which is not available on FreeBSD. I think some have gotten newer versions to run, but I don't need the latest features right now and wanted to get this up. If someone gets a later version to build, please shout.
jailed
as root
pkg add npm-node18 git ffmpeg
adduser audiobookshelf
as audiobookshelf user
change to audiobook user and build audiobookshelf
su - audiobookshelf git clone https://github.com/advplyr/audiobookshelf cd audiobookshelf git checkout v2.13.4 npm run client npm ci --omit=dev
as root
install pm2, this is a node pkg which ensures the app is running / restarts and starts at boot. It adds the relevant entries to your rc.conf to start itself as well.
npm install -g pm2 mkdir -p /usr/local/etc/rc.d/ pm2 startup
add the following to this file /mnt/config/ecosystem.config.js
module.exports = { apps : [{ name : "audiobookshelf", script : "/home/audiobookshelf/audiobookshelf/index.js", env: { "NODE_ENV": "production", "HOST": "0.0.0.0", "PORT": "3333", "CONFIG_PATH": "/mnt/config", "METADATA_PATH": "/mnt/metadata", "FFMPEG_PATH": "/usr/local/bin/ffmpeg", "FFPROBE_PATH": "/usr/local/bin/ffprobe", "AUDIOBOOKSHELF_UID": "1001", "AUDIOBOOKSHELF_GID": "1001", "SOURCE": "FreeBSD" } }] }
ensure all folders belong to audiobookshelf user
chown -R audiobookshelf:audiobookshelf /mnt/
start the app and check its status
pm2 start /mnt/config/ecosystem.config.js pm2 status
end user
Open up a web browser and go to http://your-machine:3333. I am using HaProxy to be able to route https://audiobookshelf.mydomain.tld/ to this backend jail.
Source