Comparison

tools/ejabberdsql2prosody.lua @ 1594:6e639a34e503

ejabberdsql2prosody: Added a second required command line parameter: hostname
author Waqas Hussain <waqas20@gmail.com>
date Sat, 25 Jul 2009 23:40:33 +0500
parent 1593:4e44aa858a4c
child 1595:9551055b5344
comparison
equal deleted inserted replaced
1593:4e44aa858a4c 1594:6e639a34e503
136 return readFile(filename); 136 return readFile(filename);
137 137
138 ------ 138 ------
139 end 139 end
140 140
141 local arg = ...; 141 local arg, host = ...;
142 local help = "/? -? ? /h -h /help -help --help"; 142 local help = "/? -? ? /h -h /help -help --help";
143 if not arg or help:find(arg, 1, true) then 143 if not(arg and host) or help:find(arg, 1, true) then
144 print([[ejabberd SQL DB dump importer for Prosody 144 print([[ejabberd SQL DB dump importer for Prosody
145 145
146 Usage: ejabberdsql2prosody.lua filename.txt 146 Usage: ejabberdsql2prosody.lua filename.txt hostname
147 147
148 The file can be generated using mysqldump: 148 The file can be generated using mysqldump:
149 mysqldump db_name > filename.txt 149 mysqldump db_name > filename.txt]]);
150 ]]);
151 os.exit(1); 150 os.exit(1);
152 end 151 end
153 local map = { 152 local map = {
154 ["last"] = {"username", "seconds", "state"}; 153 ["last"] = {"username", "seconds", "state"};
155 ["privacy_default_list"] = {"username", "name"}; 154 ["privacy_default_list"] = {"username", "name"};
176 end 175 end
177 end 176 end
178 end 177 end
179 end 178 end
180 179
181 local host = "ayena.de";
182
183 for i, row in ipairs(t["users"] or NULL) do 180 for i, row in ipairs(t["users"] or NULL) do
184 local node, password = row.username, row.password; 181 local node, password = row.username, row.password;
185 local ret, err = dm.store(node, host, "accounts", {password = password}); 182 local ret, err = dm.store(node, host, "accounts", {password = password});
186 --print("["..(err or "success").."] accounts: "..node.."@"..host.." = "..password); 183 print("["..(err or "success").."] accounts: "..node.."@"..host.." = "..password);
187 end 184 end
188 for i, row in ipairs(t["private_storage"] or NULL) do 185 for i, row in ipairs(t["private_storage"] or NULL) do
189 --local node, password = row.username, row.password; 186 --local node, password = row.username, row.password;
190 --local ret, err = dm.store(node, host, "accounts", {password = password}); 187 --local ret, err = dm.store(node, host, "accounts", {password = password});
191 --print("["..(err or "success").."] accounts: "..node.."@"..host.." = "..password); 188 --print("["..(err or "success").."] accounts: "..node.."@"..host.." = "..password);
192 end 189 end
193
194
195
196 print(serialize(t));