X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=blobdiff_plain;f=guardian;h=3435c096690ec8a8f4d27342b51b7e17416c5e5b;hp=c0773eef175bd1b4e137898b6f56704dfd3fd22d;hb=45bf2a03c98db3aeb415d4315933f238748ecb53;hpb=6abac3d4df20329e1f1e8967aa2c097fb9303d61 diff --git a/guardian b/guardian index c0773ee..3435c09 100644 --- a/guardian +++ b/guardian @@ -22,17 +22,50 @@ use strict; use threads; use threads::shared; +use Getopt::Long; use Thread::Queue; use Linux::Inotify2; +require Guardian::Config; require Guardian::Parser; require Guardian::Socket; +# Define version. +my $version ="2.0"; + # Array to store the monitored logfiles. my @monitored_files = ( "/var/log/snort/alert", ); +# Get and store the given command line arguments in a hash. +my %cmdargs = (); + +&GetOptions (\%cmdargs, + 'foreground|f', + 'config|c=s', + 'help|h', + 'version|v', +); + +# Show help / version information. +if (defined($cmdargs{"help"})) { + print "Guardian $version \n"; + print "Usage: guardian \n"; + print " -c, --config\t\tspecifiy a configuration file other than the default (/etc/guardian/guardian.conf)\n"; + print " -f, --foreground\trun in the foreground (doesn't fork, any output goes to STDOUT)\n"; + print " -h, --help\t\tshows this help\n"; + print " -v, --version\t\tdisplay programm version and exit.\n"; + exit; +} elsif (defined($cmdargs{"version"})) { + print "Guardian $version \n"; + exit; +} + +# Read-in the configuration file and store the settings. +# Push the may be given config file argument. +my %mainsettings = &Guardian::Config::UseConfig($cmdargs{"config"}); + # Create the main queue. It is used to store and process all events which are # reported and enqueued by the worker threads. my $queue :shared = new Thread::Queue or die "Could not create new, empty queue. $!\n";;