Software / code / prosody
Comparison
prosodyctl @ 10182:bb7d537e6fba
prosodyctl: Rewrote the install command, to make it more cleaner
| author | João Duarte <jvsDuarte08@gmail.com> |
|---|---|
| date | Wed, 31 Jul 2019 07:31:03 -0700 |
| parent | 10179:2364e9533d0e |
| child | 10184:5655cd9fc8e9 |
comparison
equal
deleted
inserted
replaced
| 10181:c7d5cd766533 | 10182:bb7d537e6fba |
|---|---|
| 74 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; | 74 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; |
| 75 local show_usage = prosodyctl.show_usage; | 75 local show_usage = prosodyctl.show_usage; |
| 76 local show_yesno = prosodyctl.show_yesno; | 76 local show_yesno = prosodyctl.show_yesno; |
| 77 local show_prompt = prosodyctl.show_prompt; | 77 local show_prompt = prosodyctl.show_prompt; |
| 78 local read_password = prosodyctl.read_password; | 78 local read_password = prosodyctl.read_password; |
| 79 local show_module_configuration_help = prosodyctl.show_module_configuration_help; | 79 local check_flags = prosodyctl.check_flags; |
| 80 local call_luarocks = prosodyctl.call_luarocks; | |
| 81 local get_path_custom_plugins = prosodyctl.get_path_custom_plugins; | |
| 80 | 82 |
| 81 local jid_split = require "util.jid".prepped_split; | 83 local jid_split = require "util.jid".prepped_split; |
| 82 | 84 |
| 83 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; | 85 local prosodyctl_timeout = (configmanager.get("*", "prosodyctl_timeout") or 5) * 2; |
| 84 ----------------------- | 86 ----------------------- |
| 88 function commands.install(arg) | 90 function commands.install(arg) |
| 89 if arg[1] == "--help" then | 91 if arg[1] == "--help" then |
| 90 show_usage([[install]], [[Installs a prosody/luarocks plugin]]); | 92 show_usage([[install]], [[Installs a prosody/luarocks plugin]]); |
| 91 return 1; | 93 return 1; |
| 92 end | 94 end |
| 93 local installer_plugin_path = prosodyctl.get_path_custom_plugins(prosody.paths.plugins) | 95 local operation = "install"; |
| 94 -- I'm considering this optional flag comes first | 96 local tree, mod, dir = check_flags(arg); |
| 95 local flag = "--tree=" | 97 if tree then |
| 96 if arg[1] and arg[1]:sub(1, #flag) == flag then | 98 call_luarocks(operation, mod, dir); |
| 97 local dir = arg[1]:match("=(.+)$") | |
| 98 show_message("Installing module %s at %s", arg[2], dir) | |
| 99 os.execute("luarocks --tree='"..dir.."' --server='http://localhost/' install "..arg[2]) | |
| 100 show_module_configuration_help(arg[2]); | |
| 101 return 0; | 99 return 0; |
| 102 else | 100 else |
| 103 show_message("Installing module %s at %s", arg[1], installer_plugin_path) | 101 dir = get_path_custom_plugins(prosody.paths.plugins); |
| 104 -- I've build a local server to upload some new rockspecs, like mod_smacks'. We can replace this server by one from | 102 call_luarocks(operation, mod, dir); |
| 105 -- prosody's, where we can oficially disbrute rocks/rockspecs for all modules | |
| 106 os.execute("luarocks --tree='"..installer_plugin_path.."' --server='http://localhost/' install "..arg[1]) | |
| 107 show_module_configuration_help(arg[1]); | |
| 108 return 0; | 103 return 0; |
| 109 end | 104 end |
| 110 end | 105 end |
| 111 | 106 |
| 112 function commands.remove(arg) | 107 function commands.remove(arg) |