prosodyctl
changeset 12269 47d5233a1fc7
parent 12268 ba712f7559dc
child 12270 24b0c4c4e28a
equal deleted inserted replaced
12268:ba712f7559dc 12269:47d5233a1fc7
    78 
    78 
    79 function commands.install(arg)
    79 function commands.install(arg)
    80 	local opts = parse_args(arg, only_help);
    80 	local opts = parse_args(arg, only_help);
    81 	if opts.help or not arg[1] then
    81 	if opts.help or not arg[1] then
    82 		show_usage([[install]], [[Installs a prosody/luarocks plugin]]);
    82 		show_usage([[install]], [[Installs a prosody/luarocks plugin]]);
    83 		return 1;
    83 		return opts.help and 0 or 1;
    84 	end
    84 	end
    85 	-- TODO finalize config option name
    85 	-- TODO finalize config option name
    86 	local server = configmanager.get("*", "plugin_server");
    86 	local server = configmanager.get("*", "plugin_server");
    87 	if not server then
    87 	if not server then
    88 		show_warning("There is no 'plugin_server' option in the configuration file");
    88 		show_warning("There is no 'plugin_server' option in the configuration file");
   100 
   100 
   101 function commands.remove(arg)
   101 function commands.remove(arg)
   102 	local opts = parse_args(arg, only_help);
   102 	local opts = parse_args(arg, only_help);
   103 	if opts.help or not arg[1] then
   103 	if opts.help or not arg[1] then
   104 		show_usage([[remove]], [[Removes a module installed in the working directory's plugins folder]]);
   104 		show_usage([[remove]], [[Removes a module installed in the working directory's plugins folder]]);
   105 		return 1;
   105 		return opts.help and 0 or 1;
   106 	end
   106 	end
   107 	show_message("Removing %s from %s", arg[1], prosody.paths.installer);
   107 	show_message("Removing %s from %s", arg[1], prosody.paths.installer);
   108 	local ret = call_luarocks("remove", arg[1]);
   108 	local ret = call_luarocks("remove", arg[1]);
   109 	return ret;
   109 	return ret;
   110 end
   110 end
   111 
   111 
   112 function commands.list(arg)
   112 function commands.list(arg)
   113 	local opts = parse_args(arg, only_help);
   113 	local opts = parse_args(arg, only_help);
   114 	if opts.help then
   114 	if opts.help then
   115 		show_usage([[list]], [[Shows installed rocks]]);
   115 		show_usage([[list]], [[Shows installed rocks]]);
   116 		return 1;
   116 		return 0;
   117 	end
   117 	end
   118 	local ret = call_luarocks("list", arg[1]);
   118 	local ret = call_luarocks("list", arg[1]);
   119 	return ret;
   119 	return ret;
   120 end
   120 end
   121 
   121 
   122 function commands.adduser(arg)
   122 function commands.adduser(arg)
   123 	local opts = parse_args(arg, only_help);
   123 	local opts = parse_args(arg, only_help);
   124 	if opts.help or not arg[1] then
   124 	if opts.help or not arg[1] then
   125 		show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);
   125 		show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);
   126 		return 1;
   126 		return opts.help and 0 or 1;
   127 	end
   127 	end
   128 	local user, host = jid_split(arg[1]);
   128 	local user, host = jid_split(arg[1]);
   129 	if not user and host then
   129 	if not user and host then
   130 		show_message [[Failed to understand JID, please supply the JID you want to create]]
   130 		show_message [[Failed to understand JID, please supply the JID you want to create]]
   131 		show_usage [[adduser user@host]]
   131 		show_usage [[adduser user@host]]
   161 
   161 
   162 function commands.passwd(arg)
   162 function commands.passwd(arg)
   163 	local opts = parse_args(arg, only_help);
   163 	local opts = parse_args(arg, only_help);
   164 	if opts.help or not arg[1] then
   164 	if opts.help or not arg[1] then
   165 		show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]);
   165 		show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]);
   166 		return 1;
   166 		return opts.help and 0 or 1;
   167 	end
   167 	end
   168 	local user, host = jid_split(arg[1]);
   168 	local user, host = jid_split(arg[1]);
   169 	if not user and host then
   169 	if not user and host then
   170 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
   170 		show_message [[Failed to understand JID, please supply the JID you want to set the password for]]
   171 		show_usage [[passwd user@host]]
   171 		show_usage [[passwd user@host]]
   201 
   201 
   202 function commands.deluser(arg)
   202 function commands.deluser(arg)
   203 	local opts = parse_args(arg, only_help);
   203 	local opts = parse_args(arg, only_help);
   204 	if opts.help or not arg[1] then
   204 	if opts.help or not arg[1] then
   205 		show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]);
   205 		show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]);
   206 		return 1;
   206 		return opts.help and 0 or 1;
   207 	end
   207 	end
   208 	local user, host = jid_split(arg[1]);
   208 	local user, host = jid_split(arg[1]);
   209 	if not user and host then
   209 	if not user and host then
   210 		show_message [[Failed to understand JID, please supply the JID to the user account you want to delete]]
   210 		show_message [[Failed to understand JID, please supply the JID to the user account you want to delete]]
   211 		show_usage [[deluser user@host]]
   211 		show_usage [[deluser user@host]]
   260 
   260 
   261 function commands.start(arg)
   261 function commands.start(arg)
   262 	local opts = parse_args(arg, only_help);
   262 	local opts = parse_args(arg, only_help);
   263 	if opts.help then
   263 	if opts.help then
   264 		show_usage([[start]], [[Start Prosody]]);
   264 		show_usage([[start]], [[Start Prosody]]);
   265 		return 1;
   265 		return 0;
   266 	end
   266 	end
   267 	service_command_warning("start");
   267 	service_command_warning("start");
   268 	local ok, ret = prosodyctl.isrunning();
   268 	local ok, ret = prosodyctl.isrunning();
   269 	if not ok then
   269 	if not ok then
   270 		show_message(error_messages[ret]);
   270 		show_message(error_messages[ret]);
   325 
   325 
   326 function commands.status(arg)
   326 function commands.status(arg)
   327 	local opts = parse_args(arg, only_help);
   327 	local opts = parse_args(arg, only_help);
   328 	if opts.help then
   328 	if opts.help then
   329 		show_usage([[status]], [[Reports the running status of Prosody]]);
   329 		show_usage([[status]], [[Reports the running status of Prosody]]);
   330 		return 1;
   330 		return 0;
   331 	end
   331 	end
   332 
   332 
   333 	local ok, ret = prosodyctl.isrunning();
   333 	local ok, ret = prosodyctl.isrunning();
   334 	if not ok then
   334 	if not ok then
   335 		show_message(error_messages[ret]);
   335 		show_message(error_messages[ret]);
   360 
   360 
   361 function commands.stop(arg)
   361 function commands.stop(arg)
   362 	local opts = parse_args(arg, only_help);
   362 	local opts = parse_args(arg, only_help);
   363 	if opts.help then
   363 	if opts.help then
   364 		show_usage([[stop]], [[Stop a running Prosody server]]);
   364 		show_usage([[stop]], [[Stop a running Prosody server]]);
   365 		return 1;
   365 		return 0;
   366 	end
   366 	end
   367 
   367 
   368 	service_command_warning("stop");
   368 	service_command_warning("stop");
   369 
   369 
   370 	if not prosodyctl.isrunning() then
   370 	if not prosodyctl.isrunning() then
   411 
   411 
   412 function commands.about(arg)
   412 function commands.about(arg)
   413 	local opts = parse_args(arg, only_help);
   413 	local opts = parse_args(arg, only_help);
   414 	if opts.help then
   414 	if opts.help then
   415 		show_usage([[about]], [[Show information about this Prosody installation]]);
   415 		show_usage([[about]], [[Show information about this Prosody installation]]);
   416 		return 1;
   416 		return 0;
   417 	end
   417 	end
   418 
   418 
   419 	local pwd = ".";
   419 	local pwd = ".";
   420 	local sorted_pairs = require "util.iterators".sorted_pairs;
   420 	local sorted_pairs = require "util.iterators".sorted_pairs;
   421 	local hg = require"util.mercurial";
   421 	local hg = require"util.mercurial";
   533 
   533 
   534 function commands.reload(arg)
   534 function commands.reload(arg)
   535 	local opts = parse_args(arg, only_help);
   535 	local opts = parse_args(arg, only_help);
   536 	if opts.help then
   536 	if opts.help then
   537 		show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]);
   537 		show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]);
   538 		return 1;
   538 		return 0;
   539 	end
   539 	end
   540 
   540 
   541 	service_command_warning("reload");
   541 	service_command_warning("reload");
   542 
   542 
   543 	if not prosodyctl.isrunning() then
   543 	if not prosodyctl.isrunning() then