luci-mod-status: display log_file in status if defined
authorChristian Korber <ckorber@tdt.de>
Wed, 3 Jul 2024 11:55:43 +0000 (13:55 +0200)
committerPaul Donald <newtwen+github@gmail.com>
Mon, 22 Jul 2024 22:41:47 +0000 (00:41 +0200)
Commit includes wrapper syslog in /usr/libexec. If a log file is configured, the output of this file is displayed. Otherwise the output of logread is displayed.

Signed-off-by: Christian Korber <ckorber@tdt.de>
modules/luci-mod-status/htdocs/luci-static/resources/view/status/syslog.js
modules/luci-mod-status/root/usr/libexec/syslog-wrapper [new file with mode: 0755]
modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json

index 2aa3c46093686e1dec488d9971979fd46be72847..83a42cdbbf398e730f5de366abb1918b8d53075f 100644 (file)
@@ -7,12 +7,11 @@
 return view.extend({
        retrieveLog: async function() {
                return Promise.all([
-                       L.resolveDefault(fs.stat('/sbin/logread'), null),
-                       L.resolveDefault(fs.stat('/usr/sbin/logread'), null)
+                       L.resolveDefault(fs.stat('/usr/libexec/syslog-wrapper'), null)
                ]).then(function(stat) {
-                       var logger = stat[0] ? stat[0].path : stat[1] ? stat[1].path : null;
+                       var logger = stat[0].path;
 
-                       return fs.exec_direct(logger, [ '-e', '^' ]).then(logdata => {
+                       return fs.exec_direct(logger).then(logdata => {
                                const loglines = logdata.trim().split(/\n/);
                                return { value: loglines.join('\n'), rows: loglines.length + 1 };
                        }).catch(function(err) {
diff --git a/modules/luci-mod-status/root/usr/libexec/syslog-wrapper b/modules/luci-mod-status/root/usr/libexec/syslog-wrapper
new file mode 100755 (executable)
index 0000000..75af831
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. /lib/functions.sh
+
+main() {
+       local log_file
+
+       log_file="$(uci_get system @system[0] log_file "")"
+       if [ -f "$log_file" ]; then
+               cat "$log_file"
+               return
+       fi
+
+       if [ -f /sbin/logread ]; then
+               /sbin/logread -e ^
+       else
+               /usr/sbin/logread -e ^
+       fi
+}
+
+main
index 45dd7d7d9e4e1be554c1c26aa527b2c7f811b4a7..200631e97b382bd3fa34e1ef7aa46361c8a84c84 100644 (file)
                        "cgi-io": [ "exec" ],
                        "file": {
                                "/bin/dmesg -r": [ "exec" ],
-                               "/sbin/logread": [ "stat" ],
-                               "/sbin/logread -e ^": [ "exec" ],
-                               "/usr/sbin/logread": [ "stat" ],
-                               "/usr/sbin/logread -e ^": [ "exec" ]
+                               "/usr/libexec/syslog-wrapper": [ "exec" ]
                        },
                        "ubus": {
                                "file": [ "stat" ]