diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-13 16:02:50 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-13 16:02:50 +0100 |
commit | e140af144e987ff7f6d767f2dc48b9cf685803fd (patch) | |
tree | 4a01971890865b4b3ca837d563bc673cbb787de8 /bin/mauveconsole | |
parent | d28af4ec946c6aa4b645b73cef47d7e0c680bc0d (diff) |
Big commit
* Added manpages for all binaries
* Added log-reopening for mauvealert-server, and logrotate snippet
* mauveserver now adds a user on install, and runs as that user
* Big logging tidy-up
* Alert subjects are only overwritten by the source, when the subject in the databse is empty
* Removed various attr_writer methods that were being redifined
* Added a notes box to the acknowledge form, but this doesn't work yet
Diffstat (limited to 'bin/mauveconsole')
-rwxr-xr-x | bin/mauveconsole | 65 |
1 files changed, 56 insertions, 9 deletions
diff --git a/bin/mauveconsole b/bin/mauveconsole index debe5af..5a16a7e 100755 --- a/bin/mauveconsole +++ b/bin/mauveconsole @@ -1,23 +1,70 @@ #!/usr/bin/ruby1.8 +# NAME +# +# mauveconsole -- Ruby console to query the mauvealert server directly +# +# SYNOPSIS +# +# mauveconsole [-h | --help] [<configuration file>] +# +# OPTIONS +# +# -h, --help Show a help message +# <configuration file> File to load the configuration from. If none is +# specified, then mauvealert.conf in the current +# directory is used, and failing that +# /etc/mauvealert/mauvealert.conf is used. +# +# SEE ALSO +# +# irb(1), mauveserver(1), mauveclient(1) +# +# AUTHOR +# +# Patrick J Cherry <patrick@bytemark.co.uk> +# -require 'pp' -require 'irb' -require 'thread' -require 'mauve/configuration' +def error(msg) + STDERR.print "*** Error: #{msg}\n" + STDERR.print "*** For help, type: #{$0} -h\n" + exit 1 +end -Thread.abort_on_exception = true +# CAUTION! Kwality kode. +# +if ARGV.any?{|a| a =~ /--?h(elp)?/} + # Open the file, stripping the shebang line + lines = File.open(__FILE__){|fh| fh.readlines}[1..-1] + + lines.each do |line| + line.chomp! + break if line.empty? + puts line[2..-1].to_s + end + + exit 0 +end configuration_file = ARGV.shift -configuration_file = [".", "/etc/mauvealert/"].find{|d| File.file?(File.join(d,"mauveserver.conf")) } if configuration_file.nil? +configuration_file = [".", "/etc/mauvealert/"].collect{|x| File.join("mauveserver.conf") }.find{|d| File.file?(d)} if configuration_file.nil? configuration_file = File.expand_path(configuration_file) unless File.file?(configuration_file) - STDERR.print "Configuration file #{configuration_file} not found" - Kernel.exit 1 + error "Configuration file #{configuration_file} not found\n" end -Mauve::Configuration.current = Mauve::ConfigurationBuilder.load(configuration_file) +require 'irb' +require 'thread' +require 'mauve/configuration' + +Thread.abort_on_exception = true include Mauve +begin + Configuration.current = ConfigurationBuilder.load(configuration_file) +rescue StandardError => ex + error ex.message +end + IRB.start |