it doesnt work. says something like this:
Connection closed by foreign host.
the cat sequence completely ignored?
Bye Markus
[Fri 10:35] markus (email) added this line to fetch some more contacts:
xmlfilter -nl $jabberdir/$server/$currentuser.xml |grep "> $jabberdir/roaster-info/lastuser.tmp
after sort do a |uniq> :) investigating more. with
#!/bin/sh
nc bail.hn.org 5222
[Fri 10:38] markus (email) http://bail.hn.org/u/mark/comment.txt
[2004-11-09 14:22 CST] Brad Barnett
xmlfilter? Where in tarnation do you find that. I can't find it in Debian (at least, not in any sane search). I can't find it with Google either.
BAH!
[2004-11-09 14:25 CST] Brad Barnett
BAH :P
Ok, so it's in this respository!
Heh. For everyone else, you now know.
#!/bin/bash
# Csaba Wiesz
# The script breaks the user.xml files line by line and greps the contacts in the user's
# roster and compares it to the list of all users and sends the difference to the user.
# Needs the "xmlfilter" script: http://scriptrepo.jabberstudio.org/xmlfilter/
# I have to mention that ther can be problems with larger number of users, as the data sent
# can be too much for the karma settings. Therefore I put some sleep lines to make the
# scripts slower.
# 2003-05-04 maqi - fixed: JIDs were case sensitive
### Setting some initial parameters ###
adminmail="foo@foobar.com"
server="jabber.foobar.com"
jabberdir="/var/lib/jabber"
cd $jabberdir/$server
users=`ls -1 *.xml|sed s/\.xml$//|tee $jabberdir/allusers.txt`
### send_to function sends message to 1 single user ($currentuser) with all missing contacts
send_to () {
### Start message to currentuser ####
### Start a stream to server and log in with a presence ###
echo -e "<stream:stream to=\"$server\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\">\n"
echo -e "<iq id='auth2' type='set'><query xmlns='jabber:iq:auth'><username>jabbadmin</username><password>passwordishere</password><resource>telnet</resource></query></iq>\n"
echo -e "<presence/>\n"
echo -e "<message id=\"new-contacts\" to=\"$currentuser@$server\"><x xmlns=\"jabber:x:roster\">"
### Add missing contacts from $currentuser-missing file
cat $jabberdir/roaster-info/$currentuser-missing |sed 's%.*%<item name="&" jid="&@foo.foobar.com"></item>%'
### Some Greetings
echo -e "</x><body>Your missing contacts are in this message. Please add them all to your contact list, this way they also get notified about your new Jabber address!\n\n[Jabber Admin Account]</body></message>\n"
### Close the stream nicely - not needed###
#echo -e "</stream:stream>\n"
}
### Main starts here
for currentuser in $users ; do
### What is already in roaster of currentuser?
echo "Processing $currentuser ..."
echo "$jabberdir/$server/$currentuser.xml"
xmlfilter -nl $jabberdir/$server/$currentuser.xml |grep "<item jid="|awk -F\' ' {print $2}'|sed s/@jabber\.foobar\.com// | tr "[A-Z]" "[a-z]" > $jabberdir/roaster-info/lastuser.tmp
### Contacts not needed can be added here:
echo -e "$currentuser\njabbadmin\n">>$jabberdir/roaster-info/lastuser.tmp
### What is missing from roaster? Compare _sorted_ files !
sort $jabberdir/roaster-info/lastuser.tmp >$jabberdir/roaster-info/$currentuser
comm $jabberdir/allusers.txt $jabberdir/roaster-info/$currentuser -2 -3 > $jabberdir/roaster-info/$currentuser-missing
#send_to
if [ -s $jabberdir/roaster-info/$currentuser-missing ]
then
send_to |tee /var/log/jabber/lastrun.log|telnet forum 5222
sleep 30
else echo "Missing contacts file size = 0"
fi
done