diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vyatta-update-conntrack-log.pl | 46 |
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; |