git: c3383035389f - main - misc/openhab: take runtime user into account, fix piddir handling

From: Alexander Leidinger <netchild_at_FreeBSD.org>
Date: Mon, 04 Sep 2023 17:22:52 UTC
The branch main has been updated by netchild:

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

commit c3383035389f393897c1287ab1682afb3c0ffea3
Author:     Alexander Leidinger <netchild@FreeBSD.org>
AuthorDate: 2023-09-04 17:20:47 +0000
Commit:     Alexander Leidinger <netchild@FreeBSD.org>
CommitDate: 2023-09-04 17:22:49 +0000

    misc/openhab: take runtime user into account, fix piddir handling
    
    The rc.d script lost the runtime user handling and the piddir was not
    set which caused warnings in the prestart routine.
    
    Noticed by:     Martin ehk <rehak@tekkirk.org>
---
 UPDATING                      | 11 +++++++++++
 misc/openhab/Makefile         |  2 +-
 misc/openhab/files/openhab.in |  6 +++---
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/UPDATING b/UPDATING
index 7ded41161f91..24e99771a386 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,17 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20230904:
+  AUTHOR: netchild@FreeBSD.org
+  AFFECTS: users of misc/openhab
+
+  The rc.d script of 4.0.2 had an error which didn't take the user to
+  run openhab into account. After installing the update and stopping
+  openhab run (for the default settings)
+    chown -R openhab:openhab /var/db/openhab/userdata /var/log/openhab
+  If you use other directories for the userdata and logs, you need to
+  adapt accordingly.
+
 20230822:
   AUTHOR: arrowd@FreeBSD.org
   AFFECTS: users of sysutils/polkit together with sysutils/consolekit2
diff --git a/misc/openhab/Makefile b/misc/openhab/Makefile
index 4e2313d4e650..c33dd44857e6 100644
--- a/misc/openhab/Makefile
+++ b/misc/openhab/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	openhab
 PORTVERSION=	4.0.2
-PORTREVISION=	0
+PORTREVISION=	1
 CATEGORIES=	misc java
 MASTER_SITES=	https://openhab.jfrog.io/artifactory/libs-release-local/org/openhab/distro/openhab/${PORTVERSION}/
 DISTNAME=	openhab-${PORTVERSION}
diff --git a/misc/openhab/files/openhab.in b/misc/openhab/files/openhab.in
index 5c2ce115c27e..7acec2be6e34 100644
--- a/misc/openhab/files/openhab.in
+++ b/misc/openhab/files/openhab.in
@@ -58,7 +58,7 @@ eval "_openhab_conf_dir=\${${name}_conf_dir:-'%%PREFIX%%/etc/openhab'}"
 eval "_openhab_runtime_dir=\${${name}_runtime_dir:-'%%PREFIX%%/libexec/openhab/runtime'}"
 eval "_openhab_userdata_dir=\${${name}_userdata_dir:-'/var/db/openhab/userdata'}"
 eval "_openhab_log_dir=\${${name}_log_dir:-'/var/log/openhab'}"
-eval "_openhab_piddir=\${${name}_piddir}"
+eval "_openhab_piddir=\${${name}_piddir:-/var/run/${name}}"
 
 eval "_openhab_java_opts=\${${name}_java_opts:-''}"
 
@@ -78,12 +78,12 @@ export OPENHAB_LOGDIR="${_openhab_log_dir}"
 export LC_ALL=en_US.UTF-8
 export JAVA_VERSION=17
 
-pidfile=/var/run/${name}/${name}.pid
+pidfile=${_openhab_piddir}/${name}.pid
 
 start_precmd="openhab_prestart"
 
 command=/usr/sbin/daemon
-command_args="-p ${pidfile} -c -t openhab ${OPENHAB_HOME}/start.sh server"
+command_args="-u ${_openhab_user} -p ${pidfile} -c -t openhab ${OPENHAB_HOME}/start.sh server"
 
 openhab_prestart() {
     # Make sure we have our RUNDIR, even if it's on a tmpfs