rsyslog: preserve existing configuration
authorGiacomo Sanchietti <giacomo.sanchietti@nethesis.it>
Thu, 9 Jun 2022 12:27:12 +0000 (14:27 +0200)
committerRosen Penev <rosenp@gmail.com>
Thu, 7 Jul 2022 17:34:58 +0000 (10:34 -0700)
Signed-off-by: Giacomo Sanchietti <giacomo.sanchietti@nethesis.it>
admin/rsyslog/Makefile
admin/rsyslog/files/20_rsyslog [new file with mode: 0644]
admin/rsyslog/files/rsyslog [deleted file]
admin/rsyslog/files/rsyslog.conf

index a93595df195c20c20480972381bbb7c62496031e..d27778f31f8af44488880c9804d5f7b1341d3b66 100644 (file)
@@ -72,8 +72,8 @@ define Package/rsyslog/install
        $(INSTALL_CONF) ./files/rsyslog.conf $(1)/etc
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/rsyslog.init $(1)/etc/init.d/rsyslog
-       $(INSTALL_DIR) $(1)/etc/config
-       $(INSTALL_CONF) ./files/rsyslog $(1)/etc/config
+       $(INSTALL_DIR) $(1)/etc/uci-defaults
+       $(INSTALL_CONF) ./files/20_rsyslog $(1)/etc/uci-defaults
 endef
 
 define Package/rsyslog/config
diff --git a/admin/rsyslog/files/20_rsyslog b/admin/rsyslog/files/20_rsyslog
new file mode 100644 (file)
index 0000000..6fd008a
--- /dev/null
@@ -0,0 +1,33 @@
+[ "$(sed -e '/^#/d' -e '/^\s*$/d' /etc/rsyslog.conf)" != "" ] && exit 0
+[ "$(uci -q get rsyslog.syslog)" == "syslog" ] && exit 0
+
+uci -q import rsyslog << EOI
+config syslog 'syslog'
+       option tcp_input_port '514'
+       option udp_input '1'
+       option tcp_input '0'
+       option udp_input_port '514'
+       option default_template 'RSYSLOG_TraditionalFileFormat'
+       list modules 'imuxsock'
+       list modules 'imklog'
+
+config selector
+       option source '*.info;mail.none;authpriv.none;cron.none'
+       option destination '/var/log/messages'
+
+config selector
+       option source 'authpriv.*'
+       option destination '/var/log/secure'
+
+config selector
+       option source 'mail.*'
+       option destination '/var/log/maillog'
+
+config selector
+       option source 'cron.*'
+       option destination '/var/log/cron'
+
+config selector
+       option source 'local7.*'
+       option destination '/var/log/boot.log'
+EOI
diff --git a/admin/rsyslog/files/rsyslog b/admin/rsyslog/files/rsyslog
deleted file mode 100644 (file)
index b4cd422..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-config syslog syslog
-    option tcp_input '0'
-    option tcp_input_port '514'
-    option udp_input '1'
-    option udp_input_port '514'
-    option default_template 'RSYSLOG_TraditionalFileFormat'
-    list modules 'imuxsock'
-    list modules 'imklog'
-
-config selector
-       option source '*.info;mail.none;authpriv.none;cron.none'
-       option destination '/var/log/messages'
-
-config selector
-    option source 'authpriv.*'
-    option destination '/var/log/secure'
-
-config selector
-    option source 'mail.*'
-    option destination '/var/log/maillog'
-
-config selector
-    option source 'cron.*'
-    option destination '/var/log/cron'
-
-config selector
-    option source 'local7.*'
-    option destination '/var/log/boot.log'
index 5aaed415b57df47324a0e8cf8340bf825bb3fb5c..0381b3e6f244ea5ab871792ddf1d9d4e4d4db325 100644 (file)
@@ -1,18 +1,18 @@
-module(load="imuxsock")
-module(load="imklog")
-module(load="imudp")
-input(type="imudp" port="514")
-#module(load="imtcp")
-#input(type="imtcp" port="514")
-
-$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
-
-*.info;mail.none;authpriv.none;cron.none  /var/log/messages
-
-authpriv.*                                /var/log/secure
-
-mail.*                                    /var/log/maillog
-
-cron.*                                    /var/log/cron
-
-local7.*                                  /var/log/boot.log
+#
+# The preferred way to configure rsyslogd is now UCI.
+#
+# This file can be still used and will be included
+# on top of the final configuration inside /var/etc/rsyslog.conf
+#
+# Example of default configuration:
+#
+# module(load="imuxsock")
+# module(load="imklog")
+# module(load="imudp")
+# input(type="imudp" port="514")
+# $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
+# *.info;mail.none;authpriv.none;cron.none  /var/log/messages
+# authpriv.*                                /var/log/secure
+# mail.*                                    /var/log/maillog
+# cron.*                                    /var/log/cron
+local7.*                                  /var/log/boot.log