[Kolab-devel] Howto install addons to Kolab

Nathan Toone nathan at toonetown.com
Fri Mar 19 19:35:54 CET 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know how useful this is, but I thought I'd share my knowledge with the 
lists.  I'm copying this to jadmin at jabber.org, just in case anyone else out 
there would be interested in integrating jabber with kolab.

Also I'm wondering if Kolab 2.0 will be a little bit easier to do this sort of 
thing.

Kolab is a great product, and it lends itself well to being expanded.  It 
makes for a great all-in-one solution.  By following this setup, you can just 
copy your /kolab directory completely to a different machine if you need to 
migrate it - it's all self-contained.

Our company is quite small - 30 people (I wouldn't try putting all this on one 
server if you have a lot (hundreds?) of users), and we wanted a single 
solution for email/mailing lists/spam filtering/virus filtering/instant 
messaging.  It might not be the solution for everyone.

The technologies we chose were:
	Kolab - email and user management
	Mailman - mailing lists
	Virus Filtering - amavisd-new and AntiVir (because we already had a license)
	Spam Filtering - spamassassin
	Instant Messaging - jabberd2

If you mess up your system I'm not responsible!  This document is messy and 
long.  I might have missed steps, there are most likely typos, and it follows 
my own meandering train of thought.  It makes sense to me - but it might not 
to everyone else.

This document also assumes that you are very familiar with all the given 
technologies, compiling your own code, administering a linux system, and 
editing config files.  There isn't much explanation of WHY I did what I did - 
just HOW I did what I did.  (The WHY is buried within the commands.  Anyone 
who would like to expand on why you enter these commands is free to do so)

NOTE:  Whenever I talk about commands you run as root, I'm assuming that you 
have run 
   export PATH=/kolab/bin/:/kolab/sbin/:/kolab/local/bin/:/kolab/local/sbin/:
$PATH
so that you prefer the kolab binaries (perl, python, etc) rather than the ones 
on your system already. (I include it in /root/.bashrc)

Here is the setup procedure:
=====================================================
1 - Install Kolab as instructed.  The installation went pretty smoothly.

VERIFY THAT KOLAB WORKED.
=====================================================
2 - Installing Python

