Annotate

util/prosodyctl.lua @ 10198:83541f0ff14f

core.configmanager: Added support to 'complement_lua_path'
author João Duarte <jvsDuarte08@gmail.com>
date Thu, 01 Aug 2019 09:21:10 -0700
parent 10191:395ce57dccdf
child 10208:219a4958673d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1515
diff changeset
1 -- Prosody IM
2923
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2796
diff changeset
2 -- Copyright (C) 2008-2010 Matthew Wild
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2796
diff changeset
3 -- Copyright (C) 2008-2010 Waqas Hussain
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
4 --
1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1515
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1515
diff changeset
6 -- COPYING file in the source package for more information.
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1515
diff changeset
7 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1515
diff changeset
8
1087
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 local config = require "core.configmanager";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 local encodings = require "util.encodings";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 local stringprep = encodings.stringprep;
3771
428882c438bf util.prosodyctl: Initialize storagemanager on hosts we modify
Matthew Wild <mwild1@gmail.com>
parents: 3711
diff changeset
13 local storagemanager = require "core.storagemanager";
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 local usermanager = require "core.usermanager";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 local signal = require "util.signal";
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: 3307
diff changeset
16 local set = require "util.set";
2794
5f14cd94a563 util.prosodyctl: Report Prosody as not running if the pidfile isn't locked
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
17 local lfs = require "lfs";
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: 3777
diff changeset
18 local pcall = pcall;
4485
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
19 local type = type;
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 local io, os = io, os;
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: 3777
diff changeset
24 local print = print;
7259
d8300985f2bb net.websocket.frames, util.datetime, util.json, util.prosodyctl, util.rfc6724: Remove unused variables [luacheck]
Matthew Wild <mwild1@gmail.com>
parents: 6777
diff changeset
25 local tonumber = tonumber;
1130
442c87de8e2d util.prosodyctl: Import CFG_SOURCEDIR from the global environment (thanks macaronyde!)
Matthew Wild <mwild1@gmail.com>
parents: 1123
diff changeset
26
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: 3777
diff changeset
27 local _G = _G;
3294
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
28 local prosody = prosody;
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
29
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: 3777
diff changeset
30 -- UI helpers
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
31 local function show_message(msg, ...)
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: 3777
diff changeset
32 print(msg:format(...));
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: 3777
diff changeset
33 end
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: 3777
diff changeset
34
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
35 local function show_usage(usage, desc)
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: 3777
diff changeset
36 print("Usage: ".._G.arg[0].." "..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: 3777
diff changeset
37 if desc then
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: 3777
diff changeset
38 print(" "..desc);
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: 3777
diff changeset
39 end
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: 3777
diff changeset
40 end
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: 3777
diff changeset
41
10152
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
42 local function show_module_configuration_help(mod_name)
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
43 print("Done.")
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
44 print("If you installed a prosody plugin, don't forget to add its name under the 'modules_enabled' section inside your configuration file.")
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
45 print("Depending on the module, there might be further configuration steps required.")
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
46 print("")
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
47 print("More info about: ")
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
48 print(" modules_enabled: https://prosody.im/doc/modules_enabled")
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
49 print(" "..mod_name..": https://modules.prosody.im/"..mod_name..".html")
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
50 end
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
51
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
52 local function getchar(n)
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: 3777
diff changeset
53 local stty_ret = os.execute("stty raw -echo 2>/dev/null");
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: 3777
diff changeset
54 local ok, char;
7457
5e18416881bb util.prosodyctl: Handle os.execute in Lua 5.2 returning true when command terminates successfully
Kim Alvefur <zash@zash.se>
parents: 7262
diff changeset
55 if stty_ret == true or stty_ret == 0 then
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: 3777
diff changeset
56 ok, char = pcall(io.read, n or 1);
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: 3777
diff changeset
57 os.execute("stty sane");
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: 3777
diff changeset
58 else
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: 3777
diff changeset
59 ok, char = pcall(io.read, "*l");
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: 3777
diff changeset
60 if ok then
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: 3777
diff changeset
61 char = char:sub(1, n or 1);
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: 3777
diff changeset
62 end
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: 3777
diff changeset
63 end
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: 3777
diff changeset
64 if ok then
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: 3777
diff changeset
65 return char;
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: 3777
diff changeset
66 end
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: 3777
diff changeset
67 end
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: 3777
diff changeset
68
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
69 local function getline()
4485
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
70 local ok, line = pcall(io.read, "*l");
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
71 if ok then
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
72 return line;
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
73 end
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
74 end
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
75
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
76 local function getpass()
8634
f6f62c92b642 util.prosodyctl: Fix getpass() for new return values of os.execute() in Lua 5.2
Matthew Wild <mwild1@gmail.com>
parents: 8123
diff changeset
77 local stty_ret, _, status_code = os.execute("stty -echo 2>/dev/null");
f6f62c92b642 util.prosodyctl: Fix getpass() for new return values of os.execute() in Lua 5.2
Matthew Wild <mwild1@gmail.com>
parents: 8123
diff changeset
78 if status_code then -- COMPAT w/ Lua 5.1
f6f62c92b642 util.prosodyctl: Fix getpass() for new return values of os.execute() in Lua 5.2
Matthew Wild <mwild1@gmail.com>
parents: 8123
diff changeset
79 stty_ret = status_code;
f6f62c92b642 util.prosodyctl: Fix getpass() for new return values of os.execute() in Lua 5.2
Matthew Wild <mwild1@gmail.com>
parents: 8123
diff changeset
80 end
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: 3777
diff changeset
81 if stty_ret ~= 0 then
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: 3777
diff changeset
82 io.write("\027[08m"); -- ANSI 'hidden' text attribute
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: 3777
diff changeset
83 end
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: 3777
diff changeset
84 local ok, pass = pcall(io.read, "*l");
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: 3777
diff changeset
85 if stty_ret == 0 then
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: 3777
diff changeset
86 os.execute("stty sane");
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: 3777
diff changeset
87 else
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: 3777
diff changeset
88 io.write("\027[00m");
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: 3777
diff changeset
89 end
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: 3777
diff changeset
90 io.write("\n");
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: 3777
diff changeset
91 if ok then
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: 3777
diff changeset
92 return pass;
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: 3777
diff changeset
93 end
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: 3777
diff changeset
94 end
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: 3777
diff changeset
95
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
96 local function show_yesno(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: 3777
diff changeset
97 io.write(prompt, " ");
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: 3777
diff changeset
98 local choice = getchar():lower();
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: 3777
diff changeset
99 io.write("\n");
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: 3777
diff changeset
100 if not choice:match("%a") then
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: 3777
diff changeset
101 choice = prompt:match("%[.-(%U).-%]$");
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: 3777
diff changeset
102 if not choice then return nil; end
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: 3777
diff changeset
103 end
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: 3777
diff changeset
104 return (choice == "y");
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: 3777
diff changeset
105 end
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: 3777
diff changeset
106
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
107 local function read_password()
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: 3777
diff changeset
108 local password;
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: 3777
diff changeset
109 while true do
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: 3777
diff changeset
110 io.write("Enter new password: ");
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: 3777
diff changeset
111 password = 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: 3777
diff changeset
112 if not password then
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: 3777
diff changeset
113 show_message("No password - cancelled");
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: 3777
diff changeset
114 return;
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: 3777
diff changeset
115 end
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: 3777
diff changeset
116 io.write("Retype new password: ");
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: 3777
diff changeset
117 if getpass() ~= password then
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: 3777
diff changeset
118 if not show_yesno [=[Passwords did not match, try again? [Y/n]]=] then
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: 3777
diff changeset
119 return;
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: 3777
diff changeset
120 end
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: 3777
diff changeset
121 else
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: 3777
diff changeset
122 break;
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: 3777
diff changeset
123 end
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: 3777
diff changeset
124 end
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: 3777
diff changeset
125 return password;
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: 3777
diff changeset
126 end
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: 3777
diff changeset
127
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
128 local function show_prompt(prompt)
4485
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
129 io.write(prompt, " ");
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
130 local line = getline();
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
131 line = line and line:gsub("\n$","");
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
132 return (line and #line > 0) and line or nil;
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
133 end
abfd27b59fa8 util.prosodyctl: Add getline() and show_prompt()
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
134
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: 3777
diff changeset
135 -- Server control
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
136 local function adduser(params)
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 local user, host, password = nodeprep(params.user), nameprep(params.host), params.password;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 if not user then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 return false, "invalid-username";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 elseif not host then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 return false, "invalid-hostname";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 end
3294
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
143
4501
eacc93e23f21 util.prosodyctl: Fix variable name clash introduced in 55ef5d83d00a (thanks chris)
Matthew Wild <mwild1@gmail.com>
parents: 4499
diff changeset
144 local host_session = prosody.hosts[host];
eacc93e23f21 util.prosodyctl: Fix variable name clash introduced in 55ef5d83d00a (thanks chris)
Matthew Wild <mwild1@gmail.com>
parents: 4499
diff changeset
145 if not host_session then
4499
55ef5d83d00a util.prosodyctl: In the register command, check that the virtual exists before proceeding.
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
146 return false, "no-such-host";
55ef5d83d00a util.prosodyctl: In the register command, check that the virtual exists before proceeding.
Kim Alvefur <zash@zash.se>
parents: 4335
diff changeset
147 end
5524
e9090966c803 util.prosodyctl: Initialize storagemanager on the host before initializing usermanager. This fixes brokenness when the auth provider opens the store on load (as they all do since eeea0eb2602a) (thanks nulani)
Matthew Wild <mwild1@gmail.com>
parents: 5379
diff changeset
148
e9090966c803 util.prosodyctl: Initialize storagemanager on the host before initializing usermanager. This fixes brokenness when the auth provider opens the store on load (as they all do since eeea0eb2602a) (thanks nulani)
Matthew Wild <mwild1@gmail.com>
parents: 5379
diff changeset
149 storagemanager.initialize_host(host);
4501
eacc93e23f21 util.prosodyctl: Fix variable name clash introduced in 55ef5d83d00a (thanks chris)
Matthew Wild <mwild1@gmail.com>
parents: 4499
diff changeset
150 local provider = host_session.users;
3294
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
151 if not(provider) or provider.name == "null" then
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
152 usermanager.initialize_host(host);
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
153 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
154
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3771
diff changeset
155 local ok, errmsg = usermanager.create_user(user, password, host);
1123
da7ff11a03ee util.prosodyctl: Return success status of usermanager.create_user()
Matthew Wild <mwild1@gmail.com>
parents: 1087
diff changeset
156 if not ok then
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
157 return false, errmsg or "creating-user-failed";
1123
da7ff11a03ee util.prosodyctl: Return success status of usermanager.create_user()
Matthew Wild <mwild1@gmail.com>
parents: 1087
diff changeset
158 end
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 return true;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
162 local function user_exists(params)
7262
751a4832adb4 util.prosodyctl: Remove unused variable [luacheck]
Matthew Wild <mwild1@gmail.com>
parents: 7259
diff changeset
163 local user, host = nodeprep(params.user), nameprep(params.host);
5524
e9090966c803 util.prosodyctl: Initialize storagemanager on the host before initializing usermanager. This fixes brokenness when the auth provider opens the store on load (as they all do since eeea0eb2602a) (thanks nulani)
Matthew Wild <mwild1@gmail.com>
parents: 5379
diff changeset
164
e9090966c803 util.prosodyctl: Initialize storagemanager on the host before initializing usermanager. This fixes brokenness when the auth provider opens the store on load (as they all do since eeea0eb2602a) (thanks nulani)
Matthew Wild <mwild1@gmail.com>
parents: 5379
diff changeset
165 storagemanager.initialize_host(host);
3711
2a1cfaf3ee61 util.prosodyctl: Prep JIDs before checking whether they exist (thanks tja)
Matthew Wild <mwild1@gmail.com>
parents: 3627
diff changeset
166 local provider = prosody.hosts[host].users;
3294
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
167 if not(provider) or provider.name == "null" then
3711
2a1cfaf3ee61 util.prosodyctl: Prep JIDs before checking whether they exist (thanks tja)
Matthew Wild <mwild1@gmail.com>
parents: 3627
diff changeset
168 usermanager.initialize_host(host);
3294
89dd67cc3689 util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
Matthew Wild <mwild1@gmail.com>
parents: 2925
diff changeset
169 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
170
3711
2a1cfaf3ee61 util.prosodyctl: Prep JIDs before checking whether they exist (thanks tja)
Matthew Wild <mwild1@gmail.com>
parents: 3627
diff changeset
171 return usermanager.user_exists(user, host);
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
173
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
174 local function passwd(params)
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
175 if not user_exists(params) then
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
176 return false, "no-such-user";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
177 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
178
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
179 return adduser(params);
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
180 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
181
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
182 local function deluser(params)
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
183 if not user_exists(params) then
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
184 return false, "no-such-user";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
185 end
5102
ae8a993b598d util.prosodyctl: Use usermanager to delete users instead of unsetting their password
Kim Alvefur <zash@zash.se>
parents: 5023
diff changeset
186 local user, host = nodeprep(params.user), nameprep(params.host);
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
187
5102
ae8a993b598d util.prosodyctl: Use usermanager to delete users instead of unsetting their password
Kim Alvefur <zash@zash.se>
parents: 5023
diff changeset
188 return usermanager.delete_user(user, host);
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
189 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
190
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
191 local function getpid()
5379
27de7cc94111 util.{prosodyctl,openssl}: More use of config sections removed
Kim Alvefur <zash@zash.se>
parents: 5102
diff changeset
192 local pidfile = config.get("*", "pidfile");
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
193 if not pidfile then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
194 return false, "no-pidfile";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
195 end
6356
fb1535328ac7 prosodyctl: Verify that 'pidfile' is a string, show friendly error otherwise
Kim Alvefur <zash@zash.se>
parents: 5524
diff changeset
196
fb1535328ac7 prosodyctl: Verify that 'pidfile' is a string, show friendly error otherwise
Kim Alvefur <zash@zash.se>
parents: 5524
diff changeset
197 if type(pidfile) ~= "string" then
fb1535328ac7 prosodyctl: Verify that 'pidfile' is a string, show friendly error otherwise
Kim Alvefur <zash@zash.se>
parents: 5524
diff changeset
198 return false, "invalid-pidfile";
fb1535328ac7 prosodyctl: Verify that 'pidfile' is a string, show friendly error otherwise
Kim Alvefur <zash@zash.se>
parents: 5524
diff changeset
199 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
200
8123
bd591c5fc1bf util.prosodyctl: Resolve possibly relative pidfile path (fixes inconsistency with mod_posix)
Kim Alvefur <zash@zash.se>
parents: 7457
diff changeset
201 pidfile = config.resolve_relative_path(prosody.paths.data, pidfile);
bd591c5fc1bf util.prosodyctl: Resolve possibly relative pidfile path (fixes inconsistency with mod_posix)
Kim Alvefur <zash@zash.se>
parents: 7457
diff changeset
202
8883
3f975bbfec3b util.prosodyctl: Rename variables for consistency (thanks Link Mauve)
Kim Alvefur <zash@zash.se>
parents: 8668
diff changeset
203 local modules_disabled = set.new(config.get("*", "modules_disabled"));
3f975bbfec3b util.prosodyctl: Rename variables for consistency (thanks Link Mauve)
Kim Alvefur <zash@zash.se>
parents: 8668
diff changeset
204 if prosody.platform ~= "posix" or modules_disabled:contains("posix") then
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: 3307
diff changeset
205 return false, "no-posix";
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: 3307
diff changeset
206 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
207
2796
1e287badd033 prosodyctl: Use mode r+ for opening the file so 1) it fails if the file doesn't exist 2) we have write access to lock it
Matthew Wild <mwild1@gmail.com>
parents: 2794
diff changeset
208 local file, err = io.open(pidfile, "r+");
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
209 if not file then
1515
9991329e6b67 util.prosodyctl: Fix undefined global access
Matthew Wild <mwild1@gmail.com>
parents: 1130
diff changeset
210 return false, "pidfile-read-failed", err;
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
211 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
212
2794
5f14cd94a563 util.prosodyctl: Report Prosody as not running if the pidfile isn't locked
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
213 local locked, err = lfs.lock(file, "w");
5f14cd94a563 util.prosodyctl: Report Prosody as not running if the pidfile isn't locked
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
214 if locked then
5f14cd94a563 util.prosodyctl: Report Prosody as not running if the pidfile isn't locked
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
215 file:close();
5f14cd94a563 util.prosodyctl: Report Prosody as not running if the pidfile isn't locked
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
216 return false, "pidfile-not-locked";
5f14cd94a563 util.prosodyctl: Report Prosody as not running if the pidfile isn't locked
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
217 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
218
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
219 local pid = tonumber(file:read("*a"));
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
220 file:close();
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
221
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
222 if not pid then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
223 return false, "invalid-pid";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
224 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
225
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
226 return true, pid;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
227 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
228
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
229 local function isrunning()
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
230 local ok, pid, err = getpid();
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
231 if not ok then
2794
5f14cd94a563 util.prosodyctl: Report Prosody as not running if the pidfile isn't locked
Matthew Wild <mwild1@gmail.com>
parents: 1522
diff changeset
232 if pid == "pidfile-read-failed" or pid == "pidfile-not-locked" then
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
233 -- Report as not running, since we can't open the pidfile
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
234 -- (it probably doesn't exist)
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
235 return true, false;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
236 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
237 return ok, pid;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
238 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
239 return true, signal.kill(pid, 0) == 0;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
240 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
241
9781
161411a41377 util.prosodyctl: Allow passing path to Lua runtime to the start() function
Kim Alvefur <zash@zash.se>
parents: 8883
diff changeset
242 local function start(source_dir, lua)
161411a41377 util.prosodyctl: Allow passing path to Lua runtime to the start() function
Kim Alvefur <zash@zash.se>
parents: 8883
diff changeset
243 lua = lua and lua .. " " or "";
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
244 local ok, ret = isrunning();
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
245 if not ok then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
246 return ok, ret;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
247 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
248 if ret then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
249 return false, "already-running";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
250 end
8668
31c5abd49dfe prosodyctl, util.prosodyctl: Pass source path as a parameter instead of global variable
Matthew Wild <mwild1@gmail.com>
parents: 8634
diff changeset
251 if not source_dir then
9781
161411a41377 util.prosodyctl: Allow passing path to Lua runtime to the start() function
Kim Alvefur <zash@zash.se>
parents: 8883
diff changeset
252 os.execute(lua .. "./prosody");
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
253 else
9781
161411a41377 util.prosodyctl: Allow passing path to Lua runtime to the start() function
Kim Alvefur <zash@zash.se>
parents: 8883
diff changeset
254 os.execute(lua .. source_dir.."/../../bin/prosody");
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
255 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
256 return true;
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
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
259 local function stop()
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
260 local ok, ret = isrunning();
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
261 if not ok then
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
262 return ok, ret;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
263 end
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
264 if not ret then
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
265 return false, "not-running";
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
266 end
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
267
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
268 local ok, pid = getpid()
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
269 if not ok then return false, pid; end
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
270
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
271 signal.kill(pid, signal.SIGTERM);
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
272 return true;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
273 end
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
274
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
275 local function reload()
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
276 local ok, ret = isrunning();
1087
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
277 if not ok then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
278 return ok, ret;
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
279 end
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
280 if not ret then
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
281 return false, "not-running";
5e9475bec571 prosodyctl, util.prosodyctl: New prosodyctl utility for managing Prosody servers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
282 end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
283
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
284 local ok, pid = getpid()
4335
3a2a01432b5c Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents: 4142
diff changeset
285 if not ok then return false, pid; end
6771
60957dd5b41b util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
Kim Alvefur <zash@zash.se>
parents: 6367
diff changeset
286
4335
3a2a01432b5c Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents: 4142
diff changeset
287 signal.kill(pid, signal.SIGHUP);
3a2a01432b5c Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents: 4142
diff changeset
288 return true;
3a2a01432b5c Add "reload" command to prosodyctl
Vladimir Protasov <eoranged@ya.ru>
parents: 4142
diff changeset
289 end
5023
dcc8e789df36 mod_admin_telnet, prosody, prosodyctl, ejabberd2prosody: Don't depend on modules setting globals
Florian Zeitz <florob@babelmonkeys.de>
parents: 4503
diff changeset
290
10167
f343ed1f02fd util.prosodyctl: Created the helper function get_path_custom_plugins
João Duarte <jvsDuarte08@gmail.com>
parents: 10158
diff changeset
291 local function get_path_custom_plugins(plugin_paths)
10191
395ce57dccdf util.prosodyctl: Changed a comment
João Duarte <jvsDuarte08@gmail.com>
parents: 10189
diff changeset
292 -- I'm considering that the custom plugins' path is the first one at prosody.paths.plugins
10167
f343ed1f02fd util.prosodyctl: Created the helper function get_path_custom_plugins
João Duarte <jvsDuarte08@gmail.com>
parents: 10158
diff changeset
293 -- luacheck: ignore 512
f343ed1f02fd util.prosodyctl: Created the helper function get_path_custom_plugins
João Duarte <jvsDuarte08@gmail.com>
parents: 10158
diff changeset
294 for path in plugin_paths:gmatch("[^;]+") do
10180
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
295 return path;
10167
f343ed1f02fd util.prosodyctl: Created the helper function get_path_custom_plugins
João Duarte <jvsDuarte08@gmail.com>
parents: 10158
diff changeset
296 end
f343ed1f02fd util.prosodyctl: Created the helper function get_path_custom_plugins
João Duarte <jvsDuarte08@gmail.com>
parents: 10158
diff changeset
297 end
f343ed1f02fd util.prosodyctl: Created the helper function get_path_custom_plugins
João Duarte <jvsDuarte08@gmail.com>
parents: 10158
diff changeset
298
10180
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
299 local function check_flags(arg)
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
300 local flag = "--tree=";
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
301 -- There might not be any argument when the list command is calling this function
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
302 if arg[1] and arg[1]:sub(1, #flag) == flag then
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
303 local dir = arg[1]:match("=(.+)$")
10189
d311168c71d1 util.prosodyctl: The check_flags function now considers that a module, if given, is specified at the penultimate argument it receives
João Duarte <jvsDuarte08@gmail.com>
parents: 10187
diff changeset
304 return true, arg[#arg-1], dir;
10180
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
305 end
10189
d311168c71d1 util.prosodyctl: The check_flags function now considers that a module, if given, is specified at the penultimate argument it receives
João Duarte <jvsDuarte08@gmail.com>
parents: 10187
diff changeset
306 return false, arg[#arg-1];
10180
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
307 end
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
308
10181
c7d5cd766533 util.prosodyctl: Added the call_luarocks function
João Duarte <jvsDuarte08@gmail.com>
parents: 10180
diff changeset
309 local function call_luarocks(operation, mod, dir)
10183
5eba710e33f9 util.prosodyctl: Function now differentiates its output, depending if it is being called by install or remove
João Duarte <jvsDuarte08@gmail.com>
parents: 10181
diff changeset
310 if operation == "install" then
10181
c7d5cd766533 util.prosodyctl: Added the call_luarocks function
João Duarte <jvsDuarte08@gmail.com>
parents: 10180
diff changeset
311 show_message("Installing %s at %s", mod, dir);
10183
5eba710e33f9 util.prosodyctl: Function now differentiates its output, depending if it is being called by install or remove
João Duarte <jvsDuarte08@gmail.com>
parents: 10181
diff changeset
312 elseif operation == "remove" then
5eba710e33f9 util.prosodyctl: Function now differentiates its output, depending if it is being called by install or remove
João Duarte <jvsDuarte08@gmail.com>
parents: 10181
diff changeset
313 show_message("Removing %s from %s", mod, dir);
5eba710e33f9 util.prosodyctl: Function now differentiates its output, depending if it is being called by install or remove
João Duarte <jvsDuarte08@gmail.com>
parents: 10181
diff changeset
314 end
10185
02d8f475a96d util.prosodyctl: call_luarocks function is now compatible with the list command
João Duarte <jvsDuarte08@gmail.com>
parents: 10183
diff changeset
315 if operation == "list" then
02d8f475a96d util.prosodyctl: call_luarocks function is now compatible with the list command
João Duarte <jvsDuarte08@gmail.com>
parents: 10183
diff changeset
316 os.execute("luarocks list --tree='"..dir.."'")
02d8f475a96d util.prosodyctl: call_luarocks function is now compatible with the list command
João Duarte <jvsDuarte08@gmail.com>
parents: 10183
diff changeset
317 else
02d8f475a96d util.prosodyctl: call_luarocks function is now compatible with the list command
João Duarte <jvsDuarte08@gmail.com>
parents: 10183
diff changeset
318 os.execute("luarocks --tree='"..dir.."' --server='http://localhost/' "..operation.." "..mod);
02d8f475a96d util.prosodyctl: call_luarocks function is now compatible with the list command
João Duarte <jvsDuarte08@gmail.com>
parents: 10183
diff changeset
319 end
10183
5eba710e33f9 util.prosodyctl: Function now differentiates its output, depending if it is being called by install or remove
João Duarte <jvsDuarte08@gmail.com>
parents: 10181
diff changeset
320 if operation == "install" then
10181
c7d5cd766533 util.prosodyctl: Added the call_luarocks function
João Duarte <jvsDuarte08@gmail.com>
parents: 10180
diff changeset
321 show_module_configuration_help(mod);
10183
5eba710e33f9 util.prosodyctl: Function now differentiates its output, depending if it is being called by install or remove
João Duarte <jvsDuarte08@gmail.com>
parents: 10181
diff changeset
322 end
10181
c7d5cd766533 util.prosodyctl: Added the call_luarocks function
João Duarte <jvsDuarte08@gmail.com>
parents: 10180
diff changeset
323 end
c7d5cd766533 util.prosodyctl: Added the call_luarocks function
João Duarte <jvsDuarte08@gmail.com>
parents: 10180
diff changeset
324
10187
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
325 local function execute_command(arg)
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
326 local operation = arg[#arg]
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
327 local tree, mod, dir = check_flags(arg);
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
328 if tree then
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
329 call_luarocks(operation, mod, dir);
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
330 return 0;
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
331 else
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
332 dir = get_path_custom_plugins(prosody.paths.plugins);
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
333 call_luarocks(operation, mod, dir);
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
334 return 0;
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
335 end
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
336 end
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
337
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
338 return {
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
339 show_message = show_message;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
340 show_warning = show_message;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
341 show_usage = show_usage;
10152
7e9c30eab11e util.prosodyctl: Added the show_module_configuration_help function
João Duarte <jvsDuarte08@gmail.com>
parents: 10148
diff changeset
342 show_module_configuration_help = show_module_configuration_help;
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
343 getchar = getchar;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
344 getline = getline;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
345 getpass = getpass;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
346 show_yesno = show_yesno;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
347 read_password = read_password;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
348 show_prompt = show_prompt;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
349 adduser = adduser;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
350 user_exists = user_exists;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
351 passwd = passwd;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
352 deluser = deluser;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
353 getpid = getpid;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
354 isrunning = isrunning;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
355 start = start;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
356 stop = stop;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
357 reload = reload;
10167
f343ed1f02fd util.prosodyctl: Created the helper function get_path_custom_plugins
João Duarte <jvsDuarte08@gmail.com>
parents: 10158
diff changeset
358 get_path_custom_plugins = get_path_custom_plugins;
10180
152604d54732 util.prosodyctl: Added the check_flags function
João Duarte <jvsDuarte08@gmail.com>
parents: 10167
diff changeset
359 check_flags = check_flags;
10181
c7d5cd766533 util.prosodyctl: Added the call_luarocks function
João Duarte <jvsDuarte08@gmail.com>
parents: 10180
diff changeset
360 call_luarocks = call_luarocks;
10187
85725e11c509 util.prosodyctl: Added the execute_command function
João Duarte <jvsDuarte08@gmail.com>
parents: 10185
diff changeset
361 execute_command = execute_command;
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 6771
diff changeset
362 };