Little Tricks

List of Users and their Passwords
To generate a file that lists registered users on your server, and their passwords, you have to perform next steps:
  1. Dump the database to a text file:
    ejabberd_ctl ejabberd3@localhost dump /tmp/edump.txt
  2. Filter that text file to get only the information about registered users:
    cat /tmp/edump.txt | grep "{passwd,{" >/tmp/epasstmp.txt
    In that temporary file, a line represents the information about one registered user. The format of that line is:
    {passwd,{"USER","VIRTUAL-HOST"},"PASSWORD"}.
  3. Convert the temporary file from ejabberd's internal format to the format you prefer. For example, the command
    sed -e 's/{passwd,{"//g;s/","/ /g;s/"},"/ /g;s/"}.//g' /tmp/epasstmp.txt >/tmp/passwd.txt
    will clean the formatting of each line in a way that the username, the hostname, and the password are separated by spaces. The resulting output will be stored in /tmp/passwd.txt and it will look like this:
    admin example.net 52I6jhRTRFtUpGt3
    yozhik example.com PamoaobS
    tux example.org P1mr7ujg
    beastie example.org dTv6LqY3
    hexley example.org 0qWD9cR8
Attach an Erlang Shell to an Already Running ejabberd Process

ejabberd 2.0.0 and higher provide a simple way to connect to a running ejabberd node. Just execute this: ejabberdctl debug

In case you want to know the details: If you started ejabberd in daemon mode (detached, in background, headless), and if you want to execute a command, you can attach an Erlang shell to the running ejabberd process node. Start a new Erlang shell to connect to 'ejabberd@node2.machine2.com':

erl -sname node1 -remsh node2@machine2.example.org
Erlang (BEAM) emulator version 5.4.8 [source] [hipe]

Eshell V5.4.8  (abort with ^G)
(node2@machine2.example.org)1>
To close the attached shell without suddenly stopping the whole ejabberd server, press Ctrl+C, Ctrl+C. More information: Interconnecting Erlang nodes.

Reload ACL and Shapers from Configuration File
Warning: this trick only updates ACL and Shapers. Listening ports, virtual hosts, modules and all major options will not change. To reload the configuration file ejabberd.cfg (loading another configuration file is also possible) without restarting ejabberd, you need to open an Erlang console on the ejabberd node to enter this command:
ejabberd_config:load_file("/home/ejabberd/ejabberd.cfg").
However, it is better to use the web interface or discovery administration if possible.
Reload Module via an Erlang Console
It is possible to reload some ejabberd modules from disk without restarting ejabberd. This allows you to modify source files (.erl) and reload them without stopping the service. Remark that reloading modules is also possible via the web interface since ejabberd 0.9.1. Open an Erlang console on the ejabberd node and type this command:
c(mod_version).
Replace 'mod_version' with the name of the file you want to reload.
If you do not want to compile, but just want to reload the .beam file, use this command instead:
l(mod_version).

Related Links

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

start will not recall??

Hi I try the reload module function. I found that new function did work! But the module's load function doesn't re-call the start_link, start and init function. Due to there are some options inside the ejabberd.yml that I need to initial the module. Should I do something more to reload all module's option back? Or it just add it supervisor & init automatically?

Thank you~~

Changing loglevel without restart

If you need change loglevel for debug purposes without restart you can use ejabberdctl debug console.

For getting information about loglevel

(ejabberd@utopia)1> ejabberd_logger:get().
{3,warning,"Warning"}

For setting loglevel

(ejabberd@utopia)2> ejabberd_logger:set(4).
{module,lager}

Use ejabberdctl debug to debug Already Running ejabberd Process

I can't find an "edit" button for this page, but:

Attach an Erlang Shell to an Already Running ejabberd Process

I couldn't get the suggested erl invocation to work, but I had success with the following command:

$ sudo ejabberdctl debug
--------------------------------------------------------------------

IMPORTANT: we will attempt to attach an INTERACTIVE shell
to an already running ejabberd node.
If an ERROR is printed, it means the connection was not successful.
You can interact with the ejabberd node if you know how to use it.
Please be extremely cautious with your actions,
and exit immediately if you are not completely sure.

To detach this shell from ejabberd, press:
  control+c, control+c

--------------------------------------------------------------------
To bypass permanently this warning, add to ejabberdctl.cfg the line:
  EJABBERD_BYPASS_WARNINGS=true
Press any key to continue

Erlang R14A (erts-5.8) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:true]

Eshell V5.8  (abort with ^G)
(ejabberd@hostname)1> 

ejabberd user or erlang cookie

If a user attaching the shell differs from a user ejabberd is running as, -setcookie might be needed:

erl -sname node1 -setcookie $(cat /var/lib/ejabberd/.erlang.cookie) -remsh node2@machine2.example.org

When using the eJabberd Web interface

When using the eJabberd Web interface, restarting a module do not reload the new code (it only reloads the currently loaded module). Thus, to install a new freshly compiled version of a module, install it manually in eJabberd's ebin directory, use the Erlang console to reload it (i.e. by typing l(mod_version).) and use the Web console to restart the module.

On the reloading of modules

Note: c(mod_version). will reload the module, but will not call start/2 or stop/2. If you change your module's hooks, you'll need to do the following:

  1. Remove the beam file. Mine was located in /var/lib/ejabberd/ebin/mod_version.beam
  2. cd to the src directory
  3. Relaunch ejabberd

Changes to any other function will get picked up if you run mod_version, so in practice this isn't a very big deal, but know this quirk exists.

Syndicate content