Merge 0.9->trunk
[prosody.git] / tools / ejabberd2prosody.lua
index 545bd9226f790eccd2689ab09a272a78b065c8e6..0a6736d782b11e52389a25cc4fd26dea21ef3301 100755 (executable)
@@ -2,7 +2,7 @@
 -- Prosody IM
 -- Copyright (C) 2008-2010 Matthew Wild
 -- Copyright (C) 2008-2010 Waqas Hussain
--- 
+--
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
 --
 
 package.path = package.path ..";../?.lua";
 
-if arg[0]:match("^./") then
-       package.path = package.path .. ";"..arg[0]:gsub("/ejabberd2prosody.lua$", "/?.lua");
+local my_name = arg[0];
+if my_name:match("[/\\]") then
+       package.path = package.path..";"..my_name:gsub("[^/\\]+$", "../?.lua");
+       package.path = package.path..";"..my_name:gsub("[^/\\]+$", "?.lua");
+       package.cpath = package.cpath..";"..my_name:gsub("[^/\\]+$", "../?.so");
 end
 
-require "erlparse";
+local erlparse = require "erlparse";
 
 prosody = {};
 
+package.loaded["util.logger"] = {init = function() return function() end; end}
 local serialize = require "util.serialization".serialize;
 local st = require "util.stanza";
-package.loaded["util.logger"] = {init = function() return function() end; end}
 local dm = require "util.datamanager"
 dm.set_data_path("data");
 
@@ -229,10 +232,10 @@ local help = "/? -? ? /h -h /help -help --help";
 if not arg or help:find(arg, 1, true) then
        print([[ejabberd db dump importer for Prosody
 
-  Usage: ejabberd2prosody.lua filename.txt
+  Usage: ]]..my_name..[[ filename.txt
 
 The file can be generated from ejabberd using:
-  sudo ./bin/ejabberdctl dump filename.txt
+  sudo ejabberdctl dump filename.txt
 
 Note: The path of ejabberdctl depends on your ejabberd installation, and ejabberd needs to be running for ejabberdctl to work.]]);
        os.exit(1);