Software /
code /
prosody
Comparison
prosodyctl @ 4324:5e7cba840409
prosodyctl: Add 'about' command to list Prosody version, directories, and various other stuff
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 27 Jun 2011 12:02:50 +0100 |
parent | 4167:9c60cc8dc142 |
child | 4331:9c45858e3208 |
comparison
equal
deleted
inserted
replaced
4323:53f3c3001499 | 4324:5e7cba840409 |
---|---|
483 | 483 |
484 commands.stop(arg); | 484 commands.stop(arg); |
485 return commands.start(arg); | 485 return commands.start(arg); |
486 end | 486 end |
487 | 487 |
488 function commands.about(arg) | |
489 require "util.array"; | |
490 require "util.iterators"; | |
491 | |
492 print("Prosody "..(prosody.version or "(unknown version)")); | |
493 print(""); | |
494 print("# Prosody directories"); | |
495 print("Data directory: ", CFG_DATADIR or "./"); | |
496 print("Plugin directory:", CFG_PLUGINDIR or "./"); | |
497 print("Config directory:", CFG_CONFIGDIR or "./"); | |
498 print("Source directory:", CFG_SOURCEDIR or "./"); | |
499 print(""); | |
500 print("# Lua environment"); | |
501 print("Lua version: ", _G._VERSION); | |
502 print(""); | |
503 print("Lua module search paths:"); | |
504 for path in package.path:gmatch("[^;]+") do | |
505 print(" "..path); | |
506 end | |
507 print(""); | |
508 print("Lua C module search paths:"); | |
509 for path in package.cpath:gmatch("[^;]+") do | |
510 print(" "..path); | |
511 end | |
512 print(""); | |
513 print("# Lua module versions"); | |
514 local module_versions, longest_name = {}, 8; | |
515 for name, module in pairs(package.loaded) do | |
516 if type(module) == "table" and rawget(module, "_VERSION") | |
517 and name ~= "_G" and not name:match("%.") then | |
518 if #name > longest_name then | |
519 longest_name = #name; | |
520 end | |
521 module_versions[name] = module._VERSION; | |
522 end | |
523 end | |
524 local sorted_keys = array.collect(keys(module_versions)):sort(); | |
525 for _, name in ipairs(array.collect(keys(module_versions)):sort()) do | |
526 print(name..":"..string.rep(" ", longest_name-#name), module_versions[name]); | |
527 end | |
528 print(""); | |
529 end | |
530 | |
488 -- ejabberdctl compatibility | 531 -- ejabberdctl compatibility |
489 | 532 |
490 function commands.register(arg) | 533 function commands.register(arg) |
491 local user, host, password = unpack(arg); | 534 local user, host, password = unpack(arg); |
492 if (not (user and host)) or arg[1] == "--help" then | 535 if (not (user and host)) or arg[1] == "--help" then |
586 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); | 629 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
587 print(""); | 630 print(""); |
588 print("Where COMMAND may be one of:\n"); | 631 print("Where COMMAND may be one of:\n"); |
589 | 632 |
590 local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; | 633 local hidden_commands = require "util.set".new{ "register", "unregister", "addplugin" }; |
591 local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart" }; | 634 local commands_order = { "adduser", "passwd", "deluser", "start", "stop", "restart", "about" }; |
592 | 635 |
593 local done = {}; | 636 local done = {}; |
594 | 637 |
595 for _, command_name in ipairs(commands_order) do | 638 for _, command_name in ipairs(commands_order) do |
596 local command = commands[command_name]; | 639 local command = commands[command_name]; |