syslog-ng: alternative for logread
authorSergey Ponomarev <stokito@gmail.com>
Sat, 2 Mar 2024 19:30:41 +0000 (21:30 +0200)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Sun, 24 Nov 2024 10:10:10 +0000 (11:10 +0100)
When the syslog-ng installed it records all messages to /var/log/messages.
This makes the default OpenWrt's ubox /sbin/logread useless and return nothing.

The logread script was added to the syslog-ng as a shim.
It's based on `tail /var/log/messages` and repeats basic options that the ubox logread have.
The script is installed instead of the /sbin/logread and this is causes an error.

Instead install it to /usr/libexec/logread.sh and specify as an alternative /sbin/logread.

The ubox logread also needs to be made as alternative in /usr/libexec/logread-ubox.

So we need to give it a separate name.
The most simple and clear would be logread-shell or just logread.sh.

Suggested-by: Andreas Gnau <andreas.gnau@iopsys.eu>
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
admin/syslog-ng/Makefile
admin/syslog-ng/files/logread [deleted file]
admin/syslog-ng/files/logread.sh [new file with mode: 0644]

index f366dcfcc1d5aeaa0f5e2f6bbf938c6f6097565e..1bfdee3065d8dcb50d70a00dac1c22a2633b6915 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=syslog-ng
 PKG_VERSION:=4.7.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_MAINTAINER:=Josef Schlehofer <pepe.schlehofer@gmail.com>
 PKG_LICENSE:=LGPL-2.1-or-later GPL-2.0-or-later
@@ -35,6 +35,7 @@ define Package/syslog-ng
   TITLE:=A powerful syslog daemon
   URL:=https://www.syslog-ng.com/products/open-source-log-management/
   DEPENDS:=+libpcre2 +glib2 +libopenssl +libpthread +librt +libdbi +libjson-c +libcurl +libuuid +SYSLOGNG_LOGROTATE:logrotate +LIBCURL_ZLIB:zlib
+  ALTERNATIVES:=300:/sbin/logread:/usr/libexec/logread.sh
 endef
 
 define Package/syslog-ng/description
@@ -123,8 +124,8 @@ define Package/syslog-ng/install
        $(INSTALL_DATA) ./files/syslog-ng.conf $(1)/etc
        touch $(1)/etc/syslog-ng.d/.keep
 
-       $(INSTALL_DIR) $(1)/sbin
-       $(INSTALL_BIN) ./files/logread $(1)/sbin
+       $(INSTALL_DIR) $(1)/usr/libexec
+       $(INSTALL_BIN) ./files/logread.sh $(1)/usr/libexec/logread.sh
 
        $(INSTALL_DIR) $(1)/usr/share/syslog-ng/include/
        $(CP) -r ./files/scl $(1)/usr/share/syslog-ng/include/
diff --git a/admin/syslog-ng/files/logread b/admin/syslog-ng/files/logread
deleted file mode 100644 (file)
index 9dfe357..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-# Shell script compatibility wrapper for /sbin/logread
-#
-# Copyright (C) 2019 Dirk Brenken <dev@brenken.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-logfile="/var/log/messages"
-
-if [ ! -f "${logfile}" ]
-then
-       printf "%s\n" "Error: logfile not found!"
-       exit 2
-fi
-
-usage()
-{
-       printf "%s\n" "Usage: logread [options]"
-       printf "%s\n" "Options:"
-       printf "%5s %-10s%s\n" "-l" "<count>" "Got only the last 'count' messages"
-       printf "%5s %-10s%s\n" "-e" "<pattern>" "Filter messages with a regexp"
-       printf "%5s %-10s%s\n" "-f" "" "Follow log messages"
-       printf "%5s %-10s%s\n" "-h" "" "Print this help message"
-}
-
-if [ -z "${1}" ]
-then
-       cat "${logfile}"
-       exit 0
-else
-       while [ "${1}" ]
-       do
-               case "${1}" in
-                       -l)
-                               shift
-                               count="${1//[^0-9]/}"
-                               tail -n "${count:-50}" "${logfile}"
-                               exit 0
-                               ;;
-                       -e)
-                               shift
-                               pattern="${1}"
-                               grep -E "${pattern}" "${logfile}"
-                               exit 0
-                               ;;
-                       -f)
-                               tail -f "${logfile}"
-                               exit 0
-                               ;;
-                       -fe)
-                               shift
-                               pattern="${1}"
-                               tail -f "${logfile}" | grep -E "${pattern}"
-                               exit 0
-                               ;;
-                       -h|*)
-                               usage
-                               exit 1
-                               ;;
-               esac
-               shift
-       done
-fi
diff --git a/admin/syslog-ng/files/logread.sh b/admin/syslog-ng/files/logread.sh
new file mode 100644 (file)
index 0000000..9dfe357
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/sh
+# Shell script compatibility wrapper for /sbin/logread
+#
+# Copyright (C) 2019 Dirk Brenken <dev@brenken.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+logfile="/var/log/messages"
+
+if [ ! -f "${logfile}" ]
+then
+       printf "%s\n" "Error: logfile not found!"
+       exit 2
+fi
+
+usage()
+{
+       printf "%s\n" "Usage: logread [options]"
+       printf "%s\n" "Options:"
+       printf "%5s %-10s%s\n" "-l" "<count>" "Got only the last 'count' messages"
+       printf "%5s %-10s%s\n" "-e" "<pattern>" "Filter messages with a regexp"
+       printf "%5s %-10s%s\n" "-f" "" "Follow log messages"
+       printf "%5s %-10s%s\n" "-h" "" "Print this help message"
+}
+
+if [ -z "${1}" ]
+then
+       cat "${logfile}"
+       exit 0
+else
+       while [ "${1}" ]
+       do
+               case "${1}" in
+                       -l)
+                               shift
+                               count="${1//[^0-9]/}"
+                               tail -n "${count:-50}" "${logfile}"
+                               exit 0
+                               ;;
+                       -e)
+                               shift
+                               pattern="${1}"
+                               grep -E "${pattern}" "${logfile}"
+                               exit 0
+                               ;;
+                       -f)
+                               tail -f "${logfile}"
+                               exit 0
+                               ;;
+                       -fe)
+                               shift
+                               pattern="${1}"
+                               tail -f "${logfile}" | grep -E "${pattern}"
+                               exit 0
+                               ;;
+                       -h|*)
+                               usage
+                               exit 1
+                               ;;
+               esac
+               shift
+       done
+fi