[08/13] gerbera: Add initscript

Message ID 20261130154031.269150-9-stefan.schantl@ipfire.org
State New
Headers
Series [01/13] libupnp: New package |

Commit Message

Stefan Schantl 30 Nov 2026, 3:18 p.m. UTC
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 lfs/gerbera                      |  2 +-
 src/initscripts/packages/gerbera | 55 ++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 src/initscripts/packages/gerbera
  

Comments

Michael Tremer 30 Nov 2026, 4:06 p.m. UTC | #1
Hello Stefan,

some comments on the initscript:

> +		route add -net 239.0.0.0 netmask 255.0.0.0 green0

There is trailing whitespace (a tab) at the end of this line. Also, green0
is hard-coded, and I am not sure what happens when there is no green0 (or
when the user wants this to be offered on blue). Could this use the
interface settings from /var/ipfire/ethernet/settings?

If the route already exists (e.g. after a crash), then "route add" fails
and I do not see any error handling for it, but the script will carry on.

> +		loadproc /usr/bin/gerbera -u nobody \
> +			-c /etc/gerbera/config.xml \
> +			-l /var/log/gerbera.log \
> +			-m /var/lib/gerbera \
> +		        -e green0 $2 $3 $4 $5 $6 $7 -d

The indentation of the last line is mixed (spaces vs. tabs). I am also
wondering whether nobody is able to write to /var/log/gerbera.log, because
nobody cannot create files in /var/log. Did you test this?

Passing $2..$7 to the daemon seems unnecessary. Why do we need that?

> +		echo "Usage: ${{0}} {{start|stop|init|status}}"

There is no "init" action and "restart" is missing from this list.

-Michael
  

Patch

diff --git a/lfs/gerbera b/lfs/gerbera
index 41b979f4b6..86b70019db 100644
--- a/lfs/gerbera
+++ b/lfs/gerbera
@@ -113,7 +113,7 @@  $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	chown nobody:nobody /var/lib/gerbera
 
 	#install initscripts
-	#$(call INSTALL_INITSCRIPTS,$(SERVICES))
+	$(call INSTALL_INITSCRIPTS,$(SERVICES))
 
 	#install backup definition
 	#install -v -m 644 ${DIR_SRC}/config/backup/includes/minidlna \
diff --git a/src/initscripts/packages/gerbera b/src/initscripts/packages/gerbera
new file mode 100644
index 0000000000..f8884b3666
--- /dev/null
+++ b/src/initscripts/packages/gerbera
@@ -0,0 +1,55 @@ 
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/
+#
+# Description : gerbera initscript
+#
+# Authors     : Arne Fitzenreiter
+#               Stefan Schantl
+#
+# Version     : 01.00
+#
+# Notes       : for www.ipfire.org - GPLv3
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+case "$1" in
+	start)
+		boot_mesg "Starting gerbera uPnP Mediaserver..."
+		route add -net 239.0.0.0 netmask 255.0.0.0 green0	
+		loadproc /usr/bin/gerbera -u nobody \
+			-c /etc/gerbera/config.xml \
+			-l /var/log/gerbera.log \
+			-m /var/lib/gerbera \
+		        -e green0 $2 $3 $4 $5 $6 $7 -d
+		evaluate_retval
+		;;
+		
+
+	stop)
+		boot_mesg "Stopping gerbera uPnP Mediaserver..."
+		killproc /usr/bin/gerbera
+		evaluate_retval
+		route del -net 239.0.0.0 netmask 255.0.0.0 green0
+		;;
+
+	restart)
+		${0} stop
+		sleep 1
+		${0} start
+
+		;;
+	status)
+		statusproc /usr/bin/gerbera
+		;;
+
+	*)
+		echo "Usage: ${0} {start|stop|init|status}"
+		exit 1
+		;;
+esac
+
+# End $rc_base/init.d/