Software /
code /
prosody
Annotate
tools/migration/prosody-migrator.lua @ 4229:f15b4e9ba688
tools/migration: Rename main.lua -> prosody-migrator.lua and update the Makefile
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 21 Mar 2011 19:39:04 +0000 |
parent | 4216:tools/migration/main.lua@ff80a8471e86 |
child | 4235:899ffc1674b5 |
rev | line source |
---|---|
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
1 #!/usr/bin/env lua |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
2 |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
3 CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR"); |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
4 CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
5 |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
6 local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua"; |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
7 |
4213
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
8 -- Command-line parsing |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
9 local options = {}; |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
10 local handled_opts = 0; |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
11 for i = 1, #arg do |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
12 if arg[i]:sub(1,2) == "--" then |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
13 local opt, val = arg[i]:match("([%w-]+)=?(.*)"); |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
14 if opt then |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
15 options[(opt:sub(3):gsub("%-", "_"))] = #val > 0 and val or true; |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
16 end |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
17 handled_opts = i; |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
18 else |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
19 break; |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
20 end |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
21 end |
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
22 table.remove(arg, handled_opts); |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
23 |
4213
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
24 -- Load config file |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
25 local function loadfilein(file, env) |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
26 if loadin then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
27 return loadin(env, io.open(file):read("*a")); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
28 else |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
29 local chunk, err = loadfile(file); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
30 if chunk then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
31 setfenv(chunk, env); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
32 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
33 return chunk, err; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
34 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
35 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
36 |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
37 local config_file = options.config or default_config; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
38 local from_store = arg[1] or "input"; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
39 local to_store = arg[2] or "output"; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
40 |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
41 config = {}; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
42 local config_env = setmetatable({}, { __index = function(t, k) return function(tbl) config[k] = tbl; end; end }); |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
43 local config_chunk, err = loadfilein(config_file, config_env); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
44 if not config_chunk then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
45 print("There was an error loading the config file, check the file exists"); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
46 print("and that the syntax is correct:"); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
47 print("", err); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
48 os.exit(1); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
49 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
50 |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
51 config_chunk(); |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
52 |
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
53 if CFG_SOURCEDIR then |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
54 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
55 package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
56 elseif not package.loaded["util.json"] then |
4213
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
57 package.path = "../../?.lua;"..package.path |
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
58 package.cpath = "../../?.so;"..package.cpath |
4213
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
59 end |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
60 |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
61 local have_err; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
62 if #arg > 0 and #arg ~= 2 then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
63 have_err = true; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
64 print("Error: Incorrect number of parameters supplied."); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
65 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
66 if not config[from_store] then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
67 have_err = true; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
68 print("Error: Input store '"..from_store.."' not found in the config file."); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
69 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
70 if not config[to_store] then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
71 have_err = true; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
72 print("Error: Output store '"..to_store.."' not found in the config file."); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
73 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
74 if not config[from_store].type then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
75 have_err = true; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
76 print("Error: Input store type not specified in the config file"); |
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
77 elseif not pcall(require, "migrator."..config[from_store].type) then |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
78 have_err = true; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
79 print("Error: Unrecognised store type for '"..from_store.."': "..config[from_store].type); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
80 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
81 if not config[to_store].type then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
82 have_err = true; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
83 print("Error: Output store type not specified in the config file"); |
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
84 elseif not pcall(require, "migrator."..config[to_store].type) then |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
85 have_err = true; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
86 print("Error: Unrecognised store type for '"..to_store.."': "..config[to_store].type); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
87 end |
4213
8f169a92b4ba
tools/migration/main.lua: Add command-line parsing, including --config=CONFIG_FILE, and the ability to specify to/from stores to migrate
Matthew Wild <mwild1@gmail.com>
parents:
4197
diff
changeset
|
88 |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
89 if have_err then |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
90 print(""); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
91 print("Usage: "..arg[0].." FROM_STORE TO_STORE"); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
92 print("If no stores are specified, 'input' and 'output' are used."); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
93 print(""); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
94 print("The available stores in your migrator config are:"); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
95 print(""); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
96 for store in pairs(config) do |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
97 print("", store); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
98 end |
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
99 print(""); |
4214
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
100 os.exit(1); |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
101 end |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
102 |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
103 local itype = config[from_store].type; |
1674cd17557c
tools/migration/*.lua: Rename config to migrator.cfg.lua, add error handling for config and command-line parameters
Matthew Wild <mwild1@gmail.com>
parents:
4213
diff
changeset
|
104 local otype = config[to_store].type; |
4216
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
105 local reader = require("migrator."..itype).reader(config[from_store]); |
ff80a8471e86
tools/migration/*: Numerous changes and restructuring, and the addition of a Makefile
Matthew Wild <mwild1@gmail.com>
parents:
4214
diff
changeset
|
106 local writer = require("migrator."..otype).writer(config[to_store]); |
4197
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
107 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
108 local json = require "util.json"; |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
109 |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
110 for x in reader do |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
111 --print(json.encode(x)) |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
112 writer(x); |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
113 end |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
114 writer(nil); -- close |
bef732980436
tools/migration/*.lua: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
4193
diff
changeset
|
115 |