diff -r 804e1c2b9a40 -r 66beb495a861 bin/ezmlm-listd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/ezmlm-listd Wed Aug 06 17:24:00 2008 +0000 @@ -0,0 +1,83 @@ +#!/usr/bin/env ruby +# +# A startup script for an instance of Ezmlm::ListDaemon. +# $Id$ +# +# Authors: +# * Michael Granger +# * Jeremiah Jordan +# + +BEGIN { + require 'pathname' + basedir = Pathname.new( __FILE__ ).dirname.parent + libdir = basedir + 'lib' + + $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s ) +} + +begin + require 'rubygems' + require 'optparse' + require 'ezmlm/listdaemon' +rescue LoadError + unless Object.const_defined?( :Gem ) + require 'rubygems' + retry + end + raise +end + + +progname = Pathname.new( $0 ).basename +opts = Ezmlm::ListDaemon.default_options + +oparser = OptionParser.new do |oparser| + oparser.accept( Pathname ) {|path| Pathname.new(path) } + + oparser.banner = "Usage: #{progname.basename} OPTIONS LISTSDIRECTORY" + oparser.separator 'Version ' + Ezmlm::VERSION + + oparser.separator '' + oparser.separator 'Options:' + oparser.on( '--bind ADDRESS', '-b', String, + "Specify the address to bind to. Defaults to '#{opts.bind_addr}'" ) do |bindaddr| + opts.bind_addr = bindaddr + end + + oparser.on( '--port PORTNUMBER', '-p', Integer, + "Specify the port to connect to. Defaults to '#{opts.bind_port}" ) do |portnumber| + opts.bind_port = portnumber + end + + + oparser.separator '' + oparser.separator 'Other Options:' + oparser.on( '--debug', '-d', FalseClass, "Turn on debugging" ) do + $DEBUG = true + $stderr.puts "Debugging enabled." + opts.debugmode = true + end + + oparser.on_tail( '--help', '-h', FalseClass, "Display help for the given command." ) do + $stderr.puts( oparser ) + exit!( 0 ) + end + + oparser.on_tail( '--version', '-V', "Print Ezmlm library version on STDOUT and quit." ) do + $stdout.puts Ezmlm::VERSION + exit!( 0 ) + end +end + + +# Parse command-line flags and display the help if there isn't exactly one argument +remaining_args = oparser.parse( ARGV ) +if remaining_args.nitems != 1 + $stderr.puts( oparser ) + exit( 64 ) # EX_USAGE +end + +listsdir = remaining_args.shift +daemon = Ezmlm::ListDaemon.new( listsdir, opts ) +daemon.start.join