commit:     e765c8b50800a67f21a7b5e65a13a6a6971b5b8b
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 24 11:59:40 2024 +0000
Commit:     Florian Schmaus <flow <AT> gentoo <DOT> org>
CommitDate: Thu Jul 25 07:20:39 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e765c8b5

app-misc/openhab-bin: add support for OpenRC

Thanks to Xavier Miller for the initial patches.

Closes: https://bugs.gentoo.org/936265
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>

 app-misc/openhab-bin/files/openhab.initd               | 18 ++++++++++++++++++
 ...ab-bin-4.2.0.ebuild => openhab-bin-4.2.0-r1.ebuild} | 11 +++++++++++
 2 files changed, 29 insertions(+)

diff --git a/app-misc/openhab-bin/files/openhab.initd 
b/app-misc/openhab-bin/files/openhab.initd
new file mode 100644
index 000000000000..a5899b24994f
--- /dev/null
+++ b/app-misc/openhab-bin/files/openhab.initd
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+
+pidfile=/run/${SVCNAME}.pid
+
+command_user="openhab:openhab"
+command="/usr/bin/openhab"
+command_args="daemon"
+command_background=true
+
+depend() {
+       need net
+}
+
+stop() {
+    ebegin "Stopping ${RC_SVCNAME}"
+    ${command} stop
+    eend $?
+}

diff --git a/app-misc/openhab-bin/openhab-bin-4.2.0.ebuild 
b/app-misc/openhab-bin/openhab-bin-4.2.0-r1.ebuild
similarity index 88%
rename from app-misc/openhab-bin/openhab-bin-4.2.0.ebuild
rename to app-misc/openhab-bin/openhab-bin-4.2.0-r1.ebuild
index 9b1c384fe722..6625624aba64 100644
--- a/app-misc/openhab-bin/openhab-bin-4.2.0.ebuild
+++ b/app-misc/openhab-bin/openhab-bin-4.2.0-r1.ebuild
@@ -96,6 +96,8 @@ export JAVA_HOME
 exec /usr/share/openhab/runtime/bin/karaf "\$@"
 EOF
        newbin "${DISTDIR}"/openhab-cli-2024-01-14 openhab-cli
+
+       newinitd "${FILESDIR}"/openhab.initd openhab
 }
 
 pkg_postinst() {
@@ -120,5 +122,14 @@ pkg_postinst() {
                if [[ -v openhab_service_active ]]; then
                        edob systemctl start openhab
                fi
+       elif [[ -d /run/openrc ]]; then
+               einfo "Follow these steps to complete the update of OpenHAB:"
+               einfo
+               einfo "1. Stop the OpenHAB's service"
+               einfo "$ rc-service openhab stop"
+               einfo "2. Clean OpenHAB's cache"
+               einfo "$ openahb-cli clean-cache"
+               einfo "3. Restart OpenHAB's service"
+               einfo "$ rc-service openhab start"
        fi
 }

Reply via email to