How can I run an a script attached to the ejabberd process?

I'm trying to set up an automated way of provisioning a new ejabberd server onto a cluster. I want to run things like mnesia:change_config(extra_db_nodes, ...) and mnesia:change_table_copy_type(table, node(), disc_copies) etc. all in a little script the first time the ejabberd server comes up. I've been running them manually in the debug console, but that's... annoying. I'm sure there's some obvious way of just running a script full of these commands that I'm missing because I'm an erlang/ejabberd noob. Any suggestions?

Thanks!
Brandon

One idea. It may be long to

One idea. It may be long to do the first day, but later it allows you to easily repeat whenever you want. And also will train you to implement other admin tasks in the feature.

You can use mod_admin_extra.erl as an example for this:

1. write a new module called mod_cluster_admin.erl
2. in it, define ejabberd commands like add_to_cluster
3. the related erlang function just has to run what you already run in the debug console

When you install a new ejabberd node, copy mod_cluster_admin.beam, and enable that module in ejabberd.cfg. Then start ejabberd, and run "ejabberdctl add_to_cluster" or whatever.

Syndicate content