aboutsummaryrefslogtreecommitdiffstats
path: root/tools/migration/main.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-02-26 00:24:23 +0000
committerMatthew Wild <mwild1@gmail.com>2011-02-26 00:24:23 +0000
commit65f5ac4f58a596f9a6813572171625095b685cee (patch)
treeaa68c7dba38183a45322f3356d08c73e8c45b599 /tools/migration/main.lua
parent8487805faf8765a24bbdc5bb4c447c3a6b6c44ba (diff)
parent2b4811c8430dcbec09c67b73e8f939b4047f1aec (diff)
downloadprosody-65f5ac4f58a596f9a6813572171625095b685cee.tar.gz
prosody-65f5ac4f58a596f9a6813572171625095b685cee.zip
Merge 0.8->trunk
Diffstat (limited to 'tools/migration/main.lua')
-rw-r--r--tools/migration/main.lua23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/migration/main.lua b/tools/migration/main.lua
index e4891966..82eeab9d 100644
--- a/tools/migration/main.lua
+++ b/tools/migration/main.lua
@@ -1,4 +1,9 @@
-local default_config = "./migrator.cfg.lua";
+#!/usr/bin/env lua
+
+CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR");
+CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR");
+
+local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua";
-- Command-line parsing
local options = {};
@@ -45,9 +50,12 @@ end
config_chunk();
-if not package.loaded["util.json"] then
+if CFG_SOURCEDIR then
+ package.path = CFG_SOURCEDIR.."/?.lua;"..package.path;
+ package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath;
+elseif not package.loaded["util.json"] then
package.path = "../../?.lua;"..package.path
- package.cpath = "../../?.dll;"..package.cpath
+ package.cpath = "../../?.so;"..package.cpath
end
local have_err;
@@ -66,14 +74,14 @@ end
if not config[from_store].type then
have_err = true;
print("Error: Input store type not specified in the config file");
-elseif not pcall(require, config[from_store].type) then
+elseif not pcall(require, "migrator."..config[from_store].type) then
have_err = true;
print("Error: Unrecognised store type for '"..from_store.."': "..config[from_store].type);
end
if not config[to_store].type then
have_err = true;
print("Error: Output store type not specified in the config file");
-elseif not pcall(require, config[to_store].type) then
+elseif not pcall(require, "migrator."..config[to_store].type) then
have_err = true;
print("Error: Unrecognised store type for '"..to_store.."': "..config[to_store].type);
end
@@ -88,13 +96,14 @@ if have_err then
for store in pairs(config) do
print("", store);
end
+ print("");
os.exit(1);
end
local itype = config[from_store].type;
local otype = config[to_store].type;
-local reader = require(itype).reader(config[from_store]);
-local writer = require(otype).writer(config[to_store]);
+local reader = require("migrator."..itype).reader(config[from_store]);
+local writer = require("migrator."..otype).writer(config[to_store]);
local json = require "util.json";