| Path: | ./instiki |
| Last Update: | Fri Jan 07 10:19:38 GMT+2:00 2005 |
#!/usr/local/bin/ruby
if RUBY_VERSION < "1.8.1"
puts "Instiki requires Ruby 1.8.1+" exit
end
require ‘optparse’ require ‘fileutils’
cdir = File.expand_path(File.dirname(FILE)) %w( /libraries/ /app/models /app/controllers ).each { |dir| $:.unshift(cdir + dir) } %w( web_controller_server action_controller_servlet wiki_service wiki ).each { |lib| require lib }
fork_available = true begin
exit unless fork
rescue NotImplementedError
fork_available = false
end
begin
pdflatex_available = system "pdflatex -version"
rescue Errno::ENOENT
pdflatex_available = false
end
OPTIONS = {
:server_type => fork_available ? Daemon : SimpleServer,
:port => 2500,
:storage => "#{File.expand_path(FileUtils.pwd)}/storage",
:pdflatex => pdflatex_available
}
ARGV.options do |opts|
script_name = File.basename($0)
opts.banner = "Usage: ruby #{script_name} [options]"
opts.separator ""
opts.on("-p", "--port=port", Integer,
"Runs Instiki on the specified port.",
"Default: 2500") { |OPTIONS[:port]| }
opts.on("-s", "--simple", "--simple-server",
"Forces Instiki not to run as a Daemon if fork is available."
) { OPTIONS[:server_type] = SimpleServer }
opts.on("-t", "--storage=storage", String,
"Makes Instiki use the specified directory for storage.",
"Default: ./storage/[port]") { |OPTIONS[:storage]| }
opts.separator ""
opts.on("-h", "--help",
"Show this help message.") { puts opts; exit }
opts.parse!
end
Socket.do_not_reverse_lookup = true
storage_dir = OPTIONS[:storage] + "/" + OPTIONS[:port].to_s FileUtils.mkdir_p(storage_dir) WikiService.storage_path = storage_dir
WikiController.template_root = "#{cdir}/app/views/"
WebControllerServer.new(OPTIONS[:port], OPTIONS[:server_type], "#{cdir}/app/controllers/")