Jabber Commercial Version

I need to convert a commercial installation of Jabber, and it's spool directory is very different from a Jabber 1.4. I've got a script that I can use to create the users by parsing the XML in the spool directory and adding the user through ejabberdctl. The roster is what I am having a difficult time with. In the web based utility, as an administrator I can modify a roster (html://localhost:5280/admin/user//roster/) Adding the rosters for 3500+ users by hand isn't a job I long for. Is there a way to administrate rosters from the commandline? I've tried dumping the database to a text file, but uploading that same file doesn't seem to work either.

Thanks,

Rich

patch to add roster items on command line

Is there a way to administrate rosters from the commandline?

Not in current ejabberd.

You can try ejabberdctl-extra, it adds a new option to ejabberd_ctl, so you can make something like:

ejabberd_ctl mynode@mymachine add-rosteritem peter mike server.com MiKe Employees both
And it adds mike@server.com to your local user 'peter' roster, with nick 'MiKe', on the group 'Employees' and subscription type 'both'.

Note that it only adds one roster item. You will probably need to add the other roster item if he's a local user: add peter@myserver.com to your local user mike. This tool does NOT allow spaces in names, so you must ensure there're no groups or nicks with spaces.

Give it a try

WORKED GREAT!! Here is the TCL script I used to convert from the Commercial version of Jabber:
#!/usr/bin/tclsh

package require xml
# XML Package helps get the password
# This is the directory structure of our Commercial Jabber server.
# 
# spool/jabber:component:tc:roomlist
# spool/jabber:component:tc:roomstate
# spool/jabber:iq:auth
# spool/jabber:iq:auth:0k
# spool/jabber:iq:last
# spool/jabber:iq:register
# spool/jabber:iq:roster
# spool/jabber:x:offline
# spool/jabberim:prefs
# spool/jabberim:textconferencing

set timeout -1
set dir "/"
set server ""
# If a user hasn't logged in for 180days the login is discarded.
set cuttime [expr [clock seconds] - (180*24*60*60)]
proc cdata {data args} {
    global passwd
    set passwd $data
}
# Open a pipe to ls. TCL treats this pipe like it would a file for 
# easy reading of the output.
set dirlist [open "|ls $dir/jabber:iq:auth/"]
while {[gets $dirlist dname] >=0} {
        if {[file exists $dir/jabber:iq:last/$dname]} {
                file stat $dir/jabber:iq:last/$dname ftime
        } else {
                continue
        }
 # Ignore user who hasn't logged in for 180 days
        if {$ftime(mtime) <= $cuttime} {continue}
 # For some reason Jabber puts a '.' at the end of each file, need to trim that off.
        set usrname [string trimright $dname "."]
 # process the xml file to get the passwd.
        set parser [::xml::parser -characterdatacommand cdata]
        set ch [open $dir/jabber:iq:auth/$dname r]
        fconfigure $ch -encoding shiftjis
        $parser parse [read $ch]
        close $ch
 # Register the user
        set status [catch {exec sudo ejabberdctl register $usrname $passwd} result]
        puts stdout "Adding $usrname: Register Result $result, Status $status"
        if {[file exists $dir/jabber:iq:roster/$dname]} {
  # xml for the roster was very convoluted... used Unix commands to parse.
                set pipe [open "|cat $dir/jabber:iq:roster/$dname | xml2 | egrep \"jid|name\" | cut -f2 -d \"=\""]
        } else {
                continue
        }
        while {[gets $pipe line]>=0} {
                gets $pipe name
                set line [lindex [split $line "@"] 0]
  # add user's roster.  I added them all to the "Jabber" group regardless of 
  # where the user had it before. You could probably spend a little time and
  # parse the xml better.
                set status [catch {exec sudo ejabberdctl add-roster $usrname $line $server \"$name\" Jabber both} result]
                puts stdout "\tejabberdctl add-roster $usrname $line $server \"$name\" Jabber both"
        }
        close $pipe
}

If you allow it, this script

If you allow it, this script can be maybe included in the ejabberd distribution in the tools directory...in that case create a bugzilla entry or send it to the mailing list. :-)

--
sander

RE:patch to add roster items on command line

We were able to add 6000+ registered users from the commercial version of Jabber into eJabber, and so far things are running fairly well. The only problem is that the rosters show the users configured as being "Not Authorized." Is there something we can do to the database to set these as "authorized?" There are some clients such as Exodus that doesn't handle this very well.

Thanks for all your help,

Rich

this experimental patch...

The patch worked great and the rosters were added just fine. The only problem is that the Pending field in the database states that it's 'out' so the users rosters all appear to be pending. Is there a way to change this so that the Pending field is set to 'none'?

I really appreciate the help you all have provided so far. eJabber is an awesome server, and we love it compared to the commercial version of Jabber.

Thanks,
Rich

You're right, on ejabberd_ctl

You're right, on ejabberd_ctl.erl, the line that says

out,          % ask: out=send request, in=somebody requests you, none
should say
none,         % ask: out=send request, in=somebody requests you, none
I've updated my patch.

You can do this:

  1. Modify manually that line on your previously patched source code
  2. Compile ejabberd
  3. Restart ejabberd
  4. Run again the same commands you ran to add the roster items the last time
  5. When users reconnect they will see it right

I've verified that you will not get duplicated roster items. Probably the new roster items replace the old ones, so if your users modified them they'll lose the changes (nickname and group).

Thanks... That worked. VCard?

THanks that worked!!!

Rich

Syndicate content