Thursday, November 30, 2023

audio/navidrome: use a config file

Hi,

At the moment we encourage users to configure navidrome via command line
arguments in the rc script.

Besides that being a bit crusty, the next version of navidrome supports
subsonic "jukebox mode" which can't be configured via the command line (only
via a config file).

This diff therefore makes the port install and use a config file.

While here, remove adding LOCALSTATEDIR to SUBST_VARS (it's already there), and
update a straggling VARBASE in the pkg README.

Questions:
- Did I use LOCALSTATEDIR correctly?
- Do we need to mention this change on -current.html?

(Once this is in, I'll post a diff to update to the latest version)

Comments, OK?


Index: Makefile
===================================================================
RCS file: /cvs/ports/audio/navidrome/Makefile,v
diff -u -p -r1.14 Makefile
--- Makefile 28 Nov 2023 06:22:47 -0000 1.14
+++ Makefile 29 Nov 2023 19:20:26 -0000
@@ -2,6 +2,7 @@ COMMENT = modern music server and stream

MODGO_MODNAME = github.com/navidrome/navidrome
MODGO_VERSION = v0.49.3
+REVISION = 0

DISTNAME = navidrome-${MODGO_VERSION}

@@ -31,11 +32,16 @@ RUN_DEPENDS = graphics/ffmpeg

MODULES = lang/go

-SUBST_VARS = LOCALSTATEDIR
+LOCALSTATEDIR = ${BASELOCALSTATEDIR}/navidrome

post-extract:
cd ${WRKSRC} && tar -C ${WRKSRC}/ui/ -zxf \
${FULLDISTDIR}/navidrome-build-${MODGO_VERSION}.tar.gz
+
+post-install:
+ ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/navidrome
+ ${SUBST_CMD} -c -m 755 ${FILESDIR}/navidrome.toml \
+ ${PREFIX}/share/examples/navidrome/navidrome.toml

.include "modules.inc"

Index: files/navidrome.toml
===================================================================
RCS file: files/navidrome.toml
diff -N files/navidrome.toml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/navidrome.toml 30 Nov 2023 08:25:59 -0000
@@ -0,0 +1,15 @@
+# The address to bind to.
+#
+# To allow other hosts to connect, change to "localhost".
+Address = "127.0.0.1"
+
+# Where Navidrome finds music.
+#
+# Make sure the _navidrome user has read access to the music files.
+MusicFolder = "${LOCALSTATEDIR}/music"
+
+# Where Navidrome stores its database etc.
+DataFolder = "${LOCALSTATEDIR}"
+
+# Uncomment to make logging more verbose.
+#LogLevel = 'DEBUG'
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/audio/navidrome/pkg/PLIST,v
diff -u -p -r1.4 PLIST
--- pkg/PLIST 28 Nov 2023 06:22:47 -0000 1.4
+++ pkg/PLIST 29 Nov 2023 19:19:35 -0000
@@ -4,8 +4,11 @@
@mode 755
@owner _navidrome
@group _navidrome
-@sample ${LOCALSTATEDIR}/navidrome/
-@sample ${LOCALSTATEDIR}/navidrome/music/
+@sample ${LOCALSTATEDIR}/
+@sample ${LOCALSTATEDIR}/music/
+share/examples/navidrome/
+share/examples/navidrome/navidrome.toml
+@sample ${SYSCONFDIR}/navidrome.toml
@mode
@owner
@group
Index: pkg/README
===================================================================
RCS file: /cvs/ports/audio/navidrome/pkg/README,v
diff -u -p -r1.2 README
--- pkg/README 11 Mar 2022 18:20:21 -0000 1.2
+++ pkg/README 30 Nov 2023 08:34:11 -0000
@@ -2,20 +2,24 @@
| Running ${PKGSTEM} on OpenBSD
+-----------------------------------------------------------------------

+Config File
+===========
+
+When using the included rc.d(8) script, ${PKGSTEM} uses the config file at
+`${SYSCONFDIR}/navidrome.toml`.
+
Adding Music
=============

-Music can be added by copying it to ${VARBASE}/navidrome/music/ or by changing
-the `--datafolder` directory used.
+Music can be added by copying it to `${LOCALSTATEDIR}/music/` or by changing
+`MusicFolder` in the config file.

Web Interface
=============

-${PKGSTEM} serves up a web interface on:
-
- http://localhost:4533
+By default, ${PKGSTEM} serves up a web interface on:

-If you wish to listen on a different interface or change the location
-${PKGSTEM} looks for music, you can modify it via rcctl:
+ http://127.0.0.1:4533

- # rcctl set navidrome flags -a 0.0.0.0 --datafolder /home/music
+If you wish to listen on a different address, change the `Address` setting in
+the config file.
Index: pkg/navidrome.rc
===================================================================
RCS file: /cvs/ports/audio/navidrome/pkg/navidrome.rc,v
diff -u -p -r1.2 navidrome.rc
--- pkg/navidrome.rc 11 Mar 2022 18:20:21 -0000 1.2
+++ pkg/navidrome.rc 29 Nov 2023 18:58:43 -0000
@@ -2,7 +2,7 @@

daemon="${TRUEPREFIX}/bin/navidrome"
daemon_user="_navidrome"
-daemon_flags="-a localhost --datafolder ${VARBASE}/navidrome --musicfolder ${VARBASE}/navidrome/music"
+daemon_flags="-c ${SYSCONFDIR}/navidrome.toml"

. /etc/rc.d/rc.subr


--
Best Regards
Edd Barrett

https://www.theunixzoo.co.uk

No comments:

Post a Comment