Index: npl/mailserver/kopano_conf/kopano_conf.build
===================================================================
--- npl/mailserver/kopano_conf/kopano_conf.build	(revision 6619178b29130b1e0e0da7195b538412ccdf17d0)
+++ npl/mailserver/kopano_conf/kopano_conf.build	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -1,1 +1,1 @@
-17
+22
Index: npl/mailserver/kopano_conf/kopano_conf.md5
===================================================================
--- npl/mailserver/kopano_conf/kopano_conf.md5	(revision 6619178b29130b1e0e0da7195b538412ccdf17d0)
+++ npl/mailserver/kopano_conf/kopano_conf.md5	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -3,12 +3,14 @@
 fd5fac3dcb59c74d9fc0994316749cf2  ./example-config/apparmor.d/usr.sbin.kopano-server
 ce5eb45e78a986fae32ebbdcbb1b844c  ./example-config/ldap.cfg
-7e293a686edc30a5f11f48dc087ff6a9  ./kopano_conf.pkg
+6f33739195a8fca341e4e13ccb3d7460  ./kopano_conf.pkg
 1f5f7d6f71d47c726d70daff8100c56f  ./kopano_conf.SlackBuild
-6f0468d3014de6b1d2ecb92ce87750db  ./kopano_conf.SlackBuild.log.gz
-77e930e82d6aa224be14072dcc719ab8  ./root/etc/cron.weekly/kopano_clean
+2e719e1a62e553eb32fe00047060708f  ./kopano_conf.SlackBuild.log.gz
+ffa5d010487228fccc8dff678e36617e  ./root/etc/apache2/conf.d/kopano.conf
+509f4a95bd86ba60c414e0666dd21339  ./root/etc/cron.weekly/kopano_clean
 c649bfb26c88c35ed95fcfec3fe6df9a  ./root/etc/kopano/archiver.cfg
 3028ddd4641d1394feb086ab58281783  ./root/etc/kopano/autorespond
 d5b3a58e38d2d3971c4d68e7de3a5004  ./root/etc/kopano/backup.cfg
 17e1514fc431e3f6dacd30d215b013ec  ./root/etc/kopano/dagent.cfg
+9c4545269155c1994f3a0b4939cdd915  ./root/etc/kopano/dspam.cfg
 125db7f424586e70c806e00400e9f1f4  ./root/etc/kopano/gateway.cfg
 a22505c1c8bb4384eb8c17d2e2c8d419  ./root/etc/kopano/ical.cfg
@@ -25,5 +27,16 @@
 8d70ed9bb454b861ea6a18552c41c8b0  ./root/etc/kopano/spooler.cfg
 175d812699725aacf1c9d742dcc1447f  ./root/etc/kopano/unix.cfg
+6ce2e5563699ad17fad55c05b53fe743  ./root/etc/kopano/userscripts/companies_common.sh
+2c945cd88531fb7ac0a669d2a6b543e1  ./root/etc/kopano/userscripts/createcompany
+73a5e66d358f006f4ca075ac058190df  ./root/etc/kopano/userscripts/createcompany.d/00createpublic
+60d06ba29d1f693cb0cb796977643962  ./root/etc/kopano/userscripts/creategroup
+2803687659c7b39e6981107845ef7e99  ./root/etc/kopano/userscripts/createuser
+6cec16060e10eb3d5e58e2f3c3389636  ./root/etc/kopano/userscripts/createuser.d/00createstore
+767032ec8be1cd6b72de6b97cdedb0ad  ./root/etc/kopano/userscripts/deletecompany
+0afd831fa6d492040c7b6348865e7d78  ./root/etc/kopano/userscripts/deletegroup
+c036bd7796319ea10ddedfdfc6fb4441  ./root/etc/kopano/userscripts/deleteuser
+c29d775a82be55a7882f4604d0b45cd5  ./root/etc/kopano/userscripts/groups_common.sh
 17ad42acc933c223f16803b965775ae6  ./root/etc/kopano/userscripts/kopano-dspam-retrain
+c7fe673ce6498ede08ca148d66293aea  ./root/etc/kopano/userscripts/users_common.sh
 95056928c5e351a922159f93a8f57d2f  ./root/etc/kopano/zcontacts.inf
 61c38fc2330baa42b357af5c1d7cffe5  ./root/etc/php5/mapi.ini
