git: 4288cedea458 - main - multimedia/emby-server(-devel): remove redundant PID file operations

From: Dries Michiels <driesm_at_FreeBSD.org>
Date: Sun, 19 Feb 2023 07:58:22 UTC
The branch main has been updated by driesm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4288cedea45865dfb375c1d4deb1ac36739d14a4

commit 4288cedea45865dfb375c1d4deb1ac36739d14a4
Author:     Matthew Wener <matthew@wener.org>
AuthorDate: 2023-02-19 07:44:10 +0000
Commit:     Dries Michiels <driesm@FreeBSD.org>
CommitDate: 2023-02-19 07:56:08 +0000

    multimedia/emby-server(-devel): remove redundant PID file operations
    
    rc.subr automatically creates and removes the PID file. In order for
    rc.subr to create the PID file, the PID file is moved to a dedicated
    directory which is owned by the emby user.
    
    Pull Request:   https://github.com/freebsd/freebsd-ports/pull/161
---
 multimedia/emby-server-devel/Makefile             |  2 +-
 multimedia/emby-server-devel/files/emby-server.in | 27 ++++++++++-------------
 multimedia/emby-server/Makefile                   |  2 +-
 multimedia/emby-server/files/emby-server.in       | 27 ++++++++++-------------
 4 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/multimedia/emby-server-devel/Makefile b/multimedia/emby-server-devel/Makefile
index 6098d9366032..6cadc2a87711 100644
--- a/multimedia/emby-server-devel/Makefile
+++ b/multimedia/emby-server-devel/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	emby-server
 DISTVERSION=	4.8.0.21
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	multimedia
 MASTER_SITES=	https://github.com/MediaBrowser/Emby.Releases/releases/download/${DISTVERSION}/ \
 		https://mediabrowser.github.io/embytools/
diff --git a/multimedia/emby-server-devel/files/emby-server.in b/multimedia/emby-server-devel/files/emby-server.in
index d5b9bdb4cf97..d753175697b4 100644
--- a/multimedia/emby-server-devel/files/emby-server.in
+++ b/multimedia/emby-server-devel/files/emby-server.in
@@ -26,8 +26,10 @@
 #			Default: %%PREFIX%%/lib/emby-server/bin/ffmpeg
 # %%RC_NAME%%_ffprobe:	Path of the ffprobe binary.
 #			Default: %%PREFIX%%/lib/emby-server/bin/ffprobe
-# %%RC_NAME%%_pid: 	Path of the pid file.
-#			Default: /var/run/%%PORTNAME%%.pid
+# %%RC_NAME%%_pid:	Name of the pid file.
+#			Default: %%PORTNAME%%.pid
+# %%RC_NAME%%_pid_dir:	Path of the pid file.
+#			Default: /var/run/emby-server
 
 . /etc/rc.subr
 name=%%RC_NAME%%
@@ -41,22 +43,23 @@ load_rc_config ${name}
 : ${%%RC_NAME%%_ffdetect:="%%PREFIX%%/lib/emby-server/bin/ffdetect"}
 : ${%%RC_NAME%%_ffmpeg:="%%PREFIX%%/lib/emby-server/bin/ffmpeg"}
 : ${%%RC_NAME%%_ffprobe:="%%PREFIX%%/lib/emby-server/bin/ffprobe"}
-: ${%%RC_NAME%%_pid:="/var/run/%%PORTNAME%%.pid"}
+: ${%%RC_NAME%%_pid:="%%PORTNAME%%.pid"}
+: ${%%RC_NAME%%_pid_dir:="/var/run/emby-server"}
 
-pidfile="${%%RC_NAME%%_pid}"
+pidfile="${%%RC_NAME%%_pid_dir}/${%%RC_NAME%%_pid}"
 command="/usr/sbin/daemon"
-command_args="-r -f -P ${%%RC_NAME%%_pid} %%PREFIX%%/lib/emby-server/system/EmbyServer \
+command_args="-r -f -P ${pidfile} %%PREFIX%%/lib/emby-server/system/EmbyServer \
 	-os freebsd \
 	-ffdetect ${%%RC_NAME%%_ffdetect} \
 	-ffmpeg ${%%RC_NAME%%_ffmpeg} \
 	-ffprobe ${%%RC_NAME%%_ffprobe} \
 	-programdata ${%%RC_NAME%%_data_dir}"
 
-start_precmd=%%RC_NAME%%_precmd
-%%RC_NAME%%_precmd()
+start_precmd=%%RC_NAME%%_start_precmd
+%%RC_NAME%%_start_precmd()
 {
-	[ -f ${%%RC_NAME%%_pid} ] || install -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} -- /dev/null ${%%RC_NAME%%_pid}
-	[ -d ${%%RC_NAME%%_data_dir} ] || install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} -- ${%%RC_NAME%%_data_dir}
+	[ -d ${%%RC_NAME%%_pid_dir} ] || install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} ${%%RC_NAME%%_pid_dir}
+	[ -d ${%%RC_NAME%%_data_dir} ] || install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} ${%%RC_NAME%%_data_dir}
 
 	# .NET 6+ use dual mode sockets to avoid the separate AF handling.
 	# disable .NET use of V6 if no ipv6 is configured.
