Sha256: 00d4b16dbb8c956ebd82ecfeb54d15c04b6b70ab670b8ed5646d259e6f8ce7e3
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
#!/usr/bin/env ruby require 'rack' require 'optparse' require 'web-facter' require 'parseconfig' options = {} optparse = OptionParser.new do |opts| opts.banner = 'Usage: web-facter [options] ...' opts.separator '' opts.separator 'Configuration options:' options[:daemonize] = true opts.on( '--no-daemonize', "Don't daemonize the web server process") do |_| options[:daemonize] = false end options[:port] = 9294 opts.on( '-p', '--port PORT', 'The port to run web-facter on') do |port| options[:port] = port end options[:config] = false opts.on( '-c', '--config FILE', 'The file to load with configuration options') do |file| options[:config] = file end opts.on_tail('-h', '--help', 'Display this screen') do puts opts exit end end begin optparse.parse! application = WebFacter::App.new daemonize = options[:daemonize] port = options[:port] if options[:config] conf = ParseConfig.new(options[:config]) if conf.get_value('password') application = Rack::Auth::Basic.new(application) do |username, password| username_check = conf.get_value('username') ? conf.get_value('username') == username : true password_check = conf.get_value('password') == password username_check && password_check end application.realm = 'Web Facter' end port = conf.get_value('port') ? conf.get_value('port') : port daemonize = conf.get_value('daemonize') ? conf.get_value('daemonize') == "true" : daemonize end Rack::Server.new(:app => application, :Port => port, :daemonize => daemonize).start rescue OptionParser::InvalidArgument, OptionParser::InvalidOption, OptionParser::MissingArgument puts $!.to_s puts optparse exit rescue Errno::EACCES puts $!.to_s exit end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
web-facter-0.0.3 | bin/web-facter |