Mailman requires Python - I installed python 2.3.3 from the openpkg 
distribution (downloaded from ftp://ftp.openpkg.org/current/SRC/)

rpm -ivh python-2.3.3-20040207.src.rpm
cd /kolab/RPM/SRC/python
rpm -bb python.spec
su
/kolab/bin/rpm -Uhv /kolab/RPM/PKG/python*.rpm

This gave me a working installation of Python in my /kolab directory.
=====================================================
3 - Installing Mailman

This was probably the one that I had the hardest time with.  I never could get 
it to run as the kolab user, so I finally had to break down and create a 
mailman user.

useradd -d /kolab/usr/mailman mailman

Download mailman from http://www.list.org/download.html

tar -zxvpf mailman-2.1.4.tgz
cd mailman-2.1.4
./configure --prefix=/kolab/usr/mailman --with-var-prefix=/kolab/var/mailman 
- --with-mail-gid=kolab --with-cgi-gid=kolab
make && make install

This should give a working mailman installation - installed 
into /kolab/usr/mailman

run /kolab/usr/mailman/bin/check_perms -f (as root)

edit rc.kolab and add the following lines:
	echo "starting mailman ..."
	su - mailman -c '/kolab/usr/mailman/bin/mailmanctl start'
right AFTER the section that starts postfix and these lines:
	echo "stopping mailman ..."
   	su - mailman -c '/kolab/usr/mailman/bin/mailmanctl stop'
right BEFORE the section that stops postfix.

Now we need to tie the configuration of mailmain to the configuration that 
Kolab uses (so we don't need to keep up the config files).  Mailman 
configuration is found in /kolab/usr/mailman/Mailman/mm_cfg.py.

cp /kolab/usr/mailman/Mailman/mm_cfg.py /kolab/etc/kolab/mm_cfg.py.template
edit /kolab/etc/kolab/mm_cfg.py.template and add the following lines to the 
end:
	MTA = 'Postfix'
	POSTFIX_ALIAS_CMD = '/kolab/sbin/postalias'
	POSTFIX_MAP_CMD = '/kolab/sbin/postmap'
	DELIVERY_MODUL = 'SMTPDirect'
	SMTPHOST = 'localhost'
	DEFAULT_URL_PATTERN = 'http://%s/mailman/'
	DEFAULT_URL = 'http://@@@fqhostname@@@/mailman/'
	DEFAULT_URL_HOST = '@@@fqhostname@@@'
	DEFAULT_EMAIL_HOST = '@@@postfix-mydomain@@@'
	DEFAULT_NNTP_HOST = '@@@fqhostname@@@'
	add_virtualhost('@@@fqhostname@@@')
	add_virtualhost('@@@postfix-mydomain@@@')

Now we need to make kolab aware of the new template file - and teach it to 
reload the mailman daemons when configurations are changed:

edit /kolab/etc/kolab/kolab

insert the line:
	"$kolab_prefix/etc/kolab/mm_cfg.py.template" => 
"$kolab_prefix/usr/mailman/Mailman/mm_cfg.py",
directly before the line:
	"$kolab_prefix/etc/kolab/main.cf.template" => 
"$kolab_prefix/etc/postfix/main.cf",
(insert those commands, all on one line, EXACTLY as show above, including the 
" and the trailing ,)


Add these lines:
	if ($haschanged{'mailman'}) {
      		dolog("restarting mailman");
      		system("$kolab_prefix/usr/mailman/bin/mailmanctl stop");
      		system("$kolab_prefix/usr/mailman/bin/mailmanctl stop");
  	}
directly before the lines:
	if ($configdata{'proftpd-ftp'} =~ /true/i) {
     		dolog("make sure proftpd is running");
		...

And add the lines:
	elsif ($conf =~ /mm_cfg/) {
            $haschanged{'mailman'} =1;
         }
directly after the lines:
	} elsif ($conf =~ /imapd/) {
            $haschanged{'imapd'} =1;
         }
(actually, you need to append the first line of my added code to the last line 
of the existing code - so it looks like this:)
         } elsif ($conf =~ /imapd/) {
            $haschanged{'imapd'} =1;
         } elsif ($conf =~ /mm_cfg/) {
            $haschanged{'mailman'} =1;
         }

Restart Kolab and pray for the best!
=====================================================
4 - Installing amavis/spamassassin

NOTE - most of this info, I got from the howto at 
http://kolab.kde.org/howtos/amavis_spamassassin_clam/amavis_spamassassin_clam.pdf.  
I don't know who wrote it, but it was very easy to follow - thanks!

Download amavisd-new from http://www.ijs.si/software/amavisd

Make sure you have all the perl modules you need (lines beginning with a > are 
typed in at the perl cpan shell):

perl -MCPAN -e shell
>install Archive::Tar
>install Archive::Zip
>install Compress::Zlib
>install Convert::TNEF
>install Convert::UUlib
>install MIME::Base64
>install MIME::Parser
>install Mail::Internet
>install Net::Server
>install NET::SMTP
>install Digest::MD5
>install IO::Stringy
>install Time::HiRes
>install Unix::Syslog
>install HTML::Parser
>install DB_File
>install Digest::SHA1
>install Net::DNS
>quit

(if you want to use dcc...reccommended)
wget http://www.dcc-servers.net/dcc/source/dcc-dccproc.tar.Z
tar xfvz dcc-dccproc.tar.Z
cd dcc_dccproc-*
./configure --prefix=/kolab && make && make install
cdcc info

(if you want to use pyzor....reccommended)
download pyzor from 
https://sourceforge.net/project/showfiles.php?group_id=50000
tar -jxvpf pyzor*.tar.bz
cd pyzor*
python setup.py build
python setup.py install
chmod -R 
a+rX /kolab/share/doc/pyzor /kolab/lib/python2.2/site-packages/pyzor /kolab/bin/pyzor /usr/bin/pyzord

(Now install spamassassin)
perl -MCPAN
>install Mail::SpamAssassin
>quit

(Now install amavisd)
mkdir /kolab/var/amavis
chown kolab:kolab-r /kolab/var/amavis
chmod 770 /kolab/var/amavis
cd to where you extracted amavis
cp amavisd /kolab/local/sbin
chown kolab:kolab-r /kolab/local/sbin/amavisd
chmod 775 /kolab/local/sbin/amavisd
Edit /kolab/local/sbin/amavisd and set the correct version of perl to
	#!/kolab/bin/perl -T
(on the first line of amavisd)
mkdir /kolab/etc/amavisd
chown kolab:kolab-r /kolab/etc/amavisd
chmod 775 /kolab/etc/amavisd
cd to where you extracted amavis
cp amavisd.conf /kolab/etc/amavisd
chown kolab:kolab-r /kolab/etc/amavisd/amavisd.conf

Configure your amavisd.conf file - uncomment the section for what antivirus 
program you are using.

I'm not going to go into installing the antivirus portion since there are so 
many you can do.  Basically, just download the source, and do
	./configure --prefix=/kolab && make && make install
You might want to set up a cron job to automatically download new virus 
definitions (check your antivirus program documentation for more details)

Now we want to tie the configuration of amavis into kolab (for easy 
management)
cp /kolab/etc/amavisd/amavisd.conf /kolab/etc/kolab/amavisd.conf.template
edit /kolab/etc/kolab/amavisd.conf.template and set 
	$mydomain = '@@@postfix-mydomain@@@';
edit /kolab/etc/kolab/kolab and add the following line:
	"$kolab_prefix/etc/kolab/amavisd.conf.template" => 
"$kolab_prefix/etc/amavis/amavisd.conf",
directly BEFORE the line:
	"$kolab_prefix/etc/kolab/main.cf.template" => 
"$kolab_prefix/etc/postfix/main.cf",
add the lines:
	if ($haschanged{'amavisd'}) {
      		dolog("restarting amavisd");
      		system("$kolab_prefix/etc/rc.d/rc.amavisd restart");
   	}
directly BEFORE the lines:
	if ($configdata{'proftpd-ftp'} =~ /true/i) {
     		 dolog("make sure proftpd is running");
add the lines:
	elsif ($conf =~ /amavis/) {
            $haschanged{'amavisd'} =1;
         }
directly after the lines:
	elsif ($conf =~ /imapd/) {
            $haschanged{'imapd'} =1;
         }
(actually append the lines - so that it matches the syntax of that section)

Include the attached rc.amavis file in /kolab/etc/rc.d/

Edit /kolab/etc/rc.d/rc.kolab
add the lines:
	echo "starting amavis ..."
    	/kolab/etc/rc.d/rc.amavis start
directly AFTER the lines:
	echo "starting postfix ..."
    	/kolab/sbin/postfix start
and add the lines:
	echo "stopping amavis ..."
   	 /kolab/etc/rc.d/rc.amavis stop
directly BEFORE the lines:
	echo "stopping postfix ..."
   	 /kolab/sbin/postfix stop

edit /kolab/etc/kolab/master.cf.template
add the following lines:
	smtp-amavis unix -      -       n       -       2       smtp
      	  	-o smtp_data_done_timeout=1200
        	-o disable_dns_lookups=yes
	127.0.0.1:10025 inet n  -       n       -       -       smtpd
        	-o content_filter=
        	-o local_recipient_maps=
        	-o relay_recipient_maps=
        	-o smtpd_restriction_classes=
        	-o smtpd_client_restrictions=
        	-o smtpd_helo_restrictions=
        	-o smtpd_sender_restrictions=
        	-o smtpd_recipient_restrictions=permit_mynetworks,reject
        	-o mynetworks=127.0.0.0/8
        	-o strict_rfc821_envelopes=yes
after the line:
	lmtp      unix  -       -       n       -       -       lmtp

edit /kolab/etc/kolab/main.cf.template
set content_filter = smtp-amavis:[127.0.0.1]:10024

OK - now restart kolab (and it should restart amavis with it) and hope it 
works!!!  
=====================================================
5 - Installing jabber

download the jabberd2 sources from http://jabberd.jabberstudio.org/2/
Untar the sources and apply the patch from 
http://zuzia.adm.onet.pl/~zych/JABBER2/jabberd-2.0s2-zz2.patch to them.
patch -p0 < jabberd-2.0s2-zz2.patch
cd jabberd-2.0s2
./configure --prefix=/kolab --enable-storage=db --enable-authreg=ldap && make 
&& make install

It is beyond the scope of this document to explain how to configure jabber.  
It's pretty straitforward.  Set it up, and verify that it works, then you can 
integrate it with Kolab in the same way that you integrated amavis and 
mailman.  
Place the attached c2s.xml sm.xml and router.xml config files 
in /kolab/etc/kolab/

Edit those files to your heart's content.  These config files come straight 
from our configuration - which only allows ssl connections.  If you want to 
do this, you need to create an ssl key for jabber:
	openssl req -new -x509 -newkey rsa:1024 -days 3650 -keyout privkey.pem -out 
server.pem
openssl rsa -in privkey.pem -out privkey.pem
cat privkey.pem >> server.pem
rm privkey.pem
mv server.pem /kolab/etc/jabberd/jabber.pem
chown root:kolab /kolab/etc/jabberd/jabber.pem    
chmod 640 /kolab/etc/jabberd/jabber.pem

Make the directories needed for jabber:
mkdir -p /kolab/var/jabberd/db
mkdir -p /kolab/var/jabberd/log
mkdir -p /kolab/var/jabberd/pid

Insert jabber-specific stuff into /kolab/etc/kolab/kolab
add the following lines:
	"$kolab_prefix/etc/kolab/c2s.xml.template" => 
"$kolab_prefix/etc/jabberd/c2s.xml",
      	"$kolab_prefix/etc/kolab/router.xml.template" => 
"$kolab_prefix/etc/jabberd/router.xml",
      	"$kolab_prefix/etc/kolab/sm.xml.template" => 
"$kolab_prefix/etc/jabberd/sm.xml",
directly before the line:
	"$kolab_prefix/etc/kolab/main.cf.template" => 
"$kolab_prefix/etc/postfix/main.cf",
add the following lines:
	$configdata{'jabber-domain'} = $configdata{'postfix-mydomain'};
   	$configdata{'jabber-email'} = '@'.$configdata{'jabber-domain'};
before the line:
	my $salt = substr $configdata{'proftpd-userPassword'}, 0, 2;
add the following lines:
	if ($haschanged{'jabberd'}) {
     		dolog("restarting jabberd");
      		system("$kolab_prefix/etc/rc.d/rc.jabberd restart");
  	}
after the lines:
	if ($haschanged{'imapd'}) {
      		dolog("restarting imapd");
      		system("$kolab_prefix/etc/rc.d/rc.imapd restart");
   	}
add the following lines:
	elsif ($conf =~ /xml/) {
            $haschanged{'jabberd'} =1;
         }
after the lines:
	} elsif ($conf =~ /imapd/) {
            $haschanged{'imapd'} =1;
         }
(append it so that it matches the syntax of the rest of that file)

Place the attached rc.jabberd file in /kolab/etc/rc.d

Edit /kolab/etc/rc.d/rc.kolab
add the lines:
	echo "starting jabber ..."
    	/kolab/etc/rc.d/rc.jabberd start
directly AFTER the lines:
	echo "starting postfix ..."
    	/kolab/sbin/postfix start
and add the lines:
	echo "stopping jabber ..."
    	/kolab/etc/rc.d/rc.jabberd stop
directly BEFORE the lines:
    	echo "stopping postfix ..."
    	/kolab/sbin/postfix stop

Once again, restart kolab and pray to the computer gods that nothing will 
break (which it probably will).
=====================================================
Like I said, this is the configuration of what worked for me.  You may need to 
tweak it - but hopefully this document gives you enough of a feel on how to 
set up any application to integrate with kolab.

If anyone knows much about freeradius, I'd love to work with you on getting it 
integrated as well (similar to the above portions)  I know nothing of how it 
works, and I'm having problems even getting it to compile into /kolab....

GOOD LUCK!

Any modifications/tips/corrections to this document are welcome.

- -Nathan


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAWz2L+lPSZRR0T30RAjjsAJ4jWX2lQ0FrPuC1I7VNec7Q53ABnACfckqG
ubFOPts/oHgyCipX3zILC+8=
=H+qV
-----END PGP SIGNATURE-----
-------------- next part --------------
#!/kolab/lib/openpkg/bash /kolab/etc/rc
##
##  rc.amavisd
##
##  Copyright (c) 2003 Stephan Buys <s.buys at codefusion.co.za>
##  adopted from: rc.kolab
##  rc.kolab:
##  Copyright (c) 2002 Martin Konold <martin.konold at erfrakon.de>
##  Copyright (c) 2002 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>


%config
    amavisd_enable="yes"

%start -p 200 -u root
    opServiceEnabled amavisd || exit 0

    echo "starting amavisd"
    if [ -f /kolab/var/amavis/amavisd.pid ]; then
       PID=`cat /kolab/var/amavis/amavisd.pid | awk '{print $1}'`
       AMAVISS=`ps -p $PID 2>/dev/null | grep -c amavisd | awk '{print $1}'`
       if [ $AMAVISS -gt 0 ]; then
          echo "Warning: amavisd is already running under pid $PID!"
       else
          /kolab/sbin/amavisd -c /kolab/etc/amavis/amavisd.conf
       fi
    else
       /kolab/sbin/amavisd -c /kolab/etc/amavis/amavisd.conf
    fi

%stop -p 200 -u root
    opServiceEnabled amavisd || exit 0

    echo "stopping amavisd..."
    if [ -f /kolab/var/amavis/amavisd.pid ]; then
       kill `cat /kolab/var/amavis/amavisd.pid` 2>/dev/null
    fi
    sleep 1
    killall -9 amavisd 2>/dev/null
    exit 0

%reload -u root
    opServiceEnabled amavisd || exit 0

    echo "reload amavisd (if running) ..."
    if [ -f /kolab/var/amavis/amavisd.pid ]; then
      kill -HUP `cat /kolab/var/amavis/amavisd.pid` 2>/dev/null
    fi


%restart -u root
    opServiceEnabled amavisd || exit 0
    /kolab/etc/rc.d/rc.amavisd stop
    sleep 1
    /kolab/etc/rc.d/rc.amavisd start

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kolab.org/pipermail/devel/attachments/20040319/b148c57e/attachment.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kolab.org/pipermail/devel/attachments/20040319/b148c57e/attachment-0001.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kolab.org/pipermail/devel/attachments/20040319/b148c57e/attachment-0002.html>
-------------- next part --------------
#!/kolab/lib/openpkg/bash
#
# Raymond 25DEC2003 support at bigriverinfotech.com
# /etc/rc.d/init.d/jabberd2
# init script for jabberd2 processes
# Tested under jabberd-2.0rc2 and Fedora 1.0 only
#
# processname: jabberd2
# description: jabberd2 is the next generation of the jabberd server
# chkconfig: 2345 85 15
#
#
progs="router sm c2s"
progsPath="/kolab/bin"
confPath="/kolab/etc/jabberd"
pidPath="/kolab/var/jabberd/pid"
statusCol="echo -ne \\033[60G"
statusColorOK="echo -ne \\033[1;32m"
statusColorFailed="echo -ne \\033[1;31m"
statusColorNormal="echo -ne \\033[0;39m"
retval=0
#
StatusOK ( ) {
	${statusCol}
	echo -n "[  "
	${statusColorOK}
	echo -n "OK"
	${statusColorNormal}
	echo "  ]"
	return 0
}
#
StatusFailed ( ) {
	echo -ne "\a"
	${statusCol}
	echo -n "["
	${statusColorFailed}
	echo -n "FAILED"
	${statusColorNormal}
	echo "]"
	return 0
}
#
ReqBins ( ) {
	for prog in ${progs}; do
		if [ ! -x ${progsPath}/${prog} ]; then
			echo -n "jabberd2 binary [${prog}] not found."
			StatusFailed
			echo "Cannot continue."
			return -1
		fi
	done
	return 0
}
#
ReqConfs ( ) {
	for prog in ${progs}; do
		if [ ! -f ${confPath}/${prog}.xml ]; then
			echo -n "jabberd2 configuration [${prog}.xml] not found."
			StatusFailed
			echo "Cannot continue."
			return -1
		fi
	done
	return 0
}
#
ReqDirs ( ) {
	if [ ! -d ${pidPath} ]; then
		echo -n "jabberd2 PID directory not found. Cannot continue."
		StatusFailed
		return -1
	fi
	return 0
}
#
Start ( ) {
	for req in ReqBins ReqConfs ReqDirs; do
		${req}
		retval=$?
		[ ${retval} == 0 ] || return ${retval}
	done
	echo "Initializing jabberd2 processes ..."
	for prog in ${progs}; do
		if [ $( pidof -s ${prog} ) ]; then
			echo -ne "\tprocess [${prog}] already running"
			StatusFailed
			sleep 1
			continue
		fi
		echo -ne "\tStarting ${prog}: "
		if [ ${prog} == "router" ]; then
			ports="5347"
		elif [ ${prog} == "c2s" ]; then
			ports="5222 5223"
		elif [ ${prog} == "s2s" ]; then
			ports="5269"
		else
			ports=""
		fi
		for port in ${ports}; do
			if [ $( netstat --numeric-ports --listening --protocol=inet |
	 				gawk '{ print $4 }' |
						gawk -F : '{ print $NF }' |
							grep -c ${port}$ ) -ne "0" ]; then
				StatusFailed
				echo -e "\tPort ${port} is currently in use. Cannot continue"
				echo -e "\tIs a Jabber 1.x server running?"
				Stop
				let retval=-1
				break 2
			fi
		done		
		rm -f ${pidPath}/${prog}.pid
		args="-c ${confPath}/${prog}.xml"
		${progsPath}/${prog} ${args} & 2> /dev/null
		retval=$?
		if [ ${retval} == 0 ]; then
			StatusOK
		else
			StatusFailed
			Stop
			let retval=-1
			break
		fi
		sleep 1
	done
	return ${retval}
}
#
Stop ( ) {
	echo "Terminating jabberd2 processes ..."
	for prog in ${progs}; do
		echo -ne "\tStopping ${prog}: "
		killproc ${prog}
		retval=$?
		if [ ${retval} == 0 ]; then
			rm -f ${pidPath}/${prog}.pid
		fi
		echo
		sleep 1
	done
	return ${retval}
}
#
case "$1" in
	start)
		Start
		;;
	stop)
		Stop
		;;
	restart)
		Stop
		Start
		;;
	condrestart)
		;;
	*)
		echo "Usage: $0 {start|stop|restart|condrestart}"
		let retval=-1
esac
exit ${retval}
#
# eof


More information about the devel mailing list