git: b5bb6426f206 - main - misc/openhab*: update to 4.0.2, rc.d script changes

From: Alexander Leidinger <netchild_at_FreeBSD.org>
Date: Wed, 30 Aug 2023 06:52:34 UTC
The branch main has been updated by netchild:

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

commit b5bb6426f206a1e1807810539ea20d42d48b9509
Author:     Alexander Leidinger <netchild@FreeBSD.org>
AuthorDate: 2023-08-30 06:46:55 +0000
Commit:     Alexander Leidinger <netchild@FreeBSD.org>
CommitDate: 2023-08-30 06:52:28 +0000

    misc/openhab*: update to 4.0.2, rc.d script changes
    
    The rc.d script is now instance-aware (like the tomcat port). [1]
    This allows to make a copy of the rc.d script to a different name and
    use similar-named rc.conf variables to start a second instance of
    openhab.
    
    Submitted by:   Jürgen Weber <weberjn@gmail.com> [1]
---
 misc/openhab-addons/Makefile  |  2 +-
 misc/openhab-addons/distinfo  |  6 +--
 misc/openhab/Makefile         |  2 +-
 misc/openhab/distinfo         |  6 +--
 misc/openhab/files/openhab.in | 86 ++++++++++++++++++++++++++++---------------
 misc/openhab/pkg-plist        |  3 +-
 6 files changed, 66 insertions(+), 39 deletions(-)

diff --git a/misc/openhab-addons/Makefile b/misc/openhab-addons/Makefile
index 1559d52441ed..41dc21b3aefc 100644
--- a/misc/openhab-addons/Makefile
+++ b/misc/openhab-addons/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	openhab-addons
-PORTVERSION=	4.0.1
+PORTVERSION=	4.0.2
 CATEGORIES=	misc java
 MASTER_SITES=	https://openhab.jfrog.io/artifactory/libs-release-local/org/openhab/distro/openhab-addons/${PORTVERSION}/
 DISTNAME=	openhab-addons-${PORTVERSION}
diff --git a/misc/openhab-addons/distinfo b/misc/openhab-addons/distinfo
index c23fe4e5a2f8..81ff74122b23 100644
--- a/misc/openhab-addons/distinfo
+++ b/misc/openhab-addons/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1690713414
-SHA256 (openhab-addons-4.0.1.kar) = edb34f7ad477ccfc5f9b171958139b780d27354384463c4b8e2a9d6d895bb75c
-SIZE (openhab-addons-4.0.1.kar) = 393905810
+TIMESTAMP = 1693376683
+SHA256 (openhab-addons-4.0.2.kar) = de1fbbb2944176712852161b1311e69f3663f46854d216abab7f3b2c49638cfa
+SIZE (openhab-addons-4.0.2.kar) = 393906978
diff --git a/misc/openhab/Makefile b/misc/openhab/Makefile
index cf6b12a3c61f..4e2313d4e650 100644
--- a/misc/openhab/Makefile
+++ b/misc/openhab/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	openhab
-PORTVERSION=	4.0.1
+PORTVERSION=	4.0.2
 PORTREVISION=	0
 CATEGORIES=	misc java
 MASTER_SITES=	https://openhab.jfrog.io/artifactory/libs-release-local/org/openhab/distro/openhab/${PORTVERSION}/
diff --git a/misc/openhab/distinfo b/misc/openhab/distinfo
index 70611c625ab0..5a0b738b3a28 100644
--- a/misc/openhab/distinfo
+++ b/misc/openhab/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1690711802
-SHA256 (openhab-4.0.1.zip) = 9a3dee1ceea3fae5c1673da954886a0432d8cc121eac8d3d1220264e3ae59ecc
-SIZE (openhab-4.0.1.zip) = 104031926
+TIMESTAMP = 1693376325
+SHA256 (openhab-4.0.2.zip) = f132b501fe997daf83db8fbb7d8d8910c87d5620c1adc3abb6ec1c609bac62ac
+SIZE (openhab-4.0.2.zip) = 104058457
diff --git a/misc/openhab/files/openhab.in b/misc/openhab/files/openhab.in
index 042c5110e564..5c2ce115c27e 100644
--- a/misc/openhab/files/openhab.in
+++ b/misc/openhab/files/openhab.in
@@ -28,47 +28,73 @@
 
 . /etc/rc.subr
 
