aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2019-01-27 23:38:16 +0100
committerJosef Schlehofer <pepe.schlehofer@gmail.com>2019-01-28 22:38:15 +0100
commita00c1a3f4ec60c812eb9a77063e6fa2ba01882c1 (patch)
tree46794fef710eac83f0aa8ca2352c6196a0791b2a
parent5f07bb10948f6ebdf83470c3437c3072aab982e3 (diff)
syslog-ng: add logread wrapper
Many (LuCI) packages require logread. Otherwise, for example, System Log tab in LuCI is empty Signed-off-by: Dirk Brenken <dev@brenken.org>
-rw-r--r--admin/syslog-ng/Makefile2
-rw-r--r--admin/syslog-ng/files/logread76
2 files changed, 78 insertions, 0 deletions
diff --git a/admin/syslog-ng/Makefile b/admin/syslog-ng/Makefile
index 06a7f9402..7cbb15718 100644
--- a/admin/syslog-ng/Makefile
+++ b/admin/syslog-ng/Makefile
@@ -82,6 +82,8 @@ define Package/syslog-ng/install
$(INSTALL_DIR) $(1)/etc/syslog-ng.d
$(INSTALL_DATA) ./files/syslog-ng.conf $(1)/etc
touch $(1)/etc/syslog-ng.d/.keep
+
+ $(INSTALL_BIN) ./files/logread $(1)/usr/sbin
endef
define Package/syslog-ng/postinst
diff --git a/admin/syslog-ng/files/logread b/admin/syslog-ng/files/logread
new file mode 100644
index 000000000..9dfe357d0
--- /dev/null
+++ b/admin/syslog-ng/files/logread
@@ -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