diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mauveclient | 35 | ||||
-rwxr-xr-x | bin/mauveserver | 12 |
2 files changed, 31 insertions, 16 deletions
diff --git a/bin/mauveclient b/bin/mauveclient index 12747fa..77b8506 100755 --- a/bin/mauveclient +++ b/bin/mauveclient @@ -158,10 +158,14 @@ # require 'getoptlong' -require 'mauve/sender' -require 'mauve/proto' -require 'mauve/mauve_time' -require 'mauve/version' + +%w(sender mauve_time version proto).each do |r| + begin + require "mauve/#{r}" + rescue LoadError => ex + puts ex.to_s + end +end NOW = Mauve::MauveTime.now @@ -205,9 +209,17 @@ def parse_time_spec(spec = "now") end begin - update = Mauve::Proto::AlertUpdate.new - update.replace = false - update.alert = [] + begin + update = Mauve::Proto::AlertUpdate.new + update.replace = false + update.alert = [] + rescue NameError + # + # Do nothing .. When generating manpages in the build process we don't need + # to have Protobuf available. + # + update = nil + end message = nil verbose = 0 help = false @@ -242,18 +254,22 @@ begin when '-V' version = true when '-p' + error "Cannot send update -- not all libraries are available" if update.nil? update.replace = true when '-i' + error "Cannot send update -- not all libraries are available" if update.nil? error "Cannot specify the same ID twice in one update -- ID #{arg}" if update.alert.any?{|a| a.id == arg} message = Mauve::Proto::Alert.new message.id = arg update.alert << message when '-o' + error "Cannot send update -- not all libraries are available" if update.nil? error "Can only specify one source" if update.source update.source = arg when '-v' verbose += 1 else + error "Cannot send update -- not all libraries are available" if update.nil? error "Must specify --id before message" unless message case opt when '-s' then message.summary = arg @@ -281,7 +297,7 @@ begin break if line.empty? if help and !found_synopsis - found_synopsis = (line =~ /^#\s+SYNOPSIS\s*$/) if !found_synopsis + found_synopsis = (line =~ /^#\s+SYNOPSIS\s*$/) next end @@ -296,13 +312,12 @@ begin exit 0 if help or version or manual + error "Cannot send update -- not all libraries are available" if update.nil? error "No alerts specified" unless !update.alert.empty? || update.replace update.transmission_id = rand(2**63) Mauve::Sender.new(ARGV).send(update, verbose) -rescue Protobuf::NotInitializedError => bad - error "Alert not initialized fully -- you must supply an ID" rescue ArgumentError => ae error ae.message diff --git a/bin/mauveserver b/bin/mauveserver index 24eb168..921e6b3 100755 --- a/bin/mauveserver +++ b/bin/mauveserver @@ -30,12 +30,6 @@ def error(msg) exit 1 end -begin - eval "Proc.new { |a,&b| }" -rescue SyntaxError => no_blocks_with_procs - error "mauveserver must have Ruby 1.8.7 or later" -end - help = ARGV.any?{|a| a =~ /-(h|-help)/} version = ARGV.any?{|a| a =~ /-(V|-version)/} manual = ARGV.any?{|a| a =~ /-(m|-manual)/} @@ -71,6 +65,12 @@ puts "#{$0}: version "+Mauve::VERSION if version exit 0 if help or version or manual +begin + eval "Proc.new { |a,&b| }" +rescue SyntaxError => no_blocks_with_procs + error "mauveserver must have Ruby 1.8.7 or later." +end + configuration_file = ARGV.shift 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) |