Software /
code /
prosody
Annotate
prosodyctl @ 4806:27a99c289b90
mod_component: Allow unauthenticated components to authenticate (thanks Maranda)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 30 Apr 2012 01:20:13 +0100 |
parent | 4487:5f466a50e78b |
child | 4815:04e6115e060b |
rev | line source |
---|---|
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env lua |
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
1501
diff
changeset
|
2 -- Prosody IM |
3742
a18acd47904b
prosodyctl: Added and updated some comments and some semicolons, to match main prosody executable.
Waqas Hussain <waqas20@gmail.com>
parents:
3741
diff
changeset
|
3 -- Copyright (C) 2008-2010 Matthew Wild |
a18acd47904b
prosodyctl: Added and updated some comments and some semicolons, to match main prosody executable.
Waqas Hussain <waqas20@gmail.com>
parents:
3741
diff
changeset
|
4 -- Copyright (C) 2008-2010 Waqas Hussain |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 -- |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 -- This project is MIT/X11 licensed. Please see the |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 -- COPYING file in the source package for more information. |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 -- |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 -- prosodyctl - command-line controller for Prosody XMPP server |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 -- Will be modified by configure script if run -- |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 |
3741
f7dd583d99b4
prosodyctl: Read PROSODY_SRCDIR and PROSODY_PLUGINDIR environment variables, to match main prosody executable.
Waqas Hussain <waqas20@gmail.com>
parents:
3739
diff
changeset
|
14 CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR"); |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); |
3741
f7dd583d99b4
prosodyctl: Read PROSODY_SRCDIR and PROSODY_PLUGINDIR environment variables, to match main prosody executable.
Waqas Hussain <waqas20@gmail.com>
parents:
3739
diff
changeset
|
16 CFG_PLUGINDIR=os.getenv("PROSODY_PLUGINDIR"); |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 CFG_DATADIR=os.getenv("PROSODY_DATADIR"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 |
3742
a18acd47904b
prosodyctl: Added and updated some comments and some semicolons, to match main prosody executable.
Waqas Hussain <waqas20@gmail.com>
parents:
3741
diff
changeset
|
19 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 |
3999
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
21 local function is_relative(path) |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
22 local path_sep = package.config:sub(1,1); |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
23 return ((path_sep == "/" and path:sub(1,1) ~= "/") |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
24 or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\"))) |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
25 end |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
26 |
3742
a18acd47904b
prosodyctl: Added and updated some comments and some semicolons, to match main prosody executable.
Waqas Hussain <waqas20@gmail.com>
parents:
3741
diff
changeset
|
27 -- Tell Lua where to find our libraries |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 if CFG_SOURCEDIR then |
3999
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
29 local function filter_relative_paths(path) |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
30 if is_relative(path) then return ""; end |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
31 end |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
32 local function sanitise_paths(paths) |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
33 return (paths:gsub("[^;]+;?", filter_relative_paths):gsub(";;+", ";")); |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
34 end |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
35 package.path = sanitise_paths(CFG_SOURCEDIR.."/?.lua;"..package.path); |
58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
Matthew Wild <mwild1@gmail.com>
parents:
3998
diff
changeset
|
36 package.cpath = sanitise_paths(CFG_SOURCEDIR.."/?.so;"..package.cpath); |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 |
3742
a18acd47904b
prosodyctl: Added and updated some comments and some semicolons, to match main prosody executable.
Waqas Hussain <waqas20@gmail.com>
parents:
3741
diff
changeset
|
39 -- Substitute ~ with path to home directory in data path |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 if CFG_DATADIR then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 if os.getenv("HOME") then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 CFG_DATADIR = CFG_DATADIR:gsub("^~", os.getenv("HOME")); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 |
3013
518e3f6f9946
prosodyctl: Relocate global prosody object creation (see fff153f7f4de)
Matthew Wild <mwild1@gmail.com>
parents:
2706
diff
changeset
|
46 -- Global 'prosody' object |
3998
009d1ad84b49
prosody, prosodyctl: Create prosody object as a local before exporting as a global
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
47 local prosody = { |
3773
2e15808243f3
prosodyctl: Add dummy lock/unlock_globals() until util.startup comes along
Matthew Wild <mwild1@gmail.com>
parents:
3742
diff
changeset
|
48 hosts = {}; |
2e15808243f3
prosodyctl: Add dummy lock/unlock_globals() until util.startup comes along
Matthew Wild <mwild1@gmail.com>
parents:
3742
diff
changeset
|
49 events = require "util.events".new(); |
2e15808243f3
prosodyctl: Add dummy lock/unlock_globals() until util.startup comes along
Matthew Wild <mwild1@gmail.com>
parents:
3742
diff
changeset
|
50 platform = "posix"; |
2e15808243f3
prosodyctl: Add dummy lock/unlock_globals() until util.startup comes along
Matthew Wild <mwild1@gmail.com>
parents:
3742
diff
changeset
|
51 lock_globals = function () end; |
2e15808243f3
prosodyctl: Add dummy lock/unlock_globals() until util.startup comes along
Matthew Wild <mwild1@gmail.com>
parents:
3742
diff
changeset
|
52 unlock_globals = function () end; |
3013
518e3f6f9946
prosodyctl: Relocate global prosody object creation (see fff153f7f4de)
Matthew Wild <mwild1@gmail.com>
parents:
2706
diff
changeset
|
53 }; |
3998
009d1ad84b49
prosody, prosodyctl: Create prosody object as a local before exporting as a global
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
54 _G.prosody = prosody; |
3013
518e3f6f9946
prosodyctl: Relocate global prosody object creation (see fff153f7f4de)
Matthew Wild <mwild1@gmail.com>
parents:
2706
diff
changeset
|
55 |
3904
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
3777
diff
changeset
|
56 local dependencies = require "util.dependencies"; |
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
3777
diff
changeset
|
57 if not dependencies.check_dependencies() then |
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
3777
diff
changeset
|
58 os.exit(1); |
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
3777
diff
changeset
|
59 end |
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
3777
diff
changeset
|
60 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 config = require "core.configmanager" |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 do |
3739
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
64 local filenames = {}; |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
65 |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
66 local filename; |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
67 if arg[1] == "--config" and arg[2] then |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
68 table.insert(filenames, arg[2]); |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
69 table.remove(arg, 1); table.remove(arg, 1); |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
70 if CFG_CONFIGDIR then |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
71 table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]); |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
72 end |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
73 else |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
74 for _, format in ipairs(config.parsers()) do |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
75 table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg."..format); |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
76 end |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
77 end |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
78 for _,_filename in ipairs(filenames) do |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
79 filename = _filename; |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
80 local file = io.open(filename); |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
81 if file then |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
82 file:close(); |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
83 CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$"); |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
84 break; |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
85 end |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
86 end |
9ee223177319
prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable).
Waqas Hussain <waqas20@gmail.com>
parents:
3724
diff
changeset
|
87 local ok, level, err = config.load(filename); |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 if not ok then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 print("\n"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 print("**************************"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 if level == "parser" then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 local err_line, err_message = tostring(err):match("%[string .-%]:(%d*): (.*)"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 print("Error"..(err_line and (" on line "..err_line) or "")..": "..(err_message or tostring(err))); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 print(""); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 elseif level == "file" then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 print("Prosody was unable to find the configuration file."); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 print("We looked for: "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 print("A sample config file is included in the Prosody download called prosody.cfg.lua.dist"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 print("Copy or rename it to prosody.cfg.lua and edit as necessary."); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 print("More help on configuring Prosody can be found at http://prosody.im/doc/configure"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 print("Good luck!"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 print("**************************"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 print(""); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 os.exit(1); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 end |
3339
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
109 local original_logging_config = config.get("*", "core", "log"); |
3338
d50b6b3efad1
prosodyctl: Force log output always to the console instead of using the config, which avoids creating log files as the wrong user
Matthew Wild <mwild1@gmail.com>
parents:
3337
diff
changeset
|
110 config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } }); |
d50b6b3efad1
prosodyctl: Force log output always to the console instead of using the config, which avoids creating log files as the wrong user
Matthew Wild <mwild1@gmail.com>
parents:
3337
diff
changeset
|
111 |
4095
6ad7ed619d37
prosodyctl: Instead of calling datamanager.set_path(), just ensure prosody.paths.data always contains the correct value (including config)
Matthew Wild <mwild1@gmail.com>
parents:
3999
diff
changeset
|
112 local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data"; |
4158
14581c3f33bd
prosodyctl: Support for plugin_paths config option
Matthew Wild <mwild1@gmail.com>
parents:
4142
diff
changeset
|
113 local custom_plugin_paths = config.get("*", "core", "plugin_paths"); |
14581c3f33bd
prosodyctl: Support for plugin_paths config option
Matthew Wild <mwild1@gmail.com>
parents:
4142
diff
changeset
|
114 if custom_plugin_paths then |
4167
9c60cc8dc142
prosody, prosodyctl: Use plugin_paths in addition to, not instead of, the default plugin path
Matthew Wild <mwild1@gmail.com>
parents:
4158
diff
changeset
|
115 local path_sep = package.config:sub(3,3); |
9c60cc8dc142
prosody, prosodyctl: Use plugin_paths in addition to, not instead of, the default plugin path
Matthew Wild <mwild1@gmail.com>
parents:
4158
diff
changeset
|
116 -- path1;path2;path3;defaultpath... |
9c60cc8dc142
prosody, prosodyctl: Use plugin_paths in addition to, not instead of, the default plugin path
Matthew Wild <mwild1@gmail.com>
parents:
4158
diff
changeset
|
117 CFG_PLUGINDIR = table.concat(custom_plugin_paths, path_sep)..path_sep..(CFG_PLUGINDIR or "plugins"); |
4158
14581c3f33bd
prosodyctl: Support for plugin_paths config option
Matthew Wild <mwild1@gmail.com>
parents:
4142
diff
changeset
|
118 end |
4095
6ad7ed619d37
prosodyctl: Instead of calling datamanager.set_path(), just ensure prosody.paths.data always contains the correct value (including config)
Matthew Wild <mwild1@gmail.com>
parents:
3999
diff
changeset
|
119 prosody.paths = { source = CFG_SOURCEDIR, config = CFG_CONFIGDIR, |
4167
9c60cc8dc142
prosody, prosodyctl: Use plugin_paths in addition to, not instead of, the default plugin path
Matthew Wild <mwild1@gmail.com>
parents:
4158
diff
changeset
|
120 plugins = CFG_PLUGINDIR or "plugins", data = data_path }; |
4095
6ad7ed619d37
prosodyctl: Instead of calling datamanager.set_path(), just ensure prosody.paths.data always contains the correct value (including config)
Matthew Wild <mwild1@gmail.com>
parents:
3999
diff
changeset
|
121 |
2587
c37f971f0fe6
prosody, prosodyctl: Re-jiggle load order again, fixes logging config not being obeyed (thanks darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
2566
diff
changeset
|
122 require "core.loggingmanager" |
c37f971f0fe6
prosody, prosodyctl: Re-jiggle load order again, fixes logging config not being obeyed (thanks darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
2566
diff
changeset
|
123 |
3904
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
3777
diff
changeset
|
124 dependencies.log_warnings(); |
2587
c37f971f0fe6
prosody, prosodyctl: Re-jiggle load order again, fixes logging config not being obeyed (thanks darkrain)
Matthew Wild <mwild1@gmail.com>
parents:
2566
diff
changeset
|
125 |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
126 -- Switch away from root and into the prosody user -- |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
127 local switched_user, current_uid; |
1580
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
128 |
3481
72d3c8029178
util.pposix: Add pposix.uname(), bump version
Matthew Wild <mwild1@gmail.com>
parents:
3471
diff
changeset
|
129 local want_pposix_version = "0.3.5"; |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
130 local ok, pposix = pcall(require, "util.pposix"); |
1580
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
131 |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
132 if ok and pposix then |
1580
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
133 if pposix._VERSION ~= want_pposix_version then print(string.format("Unknown version (%s) of binary pposix module, expected %s", tostring(pposix._VERSION), want_pposix_version)); return; end |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
134 current_uid = pposix.getuid(); |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
135 if current_uid == 0 then |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
136 -- We haz root! |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
137 local desired_user = config.get("*", "core", "prosody_user") or "prosody"; |
1580
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
138 local desired_group = config.get("*", "core", "prosody_group") or desired_user; |
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
139 local ok, err = pposix.setgid(desired_group); |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
140 if ok then |
3471
482275e38224
util.pposix, prosodyctl, mod_posix: Add initgroups() function, and bump module version. prosodyctl inits groups with the groups of prosody_user. (thanks dbb)
Matthew Wild <mwild1@gmail.com>
parents:
3339
diff
changeset
|
141 ok, err = pposix.initgroups(desired_user); |
482275e38224
util.pposix, prosodyctl, mod_posix: Add initgroups() function, and bump module version. prosodyctl inits groups with the groups of prosody_user. (thanks dbb)
Matthew Wild <mwild1@gmail.com>
parents:
3339
diff
changeset
|
142 end |
482275e38224
util.pposix, prosodyctl, mod_posix: Add initgroups() function, and bump module version. prosodyctl inits groups with the groups of prosody_user. (thanks dbb)
Matthew Wild <mwild1@gmail.com>
parents:
3339
diff
changeset
|
143 if ok then |
1580
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
144 ok, err = pposix.setuid(desired_user); |
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
145 if ok then |
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
146 -- Yay! |
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
147 switched_user = true; |
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
148 end |
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
149 end |
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
150 if not switched_user then |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
151 -- Boo! |
1580
5be6dc582df3
prosodyctl: Also switch group when we switch user
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
152 print("Warning: Couldn't switch to Prosody user/group '"..tostring(desired_user).."'/'"..tostring(desired_group).."': "..tostring(err)); |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
153 end |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
154 end |
2439
511ba389147a
prosodyctl: Set umask to protect data files, bump pposix dep to 0.3.2
Matthew Wild <mwild1@gmail.com>
parents:
2410
diff
changeset
|
155 |
511ba389147a
prosodyctl: Set umask to protect data files, bump pposix dep to 0.3.2
Matthew Wild <mwild1@gmail.com>
parents:
2410
diff
changeset
|
156 -- Set our umask to protect data files |
511ba389147a
prosodyctl: Set umask to protect data files, bump pposix dep to 0.3.2
Matthew Wild <mwild1@gmail.com>
parents:
2410
diff
changeset
|
157 pposix.umask(config.get("*", "core", "umask") or "027"); |
1114
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
158 else |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
159 print("Error: Unable to load pposix module. Check that Prosody is installed correctly.") |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
160 print("For more help send the below error to us through http://prosody.im/discuss"); |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
161 print(tostring(pposix)) |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
162 end |
c463e30da312
prosodyctl: Switch to Prosody user before attempting to do anything
Matthew Wild <mwild1@gmail.com>
parents:
1102
diff
changeset
|
163 |
3339
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
164 local function test_writeable(filename) |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
165 local f, err = io.open(filename, "a"); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
166 if not f then |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
167 return false, err; |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
168 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
169 f:close(); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
170 return true; |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
171 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
172 |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
173 local unwriteable_files = {}; |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
174 if type(original_logging_config) == "string" and original_logging_config:sub(1,1) ~= "*" then |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
175 local ok, err = test_writeable(original_logging_config); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
176 if not ok then |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
177 table.insert(unwriteable_files, err); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
178 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
179 elseif type(original_logging_config) == "table" then |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
180 for _, rule in ipairs(original_logging_config) do |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
181 if rule.filename then |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
182 local ok, err = test_writeable(rule.filename); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
183 if not ok then |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
184 table.insert(unwriteable_files, err); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
185 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
186 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
187 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
188 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
189 |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
190 if #unwriteable_files > 0 then |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
191 print("One of more of the Prosody log files are not"); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
192 print("writeable, please correct the errors and try"); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
193 print("starting prosodyctl again."); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
194 print(""); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
195 for _, err in ipairs(unwriteable_files) do |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
196 print(err); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
197 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
198 print(""); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
199 os.exit(1); |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
200 end |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
201 |
7893055e54d1
prosodyctl: Warn and exit if any log files are not writeable, fixes #94
Matthew Wild <mwild1@gmail.com>
parents:
3338
diff
changeset
|
202 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
203 local error_messages = setmetatable({ |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
204 ["invalid-username"] = "The given username is invalid in a Jabber ID"; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
205 ["invalid-hostname"] = "The given hostname is invalid"; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
206 ["no-password"] = "No password was supplied"; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
207 ["no-such-user"] = "The given user does not exist on the server"; |
1124
055cfdc96afa
prosodyctl: Add message for unable-to-save-data error
Matthew Wild <mwild1@gmail.com>
parents:
1122
diff
changeset
|
208 ["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?"; |
2065
c384ae8ee17a
prosodyctl: Put 'pidfile' in quotes to make more clear that it is the literal name of the option
Matthew Wild <mwild1@gmail.com>
parents:
2020
diff
changeset
|
209 ["no-pidfile"] = "There is no 'pidfile' option in the configuration file, see http://prosody.im/doc/prosodyctl#pidfile for help"; |
3627
9e62937c9757
prosodyctl, util.prosodyctl: Show error when mod_posix is not enabled and an attempt is made to query Prosody's status (thanks stever)
Matthew Wild <mwild1@gmail.com>
parents:
3481
diff
changeset
|
210 ["no-posix"] = "The mod_posix module is not enabled in the Prosody config file, see http://prosody.im/doc/prosodyctl for more info"; |
1390
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
211 ["no-such-method"] = "This module has no commands"; |
1460
5882ed6219ff
prosodyctl: Add message for not-running error
Matthew Wild <mwild1@gmail.com>
parents:
1459
diff
changeset
|
212 ["not-running"] = "Prosody is not running"; |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 }, { __index = function (t,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end }); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
214 |
2442
94c676b585c0
prosodyctl: Move definition of prosody singleton to prior to loading datamanager, and add platform
Matthew Wild <mwild1@gmail.com>
parents:
2439
diff
changeset
|
215 hosts = prosody.hosts; |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
216 |
3038
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
217 local function make_host(hostname) |
3630
e0c67b14d25f
prosodyctl: Give hosts type = 'local'
Matthew Wild <mwild1@gmail.com>
parents:
3627
diff
changeset
|
218 return { |
e0c67b14d25f
prosodyctl: Give hosts type = 'local'
Matthew Wild <mwild1@gmail.com>
parents:
3627
diff
changeset
|
219 type = "local", |
e0c67b14d25f
prosodyctl: Give hosts type = 'local'
Matthew Wild <mwild1@gmail.com>
parents:
3627
diff
changeset
|
220 events = prosody.events, |
e0c67b14d25f
prosodyctl: Give hosts type = 'local'
Matthew Wild <mwild1@gmail.com>
parents:
3627
diff
changeset
|
221 users = require "core.usermanager".new_null_provider(hostname) |
e0c67b14d25f
prosodyctl: Give hosts type = 'local'
Matthew Wild <mwild1@gmail.com>
parents:
3627
diff
changeset
|
222 }; |
3038
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
223 end |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
224 |
2020
24f54340a670
prosodyctl: Remove dependency on hostmanager, and friends
Matthew Wild <mwild1@gmail.com>
parents:
1580
diff
changeset
|
225 for hostname, config in pairs(config.getconfig()) do |
3038
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
226 hosts[hostname] = make_host(hostname); |
2020
24f54340a670
prosodyctl: Remove dependency on hostmanager, and friends
Matthew Wild <mwild1@gmail.com>
parents:
1580
diff
changeset
|
227 end |
24f54340a670
prosodyctl: Remove dependency on hostmanager, and friends
Matthew Wild <mwild1@gmail.com>
parents:
1580
diff
changeset
|
228 |
1390
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
229 require "core.modulemanager" |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
230 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
231 require "util.prosodyctl" |
1458
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
232 require "socket" |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
233 ----------------------- |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
234 |
4142
caa78589598f
prosodyctl, util.prosodyctl: Move UI functions to util.prosodyctl so they can be used outside of prosodyctl itself
Matthew Wild <mwild1@gmail.com>
parents:
4095
diff
changeset
|
235 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; |
caa78589598f
prosodyctl, util.prosodyctl: Move UI functions to util.prosodyctl so they can be used outside of prosodyctl itself
Matthew Wild <mwild1@gmail.com>
parents:
4095
diff
changeset
|
236 local show_usage = prosodyctl.show_usage; |
caa78589598f
prosodyctl, util.prosodyctl: Move UI functions to util.prosodyctl so they can be used outside of prosodyctl itself
Matthew Wild <mwild1@gmail.com>
parents:
4095
diff
changeset
|
237 local getchar, getpass = prosodyctl.getchar, prosodyctl.getpass; |
caa78589598f
prosodyctl, util.prosodyctl: Move UI functions to util.prosodyctl so they can be used outside of prosodyctl itself
Matthew Wild <mwild1@gmail.com>
parents:
4095
diff
changeset
|
238 local show_yesno = prosodyctl.show_yesno; |
4487
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
239 local show_prompt = prosodyctl.show_prompt; |
4142
caa78589598f
prosodyctl, util.prosodyctl: Move UI functions to util.prosodyctl so they can be used outside of prosodyctl itself
Matthew Wild <mwild1@gmail.com>
parents:
4095
diff
changeset
|
240 local read_password = prosodyctl.read_password; |
1459
545208bc0e84
prosodyctl: Use prosodyctl_timeout option if it exists in the config
Matthew Wild <mwild1@gmail.com>
parents:
1458
diff
changeset
|
241 |
545208bc0e84
prosodyctl: Use prosodyctl_timeout option if it exists in the config
Matthew Wild <mwild1@gmail.com>
parents:
1458
diff
changeset
|
242 local prosodyctl_timeout = (config.get("*", "core", "prosodyctl_timeout") or 5) * 2; |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
243 ----------------------- |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
244 local commands = {}; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
245 local command = arg[1]; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
246 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
247 function commands.adduser(arg) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
248 if not arg[1] or arg[1] == "--help" then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
249 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
250 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
251 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
252 local user, host = arg[1]:match("([^@]+)@(.+)"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
253 if not user and host then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
254 show_message [[Failed to understand JID, please supply the JID you want to create]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
255 show_usage [[adduser user@host]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
256 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
257 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
258 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
259 if not host then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
260 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
261 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
262 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
263 |
3038
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
264 if not hosts[host] then |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
265 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
266 show_warning("The user will not be able to log in until this is changed."); |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
267 hosts[host] = make_host(host); |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
268 end |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
269 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
270 if prosodyctl.user_exists{ user = user, host = host } then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
271 show_message [[That user already exists]]; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
272 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
273 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
274 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
275 local password = read_password(); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
276 if not password then return 1; end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
277 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
278 local ok, msg = prosodyctl.adduser { user = user, host = host, password = password }; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
279 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
280 if ok then return 0; end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
281 |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3773
diff
changeset
|
282 show_message(msg) |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
283 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
284 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
285 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
286 function commands.passwd(arg) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
287 if not arg[1] or arg[1] == "--help" then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
288 show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
289 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
290 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
291 local user, host = arg[1]:match("([^@]+)@(.+)"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
292 if not user and host then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
293 show_message [[Failed to understand JID, please supply the JID you want to set the password for]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
294 show_usage [[passwd user@host]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
295 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
296 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
297 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
298 if not host then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
299 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
300 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
301 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
302 |
3038
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
303 if not hosts[host] then |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
304 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
305 show_warning("The user will not be able to log in until this is changed."); |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
306 hosts[host] = make_host(host); |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
307 end |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
308 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
309 if not prosodyctl.user_exists { user = user, host = host } then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
310 show_message [[That user does not exist, use prosodyctl adduser to create a new user]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
311 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
312 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
313 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
314 local password = read_password(); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
315 if not password then return 1; end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
316 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
317 local ok, msg = prosodyctl.passwd { user = user, host = host, password = password }; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
318 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
319 if ok then return 0; end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
320 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
321 show_message(error_messages[msg]) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
322 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
323 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
324 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
325 function commands.deluser(arg) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
326 if not arg[1] or arg[1] == "--help" then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
327 show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
328 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
329 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
330 local user, host = arg[1]:match("([^@]+)@(.+)"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
331 if not user and host then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
332 show_message [[Failed to understand JID, please supply the JID you want to set the password for]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
333 show_usage [[passwd user@host]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
334 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
335 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
336 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
337 if not host then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
338 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
339 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
340 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
341 |
3038
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
342 if not hosts[host] then |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
343 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
344 show_warning("The user will not be able to log in until this is changed."); |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
345 hosts[host] = make_host(host); |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
346 end |
6b68355d615a
prosodyctl: Support for the new usermanager, refactor host creation and fail if a host is not using the default authentication provider, for now. (thanks Nicola)
Matthew Wild <mwild1@gmail.com>
parents:
3015
diff
changeset
|
347 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
348 if not prosodyctl.user_exists { user = user, host = host } then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
349 show_message [[That user does not exist on this server]] |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
350 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
351 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
352 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
353 local ok, msg = prosodyctl.passwd { user = user, host = host }; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
354 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
355 if ok then return 0; end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
356 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
357 show_message(error_messages[msg]) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
358 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
359 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
360 |
1089
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
361 function commands.start(arg) |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
362 if arg[1] == "--help" then |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
363 show_usage([[start]], [[Start Prosody]]); |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
364 return 1; |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
365 end |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
366 local ok, ret = prosodyctl.isrunning(); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
367 if not ok then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
368 show_message(error_messages[ret]); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
369 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
370 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
371 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
372 if ret then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
373 local ok, ret = prosodyctl.getpid(); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
374 if not ok then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
375 show_message("Couldn't get running Prosody's PID"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
376 show_message(error_messages[ret]); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
377 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
378 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
379 show_message("Prosody is already running with PID %s", ret or "(unknown)"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
380 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
381 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
382 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
383 local ok, ret = prosodyctl.start(); |
1458
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
384 if ok then |
2511
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
385 if config.get("*", "core", "daemonize") ~= false then |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
386 local i=1; |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
387 while true do |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
388 local ok, running = prosodyctl.isrunning(); |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
389 if ok and running then |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
390 break; |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
391 elseif i == 5 then |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
392 show_message("Still waiting..."); |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
393 elseif i >= prosodyctl_timeout then |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
394 show_message("Prosody is still not running. Please give it some time or check your log files for errors."); |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
395 return 2; |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
396 end |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
397 socket.sleep(0.5); |
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
398 i = i + 1; |
1458
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
399 end |
2511
a81c710b1708
prosodyctl: Don't display message about failing to start Prosody is daemonizing is disabled (if daemonizing is disabled then Prosody is stopped by the time control returns to prosodyctl, which then can't see Prosody running)
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
400 show_message("Started"); |
1458
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
401 end |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
402 return 0; |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
403 end |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
404 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
405 show_message("Failed to start Prosody"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
406 show_message(error_messages[ret]) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
407 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
408 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
409 |
1089
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
410 function commands.status(arg) |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
411 if arg[1] == "--help" then |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
412 show_usage([[status]], [[Reports the running status of Prosody]]); |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
413 return 1; |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
414 end |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
415 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
416 local ok, ret = prosodyctl.isrunning(); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
417 if not ok then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
418 show_message(error_messages[ret]); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
419 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
420 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
421 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
422 if ret then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
423 local ok, ret = prosodyctl.getpid(); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
424 if not ok then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
425 show_message("Couldn't get running Prosody's PID"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
426 show_message(error_messages[ret]); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
427 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
428 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
429 show_message("Prosody is running with PID %s", ret or "(unknown)"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
430 return 0; |
1089
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
431 else |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
432 show_message("Prosody is not running"); |
1115
8a7bc1a5eae6
prosodyctl: status: Show warning if we can't find a running Prosody, and we didn't switch user
Matthew Wild <mwild1@gmail.com>
parents:
1114
diff
changeset
|
433 if not switched_user and current_uid ~= 0 then |
1122
07b2b5942957
prosodyctl: Reformat note to fit in small-width terminals
Matthew Wild <mwild1@gmail.com>
parents:
1120
diff
changeset
|
434 print("\nNote:") |
07b2b5942957
prosodyctl: Reformat note to fit in small-width terminals
Matthew Wild <mwild1@gmail.com>
parents:
1120
diff
changeset
|
435 print(" You will also see this if prosodyctl is not running under"); |
07b2b5942957
prosodyctl: Reformat note to fit in small-width terminals
Matthew Wild <mwild1@gmail.com>
parents:
1120
diff
changeset
|
436 print(" the same user account as Prosody. Try running as root (e.g. "); |
07b2b5942957
prosodyctl: Reformat note to fit in small-width terminals
Matthew Wild <mwild1@gmail.com>
parents:
1120
diff
changeset
|
437 print(" with 'sudo' in front) to gain access to Prosody's real status."); |
1115
8a7bc1a5eae6
prosodyctl: status: Show warning if we can't find a running Prosody, and we didn't switch user
Matthew Wild <mwild1@gmail.com>
parents:
1114
diff
changeset
|
438 end |
1089
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
439 return 2 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
440 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
441 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
442 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
443 |
1089
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
444 function commands.stop(arg) |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
445 if arg[1] == "--help" then |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
446 show_usage([[stop]], [[Stop a running Prosody server]]); |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
447 return 1; |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
448 end |
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
449 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
450 if not prosodyctl.isrunning() then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
451 show_message("Prosody is not running"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
452 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
453 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
454 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
455 local ok, ret = prosodyctl.stop(); |
1458
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
456 if ok then |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
457 local i=1; |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
458 while true do |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
459 local ok, running = prosodyctl.isrunning(); |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
460 if ok and not running then |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
461 break; |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
462 elseif i == 5 then |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
463 show_message("Still waiting..."); |
1459
545208bc0e84
prosodyctl: Use prosodyctl_timeout option if it exists in the config
Matthew Wild <mwild1@gmail.com>
parents:
1458
diff
changeset
|
464 elseif i >= prosodyctl_timeout then |
1458
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
465 show_message("Prosody is still running. Please give it some time or check your log files for errors."); |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
466 return 2; |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
467 end |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
468 socket.sleep(0.5); |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
469 i = i + 1; |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
470 end |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
471 show_message("Stopped"); |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
472 return 0; |
fce75b4efda9
prosodyctl: Improve usability with status messages, and waiting up to 5s for the server to start/stop
Matthew Wild <mwild1@gmail.com>
parents:
1390
diff
changeset
|
473 end |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
474 |
1089
a817cbaa0f46
prosodyctl: Multiple fixes for start/status/stop
Matthew Wild <mwild1@gmail.com>
parents:
1087
diff
changeset
|
475 show_message(error_messages[ret]); |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
476 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
477 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
478 |
2696
cb5acafbec62
prosodyctl: Add restart command for KSid and johnny :)
Matthew Wild <mwild1@gmail.com>
parents:
2587
diff
changeset
|
479 function commands.restart(arg) |
cb5acafbec62
prosodyctl: Add restart command for KSid and johnny :)
Matthew Wild <mwild1@gmail.com>
parents:
2587
diff
changeset
|
480 if arg[1] == "--help" then |
2705
8a5af6f14c07
prosodyctl: Fix 'restart' command to not report itself as the 'stop' command (thanks albert!)
Matthew Wild <mwild1@gmail.com>
parents:
2696
diff
changeset
|
481 show_usage([[restart]], [[Restart a running Prosody server]]); |
2696
cb5acafbec62
prosodyctl: Add restart command for KSid and johnny :)
Matthew Wild <mwild1@gmail.com>
parents:
2587
diff
changeset
|
482 return 1; |
cb5acafbec62
prosodyctl: Add restart command for KSid and johnny :)
Matthew Wild <mwild1@gmail.com>
parents:
2587
diff
changeset
|
483 end |
cb5acafbec62
prosodyctl: Add restart command for KSid and johnny :)
Matthew Wild <mwild1@gmail.com>
parents:
2587
diff
changeset
|
484 |
3724
c12ebbd4ab61
prosodyctl: Make the 'restart' command start Prosody even if it wasn't already running
Matthew Wild <mwild1@gmail.com>
parents:
3630
diff
changeset
|
485 commands.stop(arg); |
c12ebbd4ab61
prosodyctl: Make the 'restart' command start Prosody even if it wasn't already running
Matthew Wild <mwild1@gmail.com>
parents:
3630
diff
changeset
|
486 return commands.start(arg); |
2696
cb5acafbec62
prosodyctl: Add restart command for KSid and johnny :)
Matthew Wild <mwild1@gmail.com>
parents:
2587
diff
changeset
|
487 end |
cb5acafbec62
prosodyctl: Add restart command for KSid and johnny :)
Matthew Wild <mwild1@gmail.com>
parents:
2587
diff
changeset
|
488 |
4324
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
489 function commands.about(arg) |
4331
9c45858e3208
prosodyctl: Fix 'about' command to not show up where it shouldn't...
Matthew Wild <mwild1@gmail.com>
parents:
4324
diff
changeset
|
490 if arg[1] == "--help" then |
9c45858e3208
prosodyctl: Fix 'about' command to not show up where it shouldn't...
Matthew Wild <mwild1@gmail.com>
parents:
4324
diff
changeset
|
491 show_usage([[about]], [[Show information about this Prosody installation]]); |
9c45858e3208
prosodyctl: Fix 'about' command to not show up where it shouldn't...
Matthew Wild <mwild1@gmail.com>
parents:
4324
diff
changeset
|
492 return 1; |
9c45858e3208
prosodyctl: Fix 'about' command to not show up where it shouldn't...
Matthew Wild <mwild1@gmail.com>
parents:
4324
diff
changeset
|
493 end |
9c45858e3208
prosodyctl: Fix 'about' command to not show up where it shouldn't...
Matthew Wild <mwild1@gmail.com>
parents:
4324
diff
changeset
|
494 |
4324
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
495 require "util.array"; |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
496 require "util.iterators"; |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
497 |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
498 print("Prosody "..(prosody.version or "(unknown version)")); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
499 print(""); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
500 print("# Prosody directories"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
501 print("Data directory: ", CFG_DATADIR or "./"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
502 print("Plugin directory:", CFG_PLUGINDIR or "./"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
503 print("Config directory:", CFG_CONFIGDIR or "./"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
504 print("Source directory:", CFG_SOURCEDIR or "./"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
505 print(""); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
506 print("# Lua environment"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
507 print("Lua version: ", _G._VERSION); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
508 print(""); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
509 print("Lua module search paths:"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
510 for path in package.path:gmatch("[^;]+") do |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
511 print(" "..path); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
512 end |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
513 print(""); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
514 print("Lua C module search paths:"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
515 for path in package.cpath:gmatch("[^;]+") do |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
516 print(" "..path); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
517 end |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
518 print(""); |
4333
040193dead77
prosodyctl: Add info about the presence of LuaRocks to 'about' command
Matthew Wild <mwild1@gmail.com>
parents:
4331
diff
changeset
|
519 local luarocks_status = (pcall(require, "luarocks.loader") and "Installed ("..(luarocks.cfg.program_version or "2.x+")..")") |
4334
cd1b73582711
prosodyctl: Remove typo'd '+' after LuaRocks 1.x version (thanks spoobie)
Matthew Wild <mwild1@gmail.com>
parents:
4333
diff
changeset
|
520 or (pcall(require, "luarocks.require") and "Installed (1.x)") |
4333
040193dead77
prosodyctl: Add info about the presence of LuaRocks to 'about' command
Matthew Wild <mwild1@gmail.com>
parents:
4331
diff
changeset
|
521 or "Not installed"; |
040193dead77
prosodyctl: Add info about the presence of LuaRocks to 'about' command
Matthew Wild <mwild1@gmail.com>
parents:
4331
diff
changeset
|
522 print("LuaRocks: ", luarocks_status); |
040193dead77
prosodyctl: Add info about the presence of LuaRocks to 'about' command
Matthew Wild <mwild1@gmail.com>
parents:
4331
diff
changeset
|
523 print(""); |
4324
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
524 print("# Lua module versions"); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
525 local module_versions, longest_name = {}, 8; |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
526 for name, module in pairs(package.loaded) do |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
527 if type(module) == "table" and rawget(module, "_VERSION") |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
528 and name ~= "_G" and not name:match("%.") then |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
529 if #name > longest_name then |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
530 longest_name = #name; |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
531 end |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
532 module_versions[name] = module._VERSION; |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
533 end |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
534 end |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
535 local sorted_keys = array.collect(keys(module_versions)):sort(); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
536 for _, name in ipairs(array.collect(keys(module_versions)):sort()) do |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
537 print(name..":"..string.rep(" ", longest_name-#name), module_versions[name]); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
538 end |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
539 print(""); |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
540 end |
5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
541 |
4335
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
542 function commands.reload(arg) |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
543 if arg[1] == "--help" then |
4476
53ce21286b8c
prosodyctl: Adjust description of 'reload' command (thanks crocket)
Matthew Wild <mwild1@gmail.com>
parents:
4336
diff
changeset
|
544 show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]); |
4335
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
545 return 1; |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
546 end |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
547 |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
548 if not prosodyctl.isrunning() then |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
549 show_message("Prosody is not running"); |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
550 return 1; |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
551 end |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
552 |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
553 local ok, ret = prosodyctl.reload(); |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
554 if ok then |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
555 |
4336
abcbcb15205c
prosodyctl: Update message on reload success
Matthew Wild <mwild1@gmail.com>
parents:
4335
diff
changeset
|
556 show_message("Prosody log files re-opened and config file reloaded. You may need to reload modules for some changes to take effect."); |
4335
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
557 return 0; |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
558 end |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
559 |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
560 show_message(error_messages[ret]); |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
561 return 1; |
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
562 end |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
563 -- ejabberdctl compatibility |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
564 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
565 function commands.register(arg) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
566 local user, host, password = unpack(arg); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
567 if (not (user and host)) or arg[1] == "--help" then |
1102
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
568 if user ~= "--help" then |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
569 if not user then |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
570 show_message [[No username specified]] |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
571 elseif not host then |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
572 show_message [[Please specify which host you want to register the user on]]; |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
573 end |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
574 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
575 show_usage("register USER HOST [PASSWORD]", "Register a user on the server, with the given password"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
576 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
577 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
578 if not password then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
579 password = read_password(); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
580 if not password then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
581 show_message [[Unable to register user with no password]]; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
582 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
583 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
584 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
585 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
586 local ok, msg = prosodyctl.adduser { user = user, host = host, password = password }; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
587 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
588 if ok then return 0; end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
589 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
590 show_message(error_messages[msg]) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
591 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
592 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
593 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
594 function commands.unregister(arg) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
595 local user, host = unpack(arg); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
596 if (not (user and host)) or arg[1] == "--help" then |
1102
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
597 if user ~= "--help" then |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
598 if not user then |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
599 show_message [[No username specified]] |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
600 elseif not host then |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
601 show_message [[Please specify which host you want to unregister the user from]]; |
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
602 end |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
603 end |
1102
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
604 show_usage("unregister USER HOST [PASSWORD]", "Permanently remove a user account from the server"); |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
605 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
606 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
607 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
608 local ok, msg = prosodyctl.deluser { user = user, host = host }; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
609 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
610 if ok then return 0; end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
611 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
612 show_message(error_messages[msg]) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
613 return 1; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
614 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
615 |
4487
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
616 local x509 = require "util.x509"; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
617 local genx509san = x509.genx509san; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
618 local opensslbaseconf = x509.baseconf; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
619 local seralizeopensslbaseconf = x509.serialize_conf; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
620 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
621 local cert_commands = {}; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
622 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
623 -- TODO Should this be moved to util.prosodyctl or x509? |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
624 function cert_commands.config(arg) |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
625 if #arg >= 1 and arg[1] ~= "--help" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
626 local conf_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".cnf"; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
627 if os.execute("test -f "..conf_filename) == 0 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
628 and not show_yesno("Overwrite "..conf_filename .. "?") then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
629 return nil, conf_filename; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
630 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
631 local conf = opensslbaseconf(); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
632 conf.subject_alternative_name = genx509san(hosts, config, arg, true) |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
633 for k, v in pairs(conf.distinguished_name) do |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
634 local nv; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
635 if k == "commonName" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
636 v = arg[1] |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
637 elseif k == "emailAddress" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
638 v = "xmpp@" .. arg[1]; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
639 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
640 nv = show_prompt(("%s (%s):"):format(k, nv or v)); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
641 nv = (not nv or nv == "") and v or nv; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
642 conf.distinguished_name[k] = nv ~= "." and nv or nil; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
643 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
644 local conf_file = io.open(conf_filename, "w"); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
645 conf_file:write(seralizeopensslbaseconf(conf)); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
646 conf_file:close(); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
647 print(""); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
648 show_message("Config written to " .. conf_filename); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
649 return nil, conf_filename; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
650 else |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
651 show_usage("cert config HOSTNAME", "generates config for OpenSSL") |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
652 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
653 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
654 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
655 function cert_commands.key(arg) |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
656 if #arg >= 1 and arg[1] ~= "--help" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
657 local key_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".key"; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
658 if os.execute("test -f "..key_filename) == 0 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
659 and not show_yesno("Overwrite "..key_filename .. "?") then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
660 return nil, key_filename; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
661 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
662 local key_size = tonumber(arg[2] or show_prompt("Choose key size (2048):") or 2048); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
663 os.execute(("openssl genrsa -out %s %d"):format(key_filename, tonumber(key_size))); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
664 os.execute(("chmod 400 %s"):format(key_filename)); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
665 show_message("Key written to ".. key_filename); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
666 return nil, key_filename; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
667 else |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
668 show_usage("cert key HOSTNAME <bits>", "Generates a RSA key") |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
669 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
670 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
671 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
672 function cert_commands.request(arg) |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
673 if #arg >= 1 and arg[1] ~= "--help" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
674 local req_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".req"; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
675 if os.execute("test -f "..req_filename) == 0 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
676 and not show_yesno("Overwrite "..req_filename .. "?") then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
677 return nil, req_filename; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
678 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
679 local _, key_filename = cert_commands.key({arg[1]}); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
680 local _, conf_filename = cert_commands.config({arg[1]}); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
681 os.execute(("openssl req -new -key %s -utf8 -config %s -out %s") |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
682 :format(key_filename, conf_filename, req_filename)); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
683 show_message("Certificate request written to ".. req_filename); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
684 else |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
685 show_usage("cert request HOSTNAME", "Generates a certificate request") |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
686 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
687 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
688 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
689 function cert_commands.generate(arg) |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
690 if #arg >= 1 and arg[1] ~= "--help" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
691 local cert_filename = (CFG_DATADIR or ".") .. "/" .. arg[1] .. ".cert"; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
692 if os.execute("test -f "..cert_filename) == 0 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
693 and not show_yesno("Overwrite "..cert_filename .. "?") then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
694 return nil, cert_filename; |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
695 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
696 local _, key_filename = cert_commands.key({arg[1]}); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
697 local _, conf_filename = cert_commands.config({arg[1]}); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
698 os.execute(("openssl req -new -x509 -nodes -key %s -days 365 -sha1 -utf8 -config %s -out %s") |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
699 :format(key_filename, conf_filename, cert_filename)); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
700 show_message("Certificate written to ".. cert_filename); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
701 else |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
702 show_usage("cert generate HOSTNAME", "Generates a self-signed certificate") |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
703 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
704 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
705 |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
706 function commands.cert(arg) |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
707 if #arg >= 1 and arg[1] ~= "--help" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
708 local subcmd = table.remove(arg, 1); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
709 if type(cert_commands[subcmd]) == "function" then |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
710 return cert_commands[subcmd](arg); |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
711 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
712 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
713 show_usage("cert config|request|generate|key", "Helpers for X.509 certificates.") |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
714 end |
5f466a50e78b
prosodyctl: Add commands for generating certificates and keys
Kim Alvefur <zash@zash.se>
parents:
4476
diff
changeset
|
715 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
716 --------------------- |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
717 |
1499
51e3e22b5316
prosodyctl: Fix traceback when issued with no parameters
Matthew Wild <mwild1@gmail.com>
parents:
1460
diff
changeset
|
718 if command and command:match("^mod_") then -- Is a command in a module |
1390
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
719 local module_name = command:match("^mod_(.+)"); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
720 local ret, err = modulemanager.load("*", module_name); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
721 if not ret then |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
722 show_message("Failed to load module '"..module_name.."': "..err); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
723 os.exit(1); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
724 end |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
725 |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
726 table.remove(arg, 1); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
727 |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
728 local module = modulemanager.get_module("*", module_name); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
729 if not module then |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
730 show_message("Failed to load module '"..module_name.."': Unknown error"); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
731 os.exit(1); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
732 end |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
733 |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
734 if not modulemanager.module_has_method(module, "command") then |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
735 show_message("Fail: mod_"..module_name.." does not support any commands"); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
736 os.exit(1); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
737 end |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
738 |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
739 local ok, ret = modulemanager.call_module_method(module, "command", arg); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
740 if ok then |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
741 if type(ret) == "number" then |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
742 os.exit(ret); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
743 elseif type(ret) == "string" then |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
744 show_message(ret); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
745 end |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
746 os.exit(0); -- :) |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
747 else |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
748 show_message("Failed to execute command: "..error_messages[ret]); |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
749 os.exit(1); -- :( |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
750 end |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
751 end |
ef672c9fe7c9
prosodyctl: Allow commands to be implemented in modules
Matthew Wild <mwild1@gmail.com>
parents:
1205
diff
changeset
|
752 |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
753 if not commands[command] then -- Show help for all commands |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
754 function show_usage(usage, desc) |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
755 print(" "..usage); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
756 print(" "..desc); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
757 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
758 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
759 print("prosodyctl - Manage a Prosody server"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
760 print(""); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
761 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
762 print(""); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
763 print("Where COMMAND may be one of:\n"); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
764 |
2706
c2dde8bda3fe
prosodyctl: Fix addplugin to support --help, and hide from the help listing (for now)
Matthew Wild <mwild1@gmail.com>
parents:
2705
diff
changeset
|
765 local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; |
4335
3a2a01432b5c
Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents:
4334
diff
changeset
|
766 local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart", "reload", "about" }; |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
767 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
768 local done = {}; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
769 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
770 for _, command_name in ipairs(commands_order) do |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
771 local command = commands[command_name]; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
772 if command then |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
773 command{ "--help" }; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
774 print"" |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
775 done[command_name] = true; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
776 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
777 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
778 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
779 for command_name, command in pairs(commands) do |
1102
c81df501fd38
prosodyctl: Hide ejabberd compatibility commands from command listing
Matthew Wild <mwild1@gmail.com>
parents:
1089
diff
changeset
|
780 if not done[command_name] and not hidden_commands:contains(command_name) then |
1087
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
781 command{ "--help" }; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
782 print"" |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
783 done[command_name] = true; |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
784 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
785 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
786 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
787 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
788 os.exit(0); |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
789 end |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
790 |
5e9475bec571
prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
791 os.exit(commands[command]({ select(2, unpack(arg)) })); |