prosodyctl
changeset 6324 c9730926002b
parent 6035 1b5ca55bf895
child 6325 13a43fe90d9f
equal deleted inserted replaced
6323:5926f01e5cd2 6324:c9730926002b
   266 local getchar, getpass = prosodyctl.getchar, prosodyctl.getpass;
   266 local getchar, getpass = prosodyctl.getchar, prosodyctl.getpass;
   267 local show_yesno = prosodyctl.show_yesno;
   267 local show_yesno = prosodyctl.show_yesno;
   268 local show_prompt = prosodyctl.show_prompt;
   268 local show_prompt = prosodyctl.show_prompt;
   269 local read_password = prosodyctl.read_password;
   269 local read_password = prosodyctl.read_password;
   270 
   270 
       
   271 local jid_split = require "util.jid".prepped_split;
       
   272 
   271 local prosodyctl_timeout = (config.get("*", "prosodyctl_timeout") or 5) * 2;
   273 local prosodyctl_timeout = (config.get("*", "prosodyctl_timeout") or 5) * 2;
   272 -----------------------
   274 -----------------------
   273 local commands = {};
   275 local commands = {};
   274 local command = arg[1];
   276 local command = arg[1];
   275 
   277 
   276 function commands.adduser(arg)
   278 function commands.adduser(arg)
   277 	if not arg[1] or arg[1] == "--help" then
   279 	if not arg[1] or arg[1] == "--help" then
   278 		show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);
   280 		show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);
   279 		return 1;
   281 		return 1;
   280 	end
   282 	end
   281 	local user, host = arg[1]:match("([^@]+)@(.+)");
   283 	local user, host = jid_split(arg[1]);
   282 	if not user and host then
   284 	if not user and host then
   283 		show_message [[Failed to understand JID, please supply the JID you want to create]]
   285 		show_message [[Failed to understand JID, please supply the JID you want to create]]
   284 		show_usage [[adduser user@host]]
   286 		show_usage [[adduser user@host]]
   285 		return 1;
   287 		return 1;
   286 	end
   288 	end
   315 function commands.passwd(arg)
   317 function commands.passwd(arg)
   316 	if not arg[1] or arg[1] == "--help" then
   318 	if not arg[1] or arg[1] == "--help" then
   317 		show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]);
   319 		show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]);
   318 		return 1;
   320 		return 1;
   319 	end
   321 	end
   320 	local user, host = arg[1]:match("([^@]+)@(.+)");
   322 	local user, host = jid_split(arg[1])
   321 	if not user and host then
   323 	if not user and host then
   322 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
   324 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
   323 		show_usage [[passwd user@host]]
   325 		show_usage [[passwd user@host]]
   324 		return 1;
   326 		return 1;
   325 	end
   327 	end
   354 function commands.deluser(arg)
   356 function commands.deluser(arg)
   355 	if not arg[1] or arg[1] == "--help" then
   357 	if not arg[1] or arg[1] == "--help" then
   356 		show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]);
   358 		show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]);
   357 		return 1;
   359 		return 1;
   358 	end
   360 	end
   359 	local user, host = arg[1]:match("([^@]+)@(.+)");
   361 	local user, host = jid_split(arg[1]);
   360 	if not user and host then
   362 	if not user and host then
   361 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
   363 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
   362 		show_usage [[passwd user@host]]
   364 		show_usage [[passwd user@host]]
   363 		return 1;
   365 		return 1;
   364 	end
   366 	end