From d8af25272d8daae6da652f683d49f1c0e346bb67 Mon Sep 17 00:00:00 2001 From: p0wer <2510748+p0wertiger@users.noreply.github.com> Date: Mon, 27 Feb 2023 23:25:12 +0100 Subject: [PATCH] Issue #247 Ensure systemd-journal-gatewayd socket is correct (#277) * Create systemd socket override for systemd-journal-gatewayd As stated in https://github.com/home-assistant/supervised-installer/issues/247 the default action for systemd-journal-gatewayd is to listen on HTTP port while Supervisor needs Unix socket file that's bind mounted in Docker container. This override changes socket location. * Check and fix systemd socket file As stated in #247 with the default setup the path /run/systemd-journal-gatewayd.sock may be a directory, not a file, we have to fix that * Remove unnecessary unit file Socket location change has been moved to systemd override which is the suggested way of changing original packaged unit behavior * Rename hassio-supervisor.conf to 10-hassio-supervisor.conf --- homeassistant-supervised/DEBIAN/postinst | 8 ++++++++ .../10-hassio-supervisor.conf | 3 +++ .../system/systemd-journal-gatewayd.socket | 18 ------------------ 3 files changed, 11 insertions(+), 18 deletions(-) create mode 100644 homeassistant-supervised/etc/systemd/system/systemd-journal-gatewayd.socket.d/10-hassio-supervisor.conf delete mode 100644 homeassistant-supervised/usr/lib/systemd/system/systemd-journal-gatewayd.socket diff --git a/homeassistant-supervised/DEBIAN/postinst b/homeassistant-supervised/DEBIAN/postinst index dc43ddd..414e8b2 100755 --- a/homeassistant-supervised/DEBIAN/postinst +++ b/homeassistant-supervised/DEBIAN/postinst @@ -31,6 +31,14 @@ if [ "$(systemctl is-active systemd-resolved)" = 'inactive' ]; then systemctl start systemd-resolved.service> /dev/null 2>&1; fi +# Check and fix systemd-journal-gatewayd socket location +if [ ! -S "/run/systemd-journal-gatewayd.sock" ]; then + info "Set up systemd-journal-gatewayd socket file" + if [ "$(systemctl is-active systemd-journal-gatewayd.socket)" = 'active' ]; then + systemctl stop systemd-journal-gatewayd.socket> /dev/null 2>&1; + fi + rm -rf "/run/systemd-journal-gatewayd.sock"; +fi # Enable and start systemd-journal-gatewayd if [ "$(systemctl is-active systemd-journal-gatewayd.socket)" = 'inactive' ]; then info "Enable systemd-journal-gatewayd" diff --git a/homeassistant-supervised/etc/systemd/system/systemd-journal-gatewayd.socket.d/10-hassio-supervisor.conf b/homeassistant-supervised/etc/systemd/system/systemd-journal-gatewayd.socket.d/10-hassio-supervisor.conf new file mode 100644 index 0000000..2674ad6 --- /dev/null +++ b/homeassistant-supervised/etc/systemd/system/systemd-journal-gatewayd.socket.d/10-hassio-supervisor.conf @@ -0,0 +1,3 @@ +[Socket] +ListenStream= +ListenStream=/run/systemd-journal-gatewayd.sock diff --git a/homeassistant-supervised/usr/lib/systemd/system/systemd-journal-gatewayd.socket b/homeassistant-supervised/usr/lib/systemd/system/systemd-journal-gatewayd.socket deleted file mode 100644 index a48e519..0000000 --- a/homeassistant-supervised/usr/lib/systemd/system/systemd-journal-gatewayd.socket +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -# -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. - -[Unit] -Description=Journal Gateway Service Socket -Documentation=man:systemd-journal-gatewayd(8) - -[Socket] -ListenStream=/run/systemd-journal-gatewayd.sock - -[Install] -WantedBy=sockets.target \ No newline at end of file