Software /
code /
prosody
Annotate
tools/ejabberd2prosody.lua @ 482:b86082df0bc0
ejabberd db dump importer for Prosody
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 29 Nov 2008 23:59:27 +0500 |
child | 484:af499a5ee32f |
rev | line source |
---|---|
482
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 require "erlparse"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 require "serialize"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 package.path = package.path ..";../?.lua"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 local st = require "util.stanza"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 package.loaded["util.logger"] = {init = function() return function() end; end} |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 local dm = require "util.datamanager" |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
9 local data_path = "data"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 dm.set_data_path(data_path); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 local _mkdir = {} |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 function mkdir(path) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
14 path = path:gsub("/", "\\"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 --print("mkdir",path); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 local x = io.popen("mkdir "..path.." 2>&1"):read("*a"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 function getpath(username, host, datastore, ext) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 ext = ext or "dat"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 if username then |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 return format("%s/%s/%s/%s.%s", data_path, encode(host), datastore, encode(username), ext); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 elseif host then |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 return format("%s/%s/%s.%s", data_path, encode(host), datastore, ext); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 else |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 return format("%s/%s.%s", data_path, datastore, ext); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
28 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
29 function mkdirs(host) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
30 if not _mkdir[host] then |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
31 local host_dir = string.format("%s/%s", data_path, encode(host)); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
32 mkdir(host_dir); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
33 mkdir(host_dir.."/accounts"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
34 mkdir(host_dir.."/vcard"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
35 mkdir(host_dir.."/roster"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
36 mkdir(host_dir.."/private"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
37 mkdir(host_dir.."/offline"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
38 _mkdir[host] = true; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
39 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
40 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
41 mkdir(data_path); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
42 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
43 function build_stanza(tuple, stanza) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
44 if tuple[1] == "xmlelement" then |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
45 local name = tuple[2]; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 local attr = {}; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 for _, a in ipairs(tuple[3]) do attr[a[1]] = a[2]; end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
48 local up; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
49 if stanza then stanza:tag(name, attr); up = true; else stanza = st.stanza(name, attr); end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
50 for _, a in ipairs(tuple[4]) do build_stanza(a, stanza); end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
51 if up then stanza:up(); else return stanza end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
52 elseif tuple[1] == "xmlcdata" then |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
53 stanza:text(tuple[2]); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
54 else |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
55 error("unknown element type: "..serialize.serialize(tuple)); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
56 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
57 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
58 function build_time(tuple) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
59 local Megaseconds,Seconds,Microseconds = unpack(tuple); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
60 return Megaseconds * 1000000 + Seconds; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
61 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
62 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
63 function vcard(node, host, stanza) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
64 mkdirs(host); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
65 local ret, err = dm.store(node, host, "vcard", st.preserialize(stanza)); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
66 print("["..(err or "success").."] vCard: "..node.."@"..host); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
67 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
68 function password(node, host, password) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
69 mkdirs(host); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
70 local ret, err = dm.store(node, host, "accounts", {password = password}); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
71 print("["..(err or "success").."] accounts: "..node.."@"..host.." = "..password); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
72 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
73 function roster(node, host, jid, item) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
74 mkdirs(host); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
75 local roster = dm.load(node, host, "roster") or {}; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
76 roster[jid] = item; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
77 local ret, err = dm.store(node, host, "roster", roster); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
78 print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
79 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
80 function private_storage(node, host, xmlns, stanza) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
81 mkdirs(host); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
82 local private = dm.load(node, host, "private") or {}; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
83 private[xmlns] = st.preserialize(stanza); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
84 local ret, err = dm.store(node, host, "private", private); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
85 print("["..(err or "success").."] private: " ..node.."@"..host.." - "..xmlns); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
86 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
87 function offline_msg(node, host, t, stanza) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
88 mkdirs(host); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
89 stanza.attr.stamp = os.date("!%Y-%m-%dT%H:%M:%SZ", t); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
90 stanza.attr.stamp_legacy = os.date("!%Y%m%dT%H:%M:%S", t); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
91 local ret, err = dm.list_append(node, host, "offline", st.preserialize(stanza)); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
92 print("["..(err or "success").."] offline: " ..node.."@"..host.." - "..os.date("!%Y-%m-%dT%H:%M:%SZ", t)); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
93 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
94 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
95 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
96 local filters = { |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
97 passwd = function(tuple) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
98 password(tuple[2][1], tuple[2][2], tuple[3]); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
99 end; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
100 vcard = function(tuple) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
101 vcard(tuple[2][1], tuple[2][2], build_stanza(tuple[3])); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
102 end; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
103 roster = function(tuple) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
104 local node = tuple[3][1]; local host = tuple[3][2]; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
105 local contact = tuple[4][1].."@"..tuple[4][2]; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
106 local name = tuple[5]; local subscription = tuple[6]; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
107 local ask = tuple[7]; local groups = tuple[8]; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
108 if type(name) ~= type("") then name = nil; end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
109 if ask == "none" then ask = nil; elseif ask == "out" then ask = "subscribe" else error(ask) end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
110 if subscription ~= "both" and subscription ~= "from" and subscription ~= "to" and subscription ~= "none" then error(subscription) end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
111 local item = {name = name, ask = ask, subscription = subscription, groups = {}}; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
112 for _, g in ipairs(groups) do item.groups[g] = true; end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
113 roster(node, host, contact, item); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
114 end; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
115 private_storage = function(tuple) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
116 private_storage(tuple[2][1], tuple[2][2], tuple[2][3], build_stanza(tuple[3])); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
117 end; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
118 offline_msg = function(tuple) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
119 offline_msg(tuple[2][1], tuple[2][2], build_time(tuple[3]), build_stanza(tuple[7])); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
120 end; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
121 config = function(tuple) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
122 if tuple[2] == "hosts" then |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
123 local output = io.output(); io.output("prosody.cfg.lua"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
124 io.write("-- Configuration imported from ejabberd --\n"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
125 io.write([[Host "*" |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
126 modules_enabled = { |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
127 "saslauth"; -- Authentication for clients and servers. Recommended if you want to log in. |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
128 "legacyauth"; -- Legacy authentication. Only used by some old clients and bots. |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
129 "roster"; -- Allow users to have a roster. Recommended ;) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
130 "register"; -- Allow users to register on this server using a client |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
131 "tls"; -- Add support for secure TLS on c2s/s2s connections |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
132 "vcard"; -- Allow users to set vCards |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
133 "private"; -- Private XML storage (for room bookmarks, etc.) |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
134 "version"; -- Replies to server version requests |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
135 "dialback"; -- s2s dialback support |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
136 "uptime"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
137 "disco"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
138 "time"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
139 "ping"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
140 --"selftests"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
141 }; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
142 ]]); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
143 for _, h in ipairs(tuple[3]) do |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
144 io.write("Host \"" .. h .. "\"\n"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
145 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
146 io.output(output); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
147 print("prosody.cfg.lua created"); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
148 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
149 end; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
150 }; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
151 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
152 local arg = ...; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
153 local help = "/? -? ? /h -h /help -help --help"; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
154 if not arg or help:find(arg, 1, true) then |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
155 print([[ejabberd db dump importer for Prosody |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
156 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
157 Usage: ejabberd2prosody.lua filename.txt |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
158 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
159 The file can be generated from ejabberd using: |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
160 sudo ./bin/ejabberdctl dump filename.txt |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
161 |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
162 Note: The path of ejabberdctl depends on your ejabberd installation, and ejabberd needs to be running for ejabberdctl to work.]]); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
163 os.exit(1); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
164 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
165 local count = 0; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
166 local t = {}; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
167 for item in erlparse.parseFile(arg) do |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
168 count = count + 1; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
169 local name = item[1]; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
170 t[name] = (t[name] or 0) + 1; |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
171 --print(count, serialize.serialize(item)); |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
172 if filters[name] then filters[name](item); end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
173 end |
b86082df0bc0
ejabberd db dump importer for Prosody
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
174 --print(serialize.serialize(t)); |