@@ -69,10 +72,4 @@ start_precmd=%%RC_NAME%%_precmd
 	export LD_LIBRARY_PATH=%%PREFIX%%/lib/emby-server/lib:%%LOCALBASE%%/lib
 }
 
-stop_postcmd=%%RC_NAME%%_postcmd
-%%RC_NAME%%_postcmd()
-{
-	rm -f ${%%RC_NAME%%_pid}
-}
-
 run_rc_command "$1"
diff --git a/multimedia/emby-server/Makefile b/multimedia/emby-server/Makefile
index c93bd1421dd2..006ec73d3942 100644
--- a/multimedia/emby-server/Makefile
+++ b/multimedia/emby-server/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	emby-server
 DISTVERSION=	4.7.11.0
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	multimedia
 MASTER_SITES=	https://github.com/MediaBrowser/Emby.Releases/releases/download/${DISTVERSION}/ \
 		https://mediabrowser.github.io/embytools/
diff --git a/multimedia/emby-server/files/emby-server.in b/multimedia/emby-server/files/emby-server.in
index d5b9bdb4cf97..d753175697b4 100644
--- a/multimedia/emby-server/files/emby-server.in
+++ b/multimedia/emby-server/files/emby-server.in
@@ -26,8 +26,10 @@
 #			Default: %%PREFIX%%/lib/emby-server/bin/ffmpeg
 # %%RC_NAME%%_ffprobe:	Path of the ffprobe binary.
 #			Default: %%PREFIX%%/lib/emby-server/bin/ffprobe
-# %%RC_NAME%%_pid: 	Path of the pid file.
-#			Default: /var/run/%%PORTNAME%%.pid
+# %%RC_NAME%%_pid:	Name of the pid file.
+#			Default: %%PORTNAME%%.pid
+# %%RC_NAME%%_pid_dir:	Path of the pid file.
+#			Default: /var/run/emby-server
 
 . /etc/rc.subr
 name=%%RC_NAME%%
@@ -41,22 +43,23 @@ load_rc_config ${name}
 : ${%%RC_NAME%%_ffdetect:="%%PREFIX%%/lib/emby-server/bin/ffdetect"}
 : ${%%RC_NAME%%_ffmpeg:="%%PREFIX%%/lib/emby-server/bin/ffmpeg"}
 : ${%%RC_NAME%%_ffprobe:="%%PREFIX%%/lib/emby-server/bin/ffprobe"}
-: ${%%RC_NAME%%_pid:="/var/run/%%PORTNAME%%.pid"}
+: ${%%RC_NAME%%_pid:="%%PORTNAME%%.pid"}
+: ${%%RC_NAME%%_pid_dir:="/var/run/emby-server"}
 
-pidfile="${%%RC_NAME%%_pid}"
+pidfile="${%%RC_NAME%%_pid_dir}/${%%RC_NAME%%_pid}"
 command="/usr/sbin/daemon"
-command_args="-r -f -P ${%%RC_NAME%%_pid} %%PREFIX%%/lib/emby-server/system/EmbyServer \
+command_args="-r -f -P ${pidfile} %%PREFIX%%/lib/emby-server/system/EmbyServer \
 	-os freebsd \
 	-ffdetect ${%%RC_NAME%%_ffdetect} \
 	-ffmpeg ${%%RC_NAME%%_ffmpeg} \
 	-ffprobe ${%%RC_NAME%%_ffprobe} \
 	-programdata ${%%RC_NAME%%_data_dir}"
 
-start_precmd=%%RC_NAME%%_precmd
-%%RC_NAME%%_precmd()
+start_precmd=%%RC_NAME%%_start_precmd
+%%RC_NAME%%_start_precmd()
 {
-	[ -f ${%%RC_NAME%%_pid} ] || install -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} -- /dev/null ${%%RC_NAME%%_pid}
-	[ -d ${%%RC_NAME%%_data_dir} ] || install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} -- ${%%RC_NAME%%_data_dir}
+	[ -d ${%%RC_NAME%%_pid_dir} ] || install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} ${%%RC_NAME%%_pid_dir}
+	[ -d ${%%RC_NAME%%_data_dir} ] || install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} ${%%RC_NAME%%_data_dir}
 
 	# .NET 6+ use dual mode sockets to avoid the separate AF handling.
 	# disable .NET use of V6 if no ipv6 is configured.
@@ -69,10 +72,4 @@ start_precmd=%%RC_NAME%%_precmd
 	export LD_LIBRARY_PATH=%%PREFIX%%/lib/emby-server/lib:%%LOCALBASE%%/lib
 }
 
-stop_postcmd=%%RC_NAME%%_postcmd
-%%RC_NAME%%_postcmd()
-{
-	rm -f ${%%RC_NAME%%_pid}
-}
-
 run_rc_command "$1"