summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDeepti Kulkarni <deepti@vyatta.com>2011-12-13 02:49:29 -0800
committerDeepti Kulkarni <deepti@vyatta.com>2011-12-13 02:49:29 -0800
commitb90f8af4fb0b2a8ce60014144e47fdbb0922e34d (patch)
tree3a676976b8d9bb6a04d8d320a997fcfd70d28aac /scripts
parent44f59da7eb534c3a572a6b738813ee099cb83fe8 (diff)
downloadvyatta-conntrack-b90f8af4fb0b2a8ce60014144e47fdbb0922e34d.tar.gz
vyatta-conntrack-b90f8af4fb0b2a8ce60014144e47fdbb0922e34d.zip
Bug fix 7397 - Conntrack log creation and deletion.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/vyatta-update-conntrack-log.pl46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/vyatta-update-conntrack-log.pl b/scripts/vyatta-update-conntrack-log.pl
new file mode 100644
index 0000000..09ee0a5
--- /dev/null
+++ b/scripts/vyatta-update-conntrack-log.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+use strict;
+use lib "/opt/vyatta/share/perl5";
+use Vyatta::Conntrack::Config;
+
+my $pfile = '/var/run/vyatta/connlogd.lock';
+my $lfile = '/var/run/vyatta/connlogd.log';
+
+my $config = new Vyatta::Conntrack::Config;
+my $oconfig = new Vyatta::Conntrack::Config;
+$config->setup();
+$oconfig->setupOrig();
+
+if (!($config->isDifferentFrom($oconfig))) {
+ if ($config->isEmpty()) {
+ print STDERR "Empty Configuration\n";
+ exit 1;
+ }
+ # config not changed. do nothing.
+ exit 0;
+}
+
+if ($config->isEmpty()) {
+ # delete the daemon process
+ Vyatta::Conntrack::Config::kill_daemon();
+ # delete the .lock and .log file getting generated
+ `rm -f $pfile`;
+ `rm -f $lfile`;
+ exit 0;
+}
+
+my $cmd = $config->get_command();
+if ($cmd) {
+ # First stop the daemon and restart with config
+ Vyatta::Conntrack::Config::kill_daemon();
+ `rm -f $pfile`;
+ `rm -f $lfile`;
+ system("$cmd");
+ if ($? >> 8) {
+ print STDERR "Failed to start conntrack logging daemon";
+ exit 1;
+ }
+}
+
+exit 0;