[ejabberdctl] create_rooms_file: file format

Hi all,
i'm trying to create MUC rooms using the ejabberdctl create_rooms_file command, but in the documentation there is no evidence of the file format... Has anyone ever used this command? Which is the file format?

Thank You in advance! :)
Sergio

While looking for your

While looking for your question, I noticed a bug in ejabberd that probably breaks that command. I've committed a fix that you probably need to apply to use it:
https://github.com/processone/ejabberd/commit/5e723bc90e9701c7112d741558...

Now regarding your question: simply put room JIDs one per line, as explained in

$ ejabberdctl help create_rooms_file
  Command Name: create_rooms_file
  Arguments: file::string
  Returns: res::rescode
  Tags:  muc
  Description:  Create the rooms indicated in file
 Provide one room JID per line. Rooms will be created after restart.

Example:

$ cat /tmp/rooms.txt 
room1@conference.localhost
room2@conference.localhost
room3@conference.localhost

$ ejabberdctl create_rooms_file /tmp/rooms.txt
Creating room room3@conference.localhost
Creating room room2@conference.localhost
Creating room room1@conference.localhost

Remember that the rooms will be fully accessible only after you restart ejabberd (or at least the mod_muc service, using WebAdmin for example to restart that module).

Hi, thanks for the response!

Hi,
thanks for the response! :)
I applied the fix, but I still have problems.

File:

# less ejabberd_muc_rooms 
test@conference.localhost

Command:

# ejabberdctl create_rooms_file ejabberd_muc_rooms 
Problem 'error {badmatch,{error,enoent}}' occurred executing the command.
Stacktrace: [{mod_muc_admin,create_rooms_file,1,
                            [{file,"src/mod_muc_admin.erl"},{line,554}]},
             {ejabberd_ctl,call_command,4,
                           [{file,"src/ejabberd_ctl.erl"},{line,329}]},
             {ejabberd_ctl,try_call_command,4,
                           [{file,"src/ejabberd_ctl.erl"},{line,298}]},
             {ejabberd_ctl,process2,4,
                           [{file,"src/ejabberd_ctl.erl"},{line,247}]},
             {ejabberd_ctl,process,2,
                           [{file,"src/ejabberd_ctl.erl"},{line,225}]},
             {rpc,'-handle_call_call/6-fun-0-',5,
                  [{file,"rpc.erl"},{line,187}]}]

Where am i wrong? Maybe i've lost some module's options...

Looking at

Looking at http://erlang.org/doc/man/file.html
> enoent
> The directory does not exist.

The best is to provide the filename with full path, because the ejabberdctl script is not running in .

Notice that in my example call I provided the full path.

Hi, sorry for the delay!

Hi, sorry for the delay! Thank you so much for the response!

I've tried using the full path (adding also the txt extension) and changing the file content (single row with no empty trailer row, single row with trailer row, multiple rows with trailer row, and multiple rows without trailer row), but it seems to break on the first row of the file:

# ejabberdctl create_rooms_file /root/ejabberd_muc_rooms.txt 
Problem 'error function_clause' occurred executing the command.
Stacktrace: [{io_lib_fread,fread_skip_latin1_nonwhite,
                           [<<"room1@conference.localhost\n">>,0,[]],
                           [{file,"io_lib_fread.erl"},{line,399}]},
             {io_lib_fread,fread1,7,[{file,"io_lib_fread.erl"},{line,229}]},
             {mod_muc_admin,read_room,1,
                            [{file,"src/mod_muc_admin.erl"},{line,535}]},
             {mod_muc_admin,create_rooms_file,1,
                            [{file,"src/mod_muc_admin.erl"},{line,555}]},
             {ejabberd_ctl,call_command,4,
                           [{file,"src/ejabberd_ctl.erl"},{line,329}]},
             {ejabberd_ctl,try_call_command,4,
                           [{file,"src/ejabberd_ctl.erl"},{line,298}]},
             {ejabberd_ctl,process2,4,
                           [{file,"src/ejabberd_ctl.erl"},{line,247}]},
             {ejabberd_ctl,process,2,
                           [{file,"src/ejabberd_ctl.erl"},{line,225}]}]

I googled for the "fread_skip_latin1_nonwhite" error, but i didn't find anything interesting (but i'm not used to erlang, so maybe i searched for the wrong things!). Any suggestion?
Currently i'm using eJabberd 16.09.50 downloaded from the github's head after your commit.

That's exactly the error that

That's exactly the error that I got before applying the fix. It seems as if you got an older version (previous to the fix), or that you are not starting the fixed version that you just compiled.

Check if the path where you installed the fixed beam file is where ejabberd is reading it. For that you can attach an erlang shell to your node with "ejabberdctl debug", and execute in it:

(ejabberd@localhost)1> code:is_loaded(mod_muc_admin).
{file,"/lib/ejabberd-16.09.51/ebin/mod_muc_admin.beam"}

Hi! I'm so sorry for the huge

Hi!
I'm so sorry for the huge delay... :( Anyway, today I have updated my eJabberd installation to version 17.01 and the command

ejabberdctl create_rooms_file /root/ejabberd_muc_rooms.txt

works correctly as is returns a:

Creating room room1@conference.localhost

message and after the eJabberd server restart the room is created on the server.
The only thing i noticed is that the "ejabberd_muc_rooms.txt" file should not contain empty lines, otherwise the command will fail.

I think it could be usefull to update the documentation (https://docs.ejabberd.im/admin/ejabberdctl/muc-admin/#toc_6) with the following information:

      the filename should be provided with full path
      the file should not contain empty lines
      the eJabberd server should be restarted after the execution of the "create_rooms_file" command

Thank you so much for helping me! :)

Better than that, I've added

Better than that, I've added support for non-JID lines (for example empty lines) in the command. It will be supported in next release.

https://github.com/processone/ejabberd/commit/b2a2e0f135f54a562c7157066d...

Good! Anyway i think that the

Good! Anyway i think that the documentation should be updated, just to avoid other users/developers to digg into the internet in order to find the file format! :)

Thanks! Bye

It is already documented: $

It is already documented:

$ ejabberdctl create_rooms_file

Error: the command "create_rooms_file" requires 1 more argument.

  Command Name: create_rooms_file

  Arguments: file::string
             
  Returns: res::rescode

  Tags:  muc

  Description:  Create the rooms indicated in file

 Provide one room JID per line. Rooms will be created after restart.

Syndicate content