120 ["not-running"] = "Prosody is not running"; |
120 ["not-running"] = "Prosody is not running"; |
121 }, { __index = function (t,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end }); |
121 }, { __index = function (t,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end }); |
122 |
122 |
123 hosts = prosody.hosts; |
123 hosts = prosody.hosts; |
124 |
124 |
|
125 local function make_host(hostname) |
|
126 return { events = prosody.events, users = require "core.usermanager".new_default_provider(hostname) }; |
|
127 end |
|
128 |
125 for hostname, config in pairs(config.getconfig()) do |
129 for hostname, config in pairs(config.getconfig()) do |
126 hosts[hostname] = { events = prosody.events }; |
130 hosts[hostname] = make_host(hostname); |
127 end |
131 end |
128 |
132 |
129 require "core.modulemanager" |
133 require "core.modulemanager" |
130 |
134 |
131 require "util.prosodyctl" |
135 require "util.prosodyctl" |
233 if not host then |
237 if not host then |
234 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
238 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
235 return 1; |
239 return 1; |
236 end |
240 end |
237 |
241 |
238 if prosodyctl.user_exists{ user = user, host = host } then |
|
239 show_message [[That user already exists]]; |
|
240 return 1; |
|
241 end |
|
242 |
|
243 if not hosts[host] then |
242 if not hosts[host] then |
244 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) |
243 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) |
245 show_warning("The user will not be able to log in until this is changed."); |
244 show_warning("The user will not be able to log in until this is changed."); |
|
245 hosts[host] = make_host(host); |
|
246 elseif config.get(host, "core", "authentication") |
|
247 and config.get(host, "core", "authentication") ~= "default" then |
|
248 show_warning("The host '%s' is configured to use the '%s' authentication provider", host, |
|
249 config.get(host, "core", "authentication")); |
|
250 show_warning("prosodyctl currently only supports the default provider, sorry :("); |
|
251 return 1; |
|
252 end |
|
253 |
|
254 if prosodyctl.user_exists{ user = user, host = host } then |
|
255 show_message [[That user already exists]]; |
|
256 return 1; |
246 end |
257 end |
247 |
258 |
248 local password = read_password(); |
259 local password = read_password(); |
249 if not password then return 1; end |
260 if not password then return 1; end |
250 |
261 |
271 if not host then |
282 if not host then |
272 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
283 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
273 return 1; |
284 return 1; |
274 end |
285 end |
275 |
286 |
|
287 if not hosts[host] then |
|
288 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) |
|
289 show_warning("The user will not be able to log in until this is changed."); |
|
290 hosts[host] = make_host(host); |
|
291 elseif config.get(host, "core", "authentication") |
|
292 and config.get(host, "core", "authentication") ~= "default" then |
|
293 show_warning("The host '%s' is configured to use the '%s' authentication provider", host, |
|
294 config.get(host, "core", "authentication")); |
|
295 show_warning("prosodyctl currently only supports the default provider, sorry :("); |
|
296 return 1; |
|
297 end |
|
298 |
276 if not prosodyctl.user_exists { user = user, host = host } then |
299 if not prosodyctl.user_exists { user = user, host = host } then |
277 show_message [[That user does not exist, use prosodyctl adduser to create a new user]] |
300 show_message [[That user does not exist, use prosodyctl adduser to create a new user]] |
278 return 1; |
301 return 1; |
279 end |
302 end |
280 |
303 |
304 if not host then |
327 if not host then |
305 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
328 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
306 return 1; |
329 return 1; |
307 end |
330 end |
308 |
331 |
|
332 if not hosts[host] then |
|
333 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) |
|
334 show_warning("The user will not be able to log in until this is changed."); |
|
335 hosts[host] = make_host(host); |
|
336 elseif config.get(host, "core", "authentication") |
|
337 and config.get(host, "core", "authentication") ~= "default" then |
|
338 show_warning("The host '%s' is configured to use the '%s' authentication provider", host, |
|
339 config.get(host, "core", "authentication")); |
|
340 show_warning("prosodyctl currently only supports the default provider, sorry :("); |
|
341 return 1; |
|
342 end |
|
343 |
309 if not prosodyctl.user_exists { user = user, host = host } then |
344 if not prosodyctl.user_exists { user = user, host = host } then |
310 show_message [[That user does not exist on this server]] |
345 show_message [[That user does not exist on this server]] |
311 return 1; |
346 return 1; |
312 end |
347 end |
313 |
348 |