Skip to content

Instantly share code, notes, and snippets.

@chaosbiber
Last active February 5, 2024 22:43
Show Gist options
  • Save chaosbiber/794cd785e607904bbec1db64d3b73b01 to your computer and use it in GitHub Desktop.
Save chaosbiber/794cd785e607904bbec1db64d3b73b01 to your computer and use it in GitHub Desktop.

Install navidrome on FreeNAS Jail / FreeBSD 11.4 & 12.2

https://www.navidrome.org/

  • date: 2020-08-21, navidrome 0.30.1, needs go 1.14 and node v14
  • update: 2020-10-28, navidrome 0.36.1, needs go 1.15 and node v14; newer go version in repo: pkg update, pkg upgrade followed by pkg install taglib and the build went through
  • update: 2021-01-20, FreeBSD 12, navidrome 0.39, needs go 1.15 and node v14; FreeBSD 12 repo contains node v15, installed node14 and npm-node14 instead of node and npm
  • update: 2021-04-30, FreeBSD 12, navidrome 0.42, needs go 1.16 (in repo), kept node v14 with a minor update; removed wrapper script from service below
  • update: 2021-08-04, FreeBSD 12, navidrome 0.44.1, needs node v16

Improvements / TODO

  • Create a navidrome user instead of using root. Even if this is in a jail and the music is mounted read-only.
  • no logs when stared via service log in /var/log/navidrome.log (updated rc script)
  • add reverse proxy (I have that in another jail)

Install requirements

pkg update
pkg install vim-console git htop

go 1.16 & node v16, taglib, update npm:

FreeBSD 12:
pkg install node go npm taglib

npm install npm@latest -g

ffmpeg with lame

portsnap fetch
portsnap extract  # 'portsnap update' later on
cd /usr/ports/multimedia/ffmpeg
make build-depends-list && make run-depends-list

install required packages via pkg

pkg install nasm texi2html frei0r v4l_compat gmake pkgconf perl5 libX11 libxcb aom libass dav1d libdrm fontconfig freetype2 gmp gnutls libxml2 opencv-core opus libtheora libv4l libva libvdpau libvorbis libvpx libx264 x265 xvid
make config

enable lame and nonfree codecs, then

# 'pkg unlock ffmpeg' to update
make install # 'make reinstall' to update
make clean
pkg lock ffmpeg

Install navidrome

git clone https://github.com/deluan/navidrome
cd navidrome
# 'git pull' for updates
setenv PATH $PATH\:/root/go/bin
gmake setup
gmake buildall

executable: ./navidrome default port: 4533

Example navidrome.toml

LogLevel = "INFO"
BaseURL = "/music"
ScanInterval = "3600s"
TranscodingCacheSize = "300MiB"
MusicFolder = "/media/music"
LastFM.ApiKey = "..."
LastFM.Secret = "..."

Add service

/usr/local/etc/rc.d/navidrome

#!/bin/sh
#
# PROVIDE: navidrome
# REQUIRE: networking
# KEYWORD:

. /etc/rc.subr

name="navidrome"
rcvar="navidrome_enable"
navidrome_user="root"
navidrome_command="/root/navidrome/navidrome --configfile /root/navidrome/navidrome.toml"
navidrome_chdir="/root/navidrome"
pidfile="/var/run/navidrome/${name}.pid"
logfile="/var/log/navidrome.log"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -o ${logfile} ${navidrome_command}"

load_rc_config $name
: ${navidrome_enable:=no}

PATH="${PATH}:/usr/local/bin"

run_rc_command "$1"
chmod +x /usr/local/etc/rc.d/navidrome
echo 'navidrome_enable="YES"' >> etc/rc.conf
service navidrome start
@RandomBloke85
Copy link

RandomBloke85 commented Oct 26, 2022

Hello
Thx for this write-up.
The service section didn't work for me (TrueNAS 13, jail 13.1). The pidfile wasn't created. I did not install opencv-core, since it's not available in pkg anymore. For the sake of simplicity I installed ffmpeg from pkg. But that doesn't have to do anything with the service section.

Here is the error msg
daemon: ppidfile ``/var/run/navidrome/navidrome.pid'': No such file or directory /usr/local/etc/rc.d/navidrome: WARNING: failed to start navidrome

@bun-dev
Copy link

bun-dev commented Dec 11, 2022

Hello Thx for this write-up. The service section didn't work for me (TrueNAS 13, jail 13.1). The pidfile wasn't created. I did not install opencv-core, since it's not available in pkg anymore. For the sake of simplicity I installed ffmpeg from pkg. But that doesn't have to do anything with the service section.

Here is the error msg daemon: ppidfile/var/run/navidrome/navidrome.pid'': No such file or directory /usr/local/etc/rc.d/navidrome: WARNING: failed to start navidrome ``

you need to create the navidrome directory in /var/run, or alternatively just put the pid in any directory you want.
mkdir /var/run/navidrome

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