This used to work:
#!/bin/sh
export NODE=ejabberd
export HOST=localhost
export VERSION=1.1.2
# Main directories
export ROOTDIR=/opt/ejabberd-1.1.2
export BINDIR=$ROOTDIR/bin
export PROGNAME=$BINDIR/erl
export EMU=beam
export HOME=$BINDIR
export LD_LIBRARY_PATH=$ROOTDIR/lib/linux-x86/ #hard code vs. below
$BINDIR/erlexec \
-noinput \
-sname ejabberdctl@$HOST \
-s ejabberd_ctl -extra $NODE@$HOST user-resources $@
However, I'm on a new machine and on version 2.0.2.
Changing hte version numbers from 1.1.2 to 2.0.2 did not do the trick.
I used to call this from cgi (linux/apache) and it returned all active resources for the "user server".
Now under version 2.0.2, doesn't work anymore. Note: I provided a .erlang.cookie for the apache user.
I did notice that the ejabberdctl script and erl script is different across these versions --- ejabberd-ctl vs. ejabberdctl in -sname, for example.
How can I update this? It is handy for a very quick presence check.
Try ejabberdctl
I didn't check in detail your script. I think you can use the included ejabberdctl script instead of it.
I tried this:
Of course, in your case the ejabberdctl script may be in a different location, and may require or not to be root.
limited ejabberdctl function from cgi
1. ejabberdctl has way too many functions to make it available to any user. Therefore, intentionally limiting the call to the user-resources function as a presence check
2. The above script was called from a perl script cgi apache as the apache user.
3. Don't want to run from cgi as root.
ejabberdctl user-resources user server works in 2.0.2 as advertised, but, that's not the point or the issue.
This was just a handy way for processes (not IM stuff) to check for user/resource presence without having to log in, subscribe, etc., or interrogating the database (mnesia).
Once a user/resource was identified as present, then, and only then, would processes be applied to that user/resource.
Looked into XML-RPC methods - seem too complicated. If I could update the script to run with newer versions of the server, that would be great.
What is missing from the script?
Example system call using regular user
Ah, ok, I didn't notice the requirement of executing the script with a regular user, not root.
I tried this using ejabberd trunk SVN. In your system probably you will have different ebin path and cookie path.
And in the ejabberd log files i see:
Now i provide the cookie: