From 0a60c68af7028fe58c3ece088c85fd3a04eb9a1f Mon Sep 17 00:00:00 2001
From: Mohit Mehta <mohit.mehta@vyatta.com>
Date: Fri, 10 Oct 2008 22:27:30 -0700
Subject: Fix Bug 3751 configuring multiple global syslog facilities overwrites
 previous ones in /etc/syslog.conf - multiple nodes configured under 'system
 syslog global' are appended to syslog.conf - default '*.notice
 -/var/log/messages' is removed from syslog.conf if any   node is configured
 under 'system syslog global' and is put back when nothing   configured under
 'system syslog global' - syslog process only restarted once after making all
 changes in config - added commit checks at 'system syslog <>' level nodes to
 specify facility

---
 templates/system/syslog/node.def | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'templates/system/syslog/node.def')

diff --git a/templates/system/syslog/node.def b/templates/system/syslog/node.def
index 72a82d78..7fd911f7 100644
--- a/templates/system/syslog/node.def
+++ b/templates/system/syslog/node.def
@@ -1,3 +1,11 @@
-help: Set syslog daemon
-delete:expression: "sudo sh -c \"/opt/vyatta/sbin/vyatta_update_syslog.pl \
-'' '\\/var\\/log\\/messages' '*.warning\t/var/log/messages \n'\" "
+help: Configure syslog daemon
+end: if [ -n "$VAR(./global/facility/@@)" ]; then
+      # remove the default config for global messages
+	sudo sh -c "sed -i '/\*\.notice[[:space:]]*-\/var\/log\/messages/d' /etc/syslog.conf"
+     else
+      # if not already there then write the default config for global messages
+      if ! grep -q "\*\.notice[[:space:]]*-/var/log/messages" /etc/syslog.conf; then
+	sudo sh -c "echo \"*.notice                -/var/log/messages\" >> /etc/syslog.conf"
+      fi
+     fi
+     sudo /usr/sbin/invoke-rc.d sysklogd restart
-- 
cgit v1.2.3

