From f8f458af401d92ffebd075fc1cefa99036631eae Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 1 Feb 2022 12:55:57 +0100 Subject: [PATCH] always use the systems hostname when streaming the syslog Signed-off-by: John Crispin --- renderer/templates/services/log.uc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/renderer/templates/services/log.uc b/renderer/templates/services/log.uc index b8bffcd..c1bd53a 100644 --- a/renderer/templates/services/log.uc +++ b/renderer/templates/services/log.uc @@ -1,4 +1,12 @@ -{% if (!length(log)) return %} +{% +if (!length(log)) return; +let hostname = state.unit?.hostname; +if (!hostname) { + cursor.load("system"); + let system = cursor.get_all("system", "@system[-1]"); + hostname = system?.hostname || OpenWifi; +} +%} # Syslog service configuration @@ -7,3 +15,4 @@ set system.@system[-1].log_port={{ s(log.port) }} set system.@system[-1].log_proto={{ s(log.proto) }} set system.@system[-1].log_size={{ s(log.size) }} set system.@system[-1].log_priority={{ s(log.priority) }} +set system.@system[-1].log_hostname={{ s(hostname) }}