-name=openhab
-rcvar=openhab_enable
-
-load_rc_config $name
-
-: ${openhab_enable:="NO"}
-: ${openhab_user:="openhab"}
-: ${openhab_group:="openhab"}
-: ${openhab_http_port:="8080"}
-: ${openhab_https_port:="8443"}
-: ${openhab_listen_address:="0.0.0.0"}
-: ${openhab_backup_dir:="/var/db/openhab/backups"}
-: ${openhab_home_dir:="%%PREFIX%%/libexec/openhab"}
-: ${openhab_conf_dir:="%%PREFIX%%/etc/openhab"}
-: ${openhab_runtime_dir:="%%PREFIX%%/libexec/openhab/runtime"}
-: ${openhab_userdata_dir:="/var/db/openhab/userdata"}
-: ${openhab_log_dir:="/var/log/openhab"}
-
-export OPENHAB_USER="${openhab_user}"
-export OPENHAB_GROUP="${openhab_group}"
-export OPENHAB_HTTP_PORT="${openhab_http_port}"
-export OPENHAB_HTTPS_PORT="${openhab_https_port}"
-export OPENHAB_HTTP_ADDRESS="${openhab_listen_address}"
+case $0 in
+/etc/rc*)
+        # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
+        # so get the name of the script from $_file
+        name=$_file
+        ;;
+*)
+        name=$0
+        ;;
+esac
+
+name=${name##*/}
+rcvar=${name}_enable
+
+load_rc_config "${name}"
+
+eval "${rcvar}=\${${rcvar}:-'NO'}"
+eval "_openhab_user=\${${name}_user:-'openhab'}"
+eval "_openhab_group=\${${name}_group:-'openhab'}"
+
+eval "_openhab_http_port=\${${name}_http_port:-'8080'}"
+eval "_openhab_https_port=\${${name}_https_port:-'8443'}"
+eval "_openhab_listen_address=\${${name}_listen_address:-'0.0.0.0'}"
+
+eval "_openhab_backup_dir=\${${name}_backup_dir:-'/var/db/openhab/backups'}"
+eval "_openhab_home_dir=\${${name}_home_dir:-'%%PREFIX%%/libexec/openhab'}"
+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_java_opts=\${${name}_java_opts:-''}"
+
+export OPENHAB_USER="${_openhab_user}"
+export OPENHAB_GROUP="${_openhab_group}"
+export OPENHAB_HTTP_PORT="${_openhab_http_port}"
+export OPENHAB_HTTPS_PORT="${_openhab_https_port}"
+export OPENHAB_HTTP_ADDRESS="${_openhab_listen_address}"
 export OPENHAB_BACKUPS="${openhab_backup_dir}"
-export EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/cuau0 -Dsun.nio.fs.watchservice=polling ${openhab_java_opts}"
-export OPENHAB_HOME="${openhab_home_dir}"
-export OPENHAB_CONF="${openhab_conf_dir}"
-export OPENHAB_RUNTIME="${openhab_runtime_dir}"
-export OPENHAB_USERDATA="${openhab_userdata_dir}"
-export OPENHAB_LOGDIR="${openhab_log_dir}"
+export EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/cuau0 -Dsun.nio.fs.watchservice=polling ${_openhab_java_opts}"
+export OPENHAB_HOME="${_openhab_home_dir}"
+export OPENHAB_CONF="${_openhab_conf_dir}"
+export OPENHAB_RUNTIME="${_openhab_runtime_dir}"
+export OPENHAB_USERDATA="${_openhab_userdata_dir}"
+export OPENHAB_LOGDIR="${_openhab_log_dir}"
 # for UTF-8 encoding, language can be set inside openhab:
 export LC_ALL=en_US.UTF-8
 export JAVA_VERSION=17
 
 pidfile=/var/run/${name}/${name}.pid
 
+start_precmd="openhab_prestart"
+
 command=/usr/sbin/daemon
 command_args="-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
+    install -d -o ${_openhab_user} -g ${_openhab_group} -m 0755 "${_openhab_piddir}"
+    
+    install -d -o ${_openhab_user} -g ${_openhab_group} -m 0755 "${_openhab_log_dir}"
+}
+
+
 openhab_stop() {
-	${OPENHAB_RUNTIME}/bin/stop
+	su -m ${_openhab_user} -c "${OPENHAB_RUNTIME}/bin/stop"
 	if [ -e ${pidfile} ]; then
 		wait_for_pids $(cat ${pidfile})
 	fi
diff --git a/misc/openhab/pkg-plist b/misc/openhab/pkg-plist
index 66f207a5e57f..1a433fa0fd08 100644
--- a/misc/openhab/pkg-plist
+++ b/misc/openhab/pkg-plist
@@ -233,8 +233,9 @@ libexec/openhab/runtime/system/org/javassist/javassist/3.27.0-GA/javassist-3.27.
 libexec/openhab/runtime/system/org/jctools/jctools-core/2.1.2/jctools-core-2.1.2.jar
 libexec/openhab/runtime/system/org/jline/jline/3.21.0/jline-3.21.0.jar
 libexec/openhab/runtime/system/org/jmdns/jmdns/3.5.8/jmdns-3.5.8.jar
-libexec/openhab/runtime/system/org/jupnp/org.jupnp/2.7.0/org.jupnp-2.7.0.jar
+libexec/openhab/runtime/system/org/jupnp/org.jupnp/2.7.1.OH1/org.jupnp-2.7.1.OH1.jar
 libexec/openhab/runtime/system/org/jvnet/staxex/stax-ex/1.7.4/stax-ex-1.7.4.jar
+libexec/openhab/runtime/system/org/openhab/base-fixes/1.0.0/base-fixes-1.0.0.jar
 libexec/openhab/runtime/system/org/openhab/core/bundles/org.openhab.core.addon.marketplace.karaf/%%PORTVERSION%%/org.openhab.core.addon.marketplace.karaf-%%PORTVERSION%%.jar
 libexec/openhab/runtime/system/org/openhab/core/bundles/org.openhab.core.addon.marketplace/%%PORTVERSION%%/org.openhab.core.addon.marketplace-%%PORTVERSION%%.jar
 libexec/openhab/runtime/system/org/openhab/core/bundles/org.openhab.core.addon/%%PORTVERSION%%/org.openhab.core.addon-%%PORTVERSION%%.jar