8 -- |
8 -- |
9 |
9 |
10 -- prosodyctl - command-line controller for Prosody XMPP server |
10 -- prosodyctl - command-line controller for Prosody XMPP server |
11 |
11 |
12 -- Will be modified by configure script if run -- |
12 -- Will be modified by configure script if run -- |
13 |
|
14 CFG_SOURCEDIR=CFG_SOURCEDIR or os.getenv("PROSODY_SRCDIR"); |
13 CFG_SOURCEDIR=CFG_SOURCEDIR or os.getenv("PROSODY_SRCDIR"); |
15 CFG_CONFIGDIR=CFG_CONFIGDIR or os.getenv("PROSODY_CFGDIR"); |
14 CFG_CONFIGDIR=CFG_CONFIGDIR or os.getenv("PROSODY_CFGDIR"); |
16 CFG_PLUGINDIR=CFG_PLUGINDIR or os.getenv("PROSODY_PLUGINDIR"); |
15 CFG_PLUGINDIR=CFG_PLUGINDIR or os.getenv("PROSODY_PLUGINDIR"); |
17 CFG_DATADIR=CFG_DATADIR or os.getenv("PROSODY_DATADIR"); |
16 CFG_DATADIR=CFG_DATADIR or os.getenv("PROSODY_DATADIR"); |
18 |
17 |
75 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; |
74 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; |
76 local show_usage = prosodyctl.show_usage; |
75 local show_usage = prosodyctl.show_usage; |
77 local show_yesno = prosodyctl.show_yesno; |
76 local show_yesno = prosodyctl.show_yesno; |
78 local show_prompt = prosodyctl.show_prompt; |
77 local show_prompt = prosodyctl.show_prompt; |
79 local read_password = prosodyctl.read_password; |
78 local read_password = prosodyctl.read_password; |
|
79 local call_luarocks = prosodyctl.call_luarocks; |
80 |
80 |
81 local jid_split = require "util.jid".prepped_split; |
81 local jid_split = require "util.jid".prepped_split; |
82 |
82 |
83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; |
83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; |
84 ----------------------- |
84 ----------------------- |
85 local commands = {}; |
85 local commands = {}; |
86 local command = table.remove(arg, 1); |
86 local command = table.remove(arg, 1); |
|
87 |
|
88 function commands.install(arg) |
|
89 if arg[1] == "--help" then |
|
90 show_usage([[install]], [[Installs a prosody/luarocks plugin]]); |
|
91 return 1; |
|
92 end |
|
93 call_luarocks(arg[1], "install") |
|
94 end |
|
95 |
|
96 function commands.remove(arg) |
|
97 if arg[1] == "--help" then |
|
98 show_usage([[remove]], [[Removes a module installed in the working directory's plugins folder]]); |
|
99 return 1; |
|
100 end |
|
101 call_luarocks(arg[1], "remove") |
|
102 end |
|
103 |
|
104 function commands.list(arg) |
|
105 if arg[1] == "--help" then |
|
106 show_usage([[list]], [[Shows installed rocks]]); |
|
107 return 1; |
|
108 end |
|
109 call_luarocks(arg[1], "list") |
|
110 end |
87 |
111 |
88 function commands.adduser(arg) |
112 function commands.adduser(arg) |
89 if not arg[1] or arg[1] == "--help" then |
113 if not arg[1] or arg[1] == "--help" then |
90 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); |
114 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); |
91 return 1; |
115 return 1; |
1356 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
1380 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
1357 print(""); |
1381 print(""); |
1358 print("Where COMMAND may be one of:\n"); |
1382 print("Where COMMAND may be one of:\n"); |
1359 |
1383 |
1360 local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; |
1384 local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; |
1361 local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart", "reload", "about" }; |
1385 local commands_order = { "install", "remove", "list", "adduser", "passwd", "deluser", "start", "stop", "restart", "reload", |
|
1386 "about" }; |
1362 |
1387 |
1363 local done = {}; |
1388 local done = {}; |
1364 |
1389 |
1365 for _, command_name in ipairs(commands_order) do |
1390 for _, command_name in ipairs(commands_order) do |
1366 local command_func = commands[command_name]; |
1391 local command_func = commands[command_name]; |