aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-04-19 09:37:53 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-04-19 09:37:53 +0100
commit326bbd320dbabc075fd7e59e55a715c7d4e9d6b9 (patch)
treeaa637e7287aa7088c31cb0b320241214059a6a7f /bin
parent89a67770e66d11740948e90a41db6cee0482cf8e (diff)
* added sane init script for server
* mauvesend now handles options better * jabber client has stub message receivng method
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mauveclient25
-rwxr-xr-xbin/mauveserver37
2 files changed, 23 insertions, 39 deletions
diff --git a/bin/mauveclient b/bin/mauveclient
index d513926..1c90741 100755
--- a/bin/mauveclient
+++ b/bin/mauveclient
@@ -101,18 +101,24 @@ message = nil
verbose = 0
help = false
-GetoptLong.new(
- ['-h', '--help', GetoptLong::NO_ARGUMENT],
- ['-o', '--source', GetoptLong::REQUIRED_ARGUMENT],
+opts = GetoptLong.new(
+ ['-h', '--help', GetoptLong::NO_ARGUMENT],
+ ['-o', '--source', GetoptLong::OPTIONAL_ARGUMENT],
['-p', '--replace', GetoptLong::NO_ARGUMENT],
- ['-i', '--id', GetoptLong::REQUIRED_ARGUMENT],
- ['-s', '--summary', GetoptLong::REQUIRED_ARGUMENT],
- ['-u', '--subject', GetoptLong::REQUIRED_ARGUMENT],
- ['-c', '--clear', GetoptLong::REQUIRED_ARGUMENT],
- ['-r', '--raise', GetoptLong::REQUIRED_ARGUMENT],
- ['-d', '--detail', GetoptLong::REQUIRED_ARGUMENT],
+ ['-i', '--id', GetoptLong::OPTIONAL_ARGUMENT],
+ ['-s', '--summary', GetoptLong::OPTIONAL_ARGUMENT],
+ ['-u', '--subject', GetoptLong::OPTIONAL_ARGUMENT],
+ ['-c', '--clear', GetoptLong::OPTIONAL_ARGUMENT],
+ ['-r', '--raise', GetoptLong::OPTIONAL_ARGUMENT],
+ ['-d', '--detail', GetoptLong::OPTIONAL_ARGUMENT],
['-v', '--verbose', GetoptLong::NO_ARGUMENT]
).each do |opt,arg|
+
+ #
+ # Can catch empty arguments better if we set the GetoptLong things to
+ # "optional" rather than "required" and catch the empty arg here.
+ error "#{opt} cannot be empty" if arg.empty? and not %w(-h -p -v).include?(opt)
+
case opt
when '-h'
help = true
@@ -141,7 +147,6 @@ GetoptLong.new(
end
end
-
# CAUTION! Kwality kode.
#
if help
diff --git a/bin/mauveserver b/bin/mauveserver
index c576c85..57a2299 100755
--- a/bin/mauveserver
+++ b/bin/mauveserver
@@ -12,26 +12,18 @@ require 'mauve/configuration'
include Mauve
configuration_file = ARGV[0]
-if configuration_file.nil?
- %w(/etc/mauvealert/mauveserver.conf mauveserver.conf).each do |configuration_file|
- break if File.exists?(configuration_file)
- end
-end
-unless File.exists?(configuration_file)
- if ARGV[0]
- STDERR.print "Configuration file #{configuration_file} not found"
- else
- STDERR.print "Syntax: #{$0} <configuration filename>\n"
- end
- exit 1
+configuration_file = [".", "/etc/mauvealert/"].find{|d| File.file?(File.join(d,"mauveserver.conf")) } 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
end
Configuration.current = ConfigurationBuilder.load(configuration_file)
-class RestartSignalReceived < Exception; end
-class TerminateSignalReceived < Exception; end
-
%w(HUP).each do |sig|
trap("HUP") do
# this blows up if you do it twice in quick succession, but don't really
@@ -54,18 +46,5 @@ end
end
end
-#begin
- Mauve::Server.instance.run
-#rescue SystemExit
- # Woo!
-# exit 0
-#rescue Exception => ex
-# [ex.class.to_s, ex.to_s, ex.backtrace.join("\n")].each do |s|
-# Configuration.current.logger.fatal s
-# warn s
-# end
-#
-# exit 1
-#end
-#
+Mauve::Server.instance.run