doc: more updates
[omgdav.git] / bin / omgdav-sync
blob0c811ec67394b156a8d09714a6eafb5985752e06
1 #!/usr/bin/env ruby
2 $stderr.sync = $stdout.sync = true
3 require "optparse"
4 require "sequel"
5 require "mogilefs"
6 require "omgdav/sync"
8 mfs_opts = { hosts: %w(127.0.0.1:7001), domain: "test" }
10 opts = OptionParser.new do |opts|
11 opts.banner = "Usage: omgdav-sync [options] <uri|path>"
12 opts.separator "Examples:"
13 opts.separator " omgdav-sync -t 127.0.0.1:7001 -d domain sqlite://foo.db"
15 opts.on('-t', '--trackers=host1[,host2]', '--hosts=host1[,host2]', Array,
16 'hostnames/IP addresses of trackers') do |hosts|
17 mfs_opts[:hosts] = hosts
18 end
19 opts.on('-d', '--domain=s', 'domain') do |domain|
20 mfs_opts[:domain] = domain
21 end
22 opts.parse!
23 end
25 db = ARGV.shift
26 db = Sequel.connect(db)
27 db.pragma_set(:synchronous, :off) if db.respond_to?(:pragma_set)
28 db.transaction_mode = :immediate if db.respond_to?(:transaction_mode=)
29 mogc = MogileFS::MogileFS.new(mfs_opts)
30 db.transaction do
31 OMGDAV::Sync.new(db, mogc).sync
32 end