ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/admin/syslog-ng/files/logread b/external/subpack/admin/syslog-ng/files/logread
new file mode 100644
index 0000000..9dfe357
--- /dev/null
+++ b/external/subpack/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
diff --git a/external/subpack/admin/syslog-ng/files/scl/network_localhost/detect.sh b/external/subpack/admin/syslog-ng/files/scl/network_localhost/detect.sh
new file mode 100755
index 0000000..acfb407
--- /dev/null
+++ b/external/subpack/admin/syslog-ng/files/scl/network_localhost/detect.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+if [ "$(sysctl -n net.ipv6.conf.lo.disable_ipv6)" = "0" ]; then
+ echo 'network(ip("::1") port(514) transport(udp) ip-protocol(6) )'
+else
+ echo 'network(ip("127.0.0.1") port(514) transport(udp) ip-protocol(4) )'
+fi
diff --git a/external/subpack/admin/syslog-ng/files/scl/network_localhost/plugin.conf b/external/subpack/admin/syslog-ng/files/scl/network_localhost/plugin.conf
new file mode 100644
index 0000000..b278942
--- /dev/null
+++ b/external/subpack/admin/syslog-ng/files/scl/network_localhost/plugin.conf
@@ -0,0 +1 @@
+@module confgen context(source) name(network_localhost) exec("`scl-root`/network_localhost/detect.sh")
diff --git a/external/subpack/admin/syslog-ng/files/syslog-ng.conf b/external/subpack/admin/syslog-ng/files/syslog-ng.conf
new file mode 100644
index 0000000..847e21f
--- /dev/null
+++ b/external/subpack/admin/syslog-ng/files/syslog-ng.conf
@@ -0,0 +1,67 @@
+#############################################################################
+# OpenWrt syslog-ng.conf specific file
+# which collects all local logs into a single file called /var/log/messages.
+# More details about these settings can be found here:
+# https://www.syslog-ng.com/technical-documents/list/syslog-ng-open-source-edition
+
+@version: 4.0
+@include "scl.conf"
+
+options {
+ chain_hostnames(no); # Enable or disable the chained hostname format.
+ create_dirs(yes);
+ keep_hostname(yes); # Enable or disable hostname rewriting.
+ log_fifo_size(256); # The number of messages that the output queue can store.
+ log_msg_size(1024); # Maximum length of a message in bytes.
+ stats_freq(0); # The period between two STATS messages (sent by syslog-ng, containing statistics about dropped logs) in seconds.
+ flush_lines(0); # How many lines are flushed to a destination at a time.
+ use_fqdn(no); # Add Fully Qualified Domain Name instead of short hostname.
+};
+
+# syslog-ng gets messages from syslog-ng (internal) and from /dev/log
+
+source src {
+ internal();
+ unix-dgram("/dev/log");
+};
+
+source net {
+ network_localhost();
+};
+
+source s_network {
+ default-network-drivers(
+ # NOTE: TLS support
+ #
+ # the default-network-drivers() source driver opens the TLS
+ # enabled ports as well, however without an actual key/cert
+ # pair they will not operate and syslog-ng would display a
+ # warning at startup.
+ #
+ #tls(key-file("/path/to/ssl-private-key") cert-file("/path/to/ssl-cert"))
+ );
+};
+
+source kernel {
+ file("/proc/kmsg" program_override("kernel"));
+};
+
+destination messages {
+ file("/var/log/messages");
+};
+
+log {
+ source(src);
+ source(net);
+ source(kernel);
+ destination(messages);
+
+ # uncomment this line to open port 514 to receive messages
+ #source(s_network);
+};
+
+#
+# Finally, include any user settings last so that s/he can override or
+# supplement all "canned" settings inherited from the distribution.
+#
+@include "/etc/syslog-ng.d/" # Put any customization files in this directory
diff --git a/external/subpack/admin/syslog-ng/files/syslog-ng.init b/external/subpack/admin/syslog-ng/files/syslog-ng.init
new file mode 100644
index 0000000..5ca2d2a
--- /dev/null
+++ b/external/subpack/admin/syslog-ng/files/syslog-ng.init
@@ -0,0 +1,17 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2019 OpenWrt.org
+
+START=50
+
+USE_PROCD=1
+
+start_service() {
+ [ -f /etc/syslog-ng.conf ] || return 1
+ procd_open_instance
+ procd_set_param command /usr/sbin/syslog-ng --foreground
+ procd_close_instance
+}
+
+reload_service() {
+ /usr/sbin/syslog-ng-ctl reload
+}
diff --git a/external/subpack/admin/syslog-ng/files/syslog-ng.logrotate b/external/subpack/admin/syslog-ng/files/syslog-ng.logrotate
new file mode 100644
index 0000000..75a9a07
--- /dev/null
+++ b/external/subpack/admin/syslog-ng/files/syslog-ng.logrotate
@@ -0,0 +1,12 @@
+/var/log/messages {
+ compress
+ copytruncate
+ delaycompress
+ notifempty
+ maxsize @MAXSIZE@
+ missingok
+ postrotate
+ /usr/sbin/syslog-ng-ctl reload > /dev/null
+ endscript
+ rotate @ROTATE@
+}