Zarafa-licensed on any system
From Zarafa wiki
This article is a community contribution and may include unsupported configurations.
To be able to run the zarafa-licensed daemon on any Linux system, you'll first need a system which Zarafa supports. In this example we'll use a Debian Squeeze system, which is easy to use and doesn't have a lot of dependencies. Either create a virtual machine, or if you already have a debian(-like) system use the following command:
debootstrap --arch i386 squeeze /home/chroots/squeeze http://ftp.nl.debian.org/debian
You can use any system though, as long as the pre-build Zarafa packages are installable. Note that we use the 32bit version, since that is able to run on both 32bit and 64bit systems.
If you're using a chroot, enter it with the following command:
Now download the zarafa package from http://download.zarafa.com/community/final/, unpack, and install the license package along with the minimal dependencies. Ignore the installation errors, and let apt-get install all the other system dependencies.
wget <zarafa> tar zxpvf <zarafa> cd <zarafa> dpkg -i zarafa-licensed* zarafa-client* zarafa-contact* zarafa-common* zarafa-server* apt-get -f install
To see the actual library dependencies of the zarafa-licensed daemon, run the following command:
It will show some 20 orso libraries that are required to run. Now we will setup the minimal parts in a new directory:
mkdir -p /opt/zarafa-licensed/bin mkdir -p /opt/zarafa-licensed/lib cp -p /usr/bin/zarafa-licensed /opt/zarafa-licensed/bin cp -p /usr/lib/libzarafaclient.so /opt/zarafa-licensed/lib/
This makes a very small "chroot" which now contains only the zarafa parts which are required for the zarafa-licensed to start. Now we need to add the system requirements. Either copy all the libraries mentioned from the 'ldd' output into /opt/zarafa-licensed/lib/ or use a tool which does this for you:
apt-get install mklibs mklibs-copy -d /opt/zarafa-licensed/lib /opt/zarafa-licensed/bin/*
In zarafa 7.x this still misses a lot of libraries as I found out with strace, so you need these as well to get a really clean environment that only uses the correct libraries:
cp /lib/ld-linux.so.2 /opt/zarafa-licensed/lib/ cp -a /usr/lib/libzarafa* /opt/zarafa-licensed/lib/ cp /usr/lib/gconv/gconv-modules /opt/zarafa-licensed/lib cp -a /usr/lib/gconv/UTF-32.so /opt/zarafa-licensed/lib/ cp -a /usr/lib/libnss_files.so /opt/zarafa-licensed/lib ln -s libnss_files.so /opt/zarafa-licensed/lib/libnss_files.so.2
Now we should have a full environment which is able to correctly run the zarafa-licensed daemon in /opt/zarafa-licensed.
Now make a tar.gz in a specified location containing all the files we just copied:
cd /opt && tar zcpvf /root/zarafa-licensed-full.tar.gz zarafa-licensed
Exit the chroot, and copy the tar file to the machine you would like to run the zarafa-licensed daemon on. Eg:
cd /home/chroots/squeeze/root/ scp zarafa-licensed-full.tar.gz <destination system>
On the destination system, unpack the file in /opt again:
cd /opt tar zxpvf /path/to/zarafa-licensed-full.tar.gz
If you're running a 64bit system, and used this example to make a 32bit license daemon, your system needs some dependencies to run 32bit programs. This differs a bit from system to system. Eg, on Fedora:
yum install glibc.i686
Or on Ubuntu:
apt-get install libc6-i386
There is no simple way to be absolutely sure you have all the correct libraries complete. Tools like ldd dont show all of them. The best way to be sure is to use strace when you run the licensed on the other environment:
strace -f -E GCONV_PATH=/opt/zarafa-licensed/lib -E LD_LIBRARY_PATH=/opt/zarafa-licensed/lib/ /opt/zarafa-licensed/lib/ld-linux.so.2 /opt/zarafa-licensed/bin/zarafa-licensed -F 2>&1 | grep lib
If this loads any libraries from any other place then /opt/zarafa-licensed/lib, then you should add those libraries. If you dont, then the zarafa-licensed could crash when you issue on some commands, like the "CAPA ZCP" command.
To actually run the zarafa-licensed daemon, we still need to tell the system where to find required system libraries and where to find the new libraries. So we need to add the system directories first to the LD_LIBRARY_PATH, and we also need GCONV_PATH:
GCONV_PATH=/opt/zarafa-licensed/lib LD_LIBRARY_PATH=/opt/zarafa-licensed/lib/ /opt/zarafa-licensed/lib/ld-linux.so.2 /opt/zarafa-licensed/bin/zarafa-licensed -V
Note how we first call the correct ld-linux.so loader.
This should print the version of the zarafa-licensed program. If it segfaults, you might need to force the first system library to the correct architecture, either /lib32 or /lib64. When this proof of concept works, you can continue.
Finalizing the installation
Copy the configuration file and init script from the minimized system to the destination system in the same locations. Edit the configuration file if required. Since the init script wants the zarafa-licensed in the /usr/bin directory, we'll create a special wrapper script there, that correctly starts the zarafa-licensed daemon from our new location. The script should contain the following lines:
#!/bin/sh export LD_LIBRARY_PATH=/opt/zarafa-licensed/lib/ export GCONV_PATH=/opt/zarafa-licensed/lib exec /opt/zarafa-licensed/lib/ld-linux.so.2 /opt/zarafa-licensed/bin/zarafa-licensed $@
Now use the init script to start the license daemon, and monitor the output in the logfile and check if the program stays running.
Using socat to test the license deamon can save you a lot of time, since in sometimes the daemon only crashes when it receives certain commands.
An example of a correctly functioning daemon you find below. (things like INFO ZCP are the command you type in, which should give you a response)
[Syn-3] email@example.com ~# socat UNIX-CONNECT:/var/run/zarafa-licensed - INFO ZCP OK 10 SERIAL ZCP OK XXXXXXXXXXXXXXXXXXX CAPA ZCP OK OUTLOOK BACKUP WA-ADVANCED-CALENDAR EWS ^C[Syn-3] firstname.lastname@example.org ~#
Especially the CAPA ZCP command is troublesome if you dont have all the correct libs.