#!/usr/bin/env ruby require 'fcrepo_wrapper' require 'optparse' options = {} subtext = < OptionParser.new do |opts| opts.banner = "Usage: clean" end, } begin args.order! command = ARGV.shift if command raise "Bad subcommand: #{command}" unless subcommands[command] subcommands[command].order! end args.parse! rescue => error $stderr.puts "ERROR: #{error}\n" $stderr.puts "#{args.help}\n" exit 1 end instance = FcrepoWrapper.default_instance(options) if command == 'clean' $stderr.puts "cleaning #{instance.instance_dir}..." instance.clean! exit 0 end $stderr.print "Starting Fedora #{instance.version} on port #{instance.port} ... " instance.wrap do |conn| $stderr.puts "http://#{instance.host}:#{instance.port}/" begin while conn.status sleep 1 end rescue Interrupt Signal.trap("SIGTERM") { "IGNORE" } Signal.trap("SIGINT") { "IGNORE" } $stderr.puts "Fedora is shutting down." end end