Index: npl/mailserver/kopano_conf/root/etc/apache2/conf.d/kopano.conf
===================================================================
--- npl/mailserver/kopano_conf/root/etc/apache2/conf.d/kopano.conf	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/apache2/conf.d/kopano.conf	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,3 @@
+Redirect /syn3/zarafa_webapp /syn3/kopano-webapp
+Redirect /syn3/zarafa /syn3/kopano-webapp
+
Index: npl/mailserver/kopano_conf/root/etc/cron.weekly/kopano_clean
===================================================================
--- npl/mailserver/kopano_conf/root/etc/cron.weekly/kopano_clean	(revision 6619178b29130b1e0e0da7195b538412ccdf17d0)
+++ npl/mailserver/kopano_conf/root/etc/cron.weekly/kopano_clean	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -39,6 +39,5 @@
 syn3-state kopano OK "$TXT kopano search xapian compact"
 svcstop /service/kopano-search/
-kopano-search-xapian-compact.py || abort "kopano search xapian compact mislukt"
-chown -R kopano:kopano /home/system/kopano_index/
+setuidgid kopano kopano-search-xapian-compact.py || abort "kopano search xapian compact mislukt"
 svcreset /service/kopano-search/
 
Index: npl/mailserver/kopano_conf/root/etc/kopano/dspam.cfg
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/dspam.cfg	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/dspam.cfg	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,70 @@
+##############################################################
+# dspam SERVICE SETTINGS
+
+# Path to store database with retrain-data and server-sync-state
+dspam_path          = /var/lib/kopano/dspam/
+
+# run as specific user
+run_as_user         = kopano
+
+# run as specific group
+run_as_group        = kopano
+
+
+# run server in this path (when not using the -F switch)
+running_path        =   /
+
+
+##############################################################
+# CONNECTION TO KOPANO SERVER SETTINGS
+#
+
+# Login to the Kopano server using this SSL Key
+#sslkey_file         = /etc/kopano/ssl/search.pem
+
+# The password of the SSL Key
+#sslkey_pass         = replace-with-server-cert-password
+
+##############################################################
+# LOG SETTINGS
+
+# Logging method (syslog, file)
+log_method          =   file
+
+# Loglevel (0=no logging, 5=full logging, 6=debugging)
+log_level           =   6
+
+# Logfile for log_method = file, use '-' for stderr
+log_file            =   /var/log/kopano/dspam.log
+
+# Log timestamp - prefix each log line with timestamp in 'file' logging mode
+log_timestamp       =   1
+
+
+##############################################################
+# SPAM FILTER SPECIFIC SETTINGS
+
+# This example is for dspam, the way its configured on a Datux SYN-3 server.
+# Requires a patched dspam version.
+
+# Header and header-value that classify a mail as spam.
+header_result       = X-DSPAM-Result
+header_result_spam  = Spam
+
+# Header that stores the original recipient/user of the mail. (some filters require this when retraining a mail)
+header_user         = X-DSPAM-Recipient
+
+# Header that stores the unique id thats required to retrain a message.
+header_id           = X-DSPAM-Signature
+
+# Actual script that is called to do the retraining.
+# Parameters:
+#  $1: spam-filter user
+#  $2: spam-filter message id or token
+#  $3: retrain classification: 'spam' or 'innocent'
+#  $4: when a previous training should be undone, this has the value 'undo' (e.g. when the user moves a message user back to the previous folder again)
+#      most filters dont support this, and you will probably just retrain the data again.
+retrain_script      = /etc/kopano/userscripts/kopano-dspam-retrain
+
+# Filter out dangerous characters from the parameters before calling the shell script:
+shell_filter_regex  = [^a-zA-Z0-9_,.-]
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/companies_common.sh
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/companies_common.sh	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/companies_common.sh	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,24 @@
+# shell include script
+
+KOPANO_LANG="${KOPANO_USERSCRIPT_LOCALE:-${LC_MESSAGES:-en_US}}"
+PATH=/bin:/usr/local/bin:/usr/bin
+export KOPANO_LANG PATH
+
+if [ -z "${KOPANO_COMPANY_SCRIPTS}" ] ; then
+    exec >&2
+    echo "Do not execute this script directly"
+    exit 1
+fi
+
+if [ ! -d "${KOPANO_COMPANY_SCRIPTS}" ] ; then
+    exec >&2
+    echo "${KOPANO_COMPANY_SCRIPTS} does not exist or is not a directory"
+    exit 1
+fi
+
+if [ -z "${KOPANO_COMPANY}" -a -z "${KOPANO_COMPANYID}" ] ; then
+    exec >&2
+    echo "KOPANO_COMPANY and KOPANO_COMPANYID is not set."
+    exit 1
+fi
+exec "$PKGLIBEXECDIR/kscriptrun" "$KOPANO_COMPANY_SCRIPTS"
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createcompany
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createcompany	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createcompany	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,20 @@
+#! /bin/sh
+
+# Script that is executed whenever a new company is created in the
+# external user source, such as an Active Directory tree or
+# /etc/passwd.
+
+# This script executes all scripts in /etc/kopano/userscripts/createcompany.d
+# using find.  The environment variable KOPANO_COMPANY is set, but
+# beware that this string can contain any characters, so take heed to
+# correct quoting.
+
+if [ -f /usr/etc/sysconfig/kopano ]; then
+  . /usr/etc/sysconfig/kopano
+elif [ -f /usr/etc/default/kopano ]; then
+  # Used on Debian in place of sysconfig
+  . /usr/etc/default/kopano
+fi
+PKGLIBEXECDIR=/usr/libexec/kopano
+KOPANO_COMPANY_SCRIPTS=/etc/kopano/userscripts/createcompany.d
+. /etc/kopano/userscripts/companies_common.sh
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createcompany.d/00createpublic
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createcompany.d/00createpublic	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createcompany.d/00createpublic	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+# Create a public store for the new company.
+
+PATH=$PATH:/sbin:/usr/local/sbin:/usr/sbin
+
+# The KOPANO_COMPANY variable from the server will always be in UTF-8
+# format.  The --utf8 option must be set before this value is used,
+# since the current locale isn't necessarily UTF-8.
+kopano-admin -v --utf8 -s -I "${KOPANO_COMPANY}"
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/creategroup
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/creategroup	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/creategroup	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# Script that is executed whenever a new group is created in the
+# external user source, such as an Active Directory tree or
+# /etc/passwd.
+
+# This script executes all scripts in /etc/kopano/userscripts/creategroup.d
+# using find.  The environment variable KOPANO_GROUP is set, but
+# beware that this string can contain any characters, so take heed to
+# correct quoting.
+
+if [ -f /usr/etc/sysconfig/kopano ]; then
+  . /usr/etc/sysconfig/kopano
+elif [ -f /usr/etc/default/kopano ]; then
+  . /usr/etc/default/kopano
+fi
+PKGLIBEXECDIR=/usr/libexec/kopano
+KOPANO_GROUP_SCRIPTS=/etc/kopano/userscripts/creategroup.d
+. /etc/kopano/userscripts/groups_common.sh
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createuser
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createuser	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createuser	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# Script that is executed whenever a new user is created in the
+# external user source, such as an Active Directory tree or
+# /etc/passwd.
+
+# This script executes all scripts in /etc/kopano/userscripts/createuser.d
+# using find.  The environment variable KOPANO_USER is set, but
+# beware that this string can contain any characters, so take heed to
+# correct quoting.
+
+if [ -f /usr/etc/sysconfig/kopano ]; then
+  . /usr/etc/sysconfig/kopano
+elif [ -f /usr/etc/default/kopano ]; then
+  . /usr/etc/default/kopano
+fi
+PKGLIBEXECDIR=/usr/libexec/kopano
+KOPANO_USER_SCRIPTS=/etc/kopano/userscripts/createuser.d
+. /etc/kopano/userscripts/users_common.sh
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createuser.d/00createstore
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createuser.d/00createstore	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/createuser.d/00createstore	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+# Create a Kopano user for an already existing external user.  Create
+# and initialize the user's stores.
+
+PATH=$PATH:/sbin:/usr/local/sbin:/usr/sbin
+
+# The KOPANO_USER variable from the server will always be in UTF-8
+# format.  The --utf8 option must be set before this value is used,
+# since the current locale isn't necessarily UTF-8.
+kopano-admin -v --utf8 --create-store "${KOPANO_USER}" --lang "${KOPANO_LANG}"
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deletecompany
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deletecompany	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deletecompany	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# Script that is executed whenever a new company is deleted from
+# the external user source, such as an Active Directory tree or
+# /etc/passwd.
+
+# This script executes all scripts in /etc/kopano/userscripts/deletecompany.d
+# using find.  The environment variable KOPANO_COMPANY is set, but
+# beware that this string can contain any characters, so take heed to
+# correct quoting.
+
+if [ -f /usr/etc/sysconfig/kopano ]; then
+  . /usr/etc/sysconfig/kopano
+elif [ -f /usr/etc/default/kopano ]; then
+  . /usr/etc/default/kopano
+fi
+PKGLIBEXECDIR=/usr/libexec/kopano
+KOPANO_COMPANY_SCRIPTS=/etc/kopano/userscripts/deletecompany.d
+. /etc/kopano/userscripts/companies_common.sh
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deletegroup
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deletegroup	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deletegroup	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# Script that is executed whenever a new group is deleted from
+# the external user source, such as an Active Directory tree or
+# /etc/passwd.
+
+# This script executes all scripts in /etc/kopano/userscripts/deletegroup.d
+# using find.  The environment variable KOPANO_GROUP is set, but
+# beware that this string can contain any characters, so take heed to
+# correct quoting.
+
+if [ -f /usr/etc/sysconfig/kopano ]; then
+  . /usr/etc/sysconfig/kopano
+elif [ -f /usr/etc/default/kopano ]; then
+  . /usr/etc/default/kopano
+fi
+PKGLIBEXECDIR=/usr/libexec/kopano
+KOPANO_GROUP_SCRIPTS=/etc/kopano/userscripts/deletegroup.d
+. /etc/kopano/userscripts/groups_common.sh
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deleteuser
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deleteuser	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/deleteuser	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+# Script that is executed whenever a new user is deleted from
+# the external user source, such as an Active Directory tree or
+# /etc/passwd.
+
+# This script executes all scripts in /etc/kopano/userscripts/deleteuser.d
+# using find.  The environment variable KOPANO_USER is set, but beware
+# that this string can contain any characters, so take heed to correct
+# quoting.
+
+if [ -f /usr/etc/sysconfig/kopano ]; then
+  . /usr/etc/sysconfig/kopano
+elif [ -f /usr/etc/default/kopano ]; then
+  . /usr/etc/default/kopano
+fi
+PKGLIBEXECDIR=/usr/libexec/kopano
+KOPANO_USER_SCRIPTS=/etc/kopano/userscripts/deleteuser.d
+. /etc/kopano/userscripts/users_common.sh
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/groups_common.sh
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/groups_common.sh	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/groups_common.sh	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,24 @@
+# shell include script
+
+KOPANO_LANG="${KOPANO_USERSCRIPT_LOCALE:-${LC_MESSAGES:-en_US}}"
+PATH=/bin:/usr/local/bin:/usr/bin
+export KOPANO_LANG PATH
+
+if [ -z "${KOPANO_GROUP_SCRIPTS}" ] ; then
+    exec >&2
+    echo "Do not execute this script directly"
+    exit 1
+fi
+
+if [ ! -d "${KOPANO_GROUP_SCRIPTS}" ] ; then
+    exec >&2
+    echo "${KOPANO_GROUP_SCRIPTS} does not exist or is not a directory"
+    exit 1
+fi
+
+if [ -z "${KOPANO_GROUP}" -a -z "${KOPANO_GROUPID}" ] ; then
+    exec >&2
+    echo "KOPANO_GROUP and KOPANO_GROUPID is not set."
+    exit 1
+fi
+exec "$PKGLIBEXECDIR/kscriptrun" "$KOPANO_GROUP_SCRIPTS"
Index: npl/mailserver/kopano_conf/root/etc/kopano/userscripts/users_common.sh
===================================================================
--- npl/mailserver/kopano_conf/root/etc/kopano/userscripts/users_common.sh	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
+++ npl/mailserver/kopano_conf/root/etc/kopano/userscripts/users_common.sh	(revision 51c3d1a508ff776ff50af20d4b79b50aeb48fe2a)
@@ -0,0 +1,24 @@
+# shell include script
+
+KOPANO_LANG="${KOPANO_USERSCRIPT_LOCALE:-${LC_MESSAGES:-C}}"
+PATH=/bin:/usr/local/bin:/usr/bin
+export KOPANO_LANG PATH
+
+if [ -z "${KOPANO_USER_SCRIPTS}" ] ; then
+    exec >&2
+    echo "Do not execute this script directly"
+    exit 1
+fi
+
+if [ ! -d "${KOPANO_USER_SCRIPTS}" ] ; then
+    exec >&2
+    echo "${KOPANO_USER_SCRIPTS} does not exist or is not a directory"
+    exit 1
+fi
+
+if [ -z "${KOPANO_USER}" -a -z "${KOPANO_STOREGUID}" ] ; then
+    exec >&2
+    echo "KOPANO_USER and KOPANO_STOREGUID is not set."
+    exit 1
+fi
+exec "$PKGLIBEXECDIR/kscriptrun" "$KOPANO_USER_SCRIPTS"
