Talk:Zarafa on SME8

From SME Server
Revision as of 19:10, 19 February 2013 by Frifri (talk | contribs) (Created page with "==== INSTALLATION of Zarafa ==== ===== Search latest STABLE php53-mapi.rpm ===== SME8 uses PHP5.3<br> Unfortunately, PHP 5.1 and PHP 5.3 are ABI incompatible, that means that...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

INSTALLATION of Zarafa

Search latest STABLE php53-mapi.rpm

SME8 uses PHP5.3
Unfortunately, PHP 5.1 and PHP 5.3 are ABI incompatible, that means that PHP modules that were compiled for PHP 5.1 (like the php-mapi.rpm compiled in the Zarafa-rpms for RHEL 5) can not be run using PHP 5.3 :

https://community.zarafa.com/pg/blog/read/1837/support-for-php-53-in-rhel-5-via-new-php53mapi-rpm-package

So, search on the EPEL-repositories the latest STABLE php53-mapi-package.

https://admin.fedoraproject.org/updates/search/php53-mapi?
Set the epel-repository :
/sbin/e-smith/db yum_repositories set epel repository \
Name 'Epel - EL5' \
BaseUrl 'http://download.fedoraproject.org/pub/epel/5/$basearch' \
MirrorList 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch' \
EnableGroups no \
GPGCheck yes \
GPGKey http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL \
Visible no \
status disabled 
/sbin/e-smith/db yum_repositories set epel-testing repository \
Name 'Epel-testing - EL5' \
BaseUrl 'http://download.fedoraproject.org/pub/epel/testing/5/$basearch' \
MirrorList 'http://mirrors.fedoraproject.org/mirrorlist?repo=testing-epel5&arch=$basearch' \
EnableGroups no \
GPGCheck yes \
GPGKey http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL \
Visible no \
status disabled 
signal-event yum-modify
Download via the Zarafawebsite the package for ZCP corresponding with the php53-mapi.rpm (cf. version above)

cd /to an installdirectory, ex. : /root/InstallZarafa

wget http://download.zarafa.com/community/final/7.0/[version]/zcp-[version]-rhel-5-[cpu-arch]-free.tar.gz

The 'free'-version has the ability to connect with Microsoft Outlook (default 3 users for free, buy zarafa-CAL's if you want more).

Unpack the corresponding package for ZCP :

Go (cd /...) to the installdirectory (if you haven't done this yet) :

cd /to the installdirectory

And unpack :

tar -zxvf zcp-*
Go (cd ./zcp-...) to the created subdirectory (zcp-...) :
cd ./zcp- ... 
Remove the devel packages
Move the windows-directory to an installshare in your network
Download the latest webapp.rpm too in the same subdirectory :
wget http://download.zarafa.com/community/final/WebApp/[version]/rhel/[zarafa-webapp-version.noarch.rpm]
Install all rpm's in the unpacked package of ZCP and the webapp.rpm too :
yum localinstall *.rpm

All packages have dependencies that cannot be resolved if you install only part of the rpm's.

Remove the default php-mapi.rpm

We have to remove the installation of the default php-mapi (because it's not built for php 5.3).

rpm -e php-mapi --nodeps
Install the php53-mapi.rpm

Install the php53-mapi.rpm of the EPEL-repository :

-If you downloaded the rpm :

rpm -Uvh --force php53-mapi

-If you did set the EPEL-repository :

yum install php53-mapi --enablerepo=epel --enablerepo=epel-testing
Make install/update-actions
nano -w /etc/e-smith/events/actions/zarafa-install
#!/usr/bin/env bash
clear

if [ `whoami` != "root" ]; then
	echo "This installation must be run as user root."
	echo "Become root, and run this script again."
	echo
	exit 1
fi

##########################################
# Creating some Zarafa-actions
##########################################

#
#--- zarafa-expand-templates ---
#
echo
echo "Creating zarafa-expand-templates-action ..."
echo
cat <<HERE1 > /etc/e-smith/events/actions/zarafa-expand-templates
#!/bin/sh
/sbin/e-smith/expand-template /etc/zarafa/gateway.cfg
/sbin/e-smith/expand-template /etc/zarafa/ical.cfg
/sbin/e-smith/expand-template /etc/zarafa/server.cfg
/sbin/e-smith/expand-template /etc/zarafa/unix.cfg
/sbin/e-smith/expand-template /etc/zarafa/monitor.cfg
/sbin/e-smith/expand-template /etc/zarafa/indexer.cfg
/sbin/e-smith/expand-template /etc/zarafa/spooler.cfg
/sbin/e-smith/expand-template /etc/zarafa/dagent.cfg
/sbin/e-smith/expand-template /etc/zarafa/licensed.cfg
/etc/e-smith/events/actions/qmail-update-user
HERE1


#
#--- zarafa-services ---
#
echo
echo "Creating zarafa-services-action ..."
echo
cat <<HERE2 > /etc/e-smith/events/actions/zarafa-services
#!/bin/sh
FILE=/etc/rc.d/init.d/zarafa-licensed
if [ "\$1" == start ]; then
 /etc/rc.d/init.d/zarafa-dagent start
 /etc/rc.d/init.d/zarafa-gateway start
 /etc/rc.d/init.d/zarafa-ical start
 if [ -a \$FILE ]; then \$FILE start; fi
 /etc/rc.d/init.d/zarafa-monitor start
 /etc/rc.d/init.d/zarafa-spooler start
 /etc/rc.d/init.d/zarafa-indexer start
 /etc/rc.d/init.d/zarafa-server start
 exit 0
fi
if [ "\$1" == stop ]; then
 /etc/rc.d/init.d/zarafa-dagent stop
 /etc/rc.d/init.d/zarafa-gateway stop
 /etc/rc.d/init.d/zarafa-ical stop
 if [ -a \$FILE ]; then \$FILE stop; fi
 /etc/rc.d/init.d/zarafa-indexer stop
 /etc/rc.d/init.d/zarafa-spooler stop
 /etc/rc.d/init.d/zarafa-server stop
 /etc/rc.d/init.d/zarafa-monitor stop  
 exit 0
fi
if [ "\$1" == restart ]; then
 /etc/rc.d/init.d/zarafa-dagent stop
 /etc/rc.d/init.d/zarafa-gateway stop
 /etc/rc.d/init.d/zarafa-ical stop
 if [ -a \$FILE ]; then \$FILE stop; fi
 /etc/rc.d/init.d/zarafa-monitor stop
 /etc/rc.d/init.d/zarafa-indexer stop
 /etc/rc.d/init.d/zarafa-spooler stop
 /etc/rc.d/init.d/zarafa-server stop
 /etc/rc.d/init.d/zarafa-dagent start
 /etc/rc.d/init.d/zarafa-gateway start
 /etc/rc.d/init.d/zarafa-ical start
 if [ -a \$FILE ]; then \$FILE start; fi
 /etc/rc.d/init.d/zarafa-monitor start
 /etc/rc.d/init.d/zarafa-server start
 /etc/rc.d/init.d/zarafa-spooler start
 /etc/rc.d/init.d/zarafa-indexer start
 exit 0
fi
if [ "\$1" == enabled ]; then
 config setprop zarafa-gateway status enabled
 config setprop zarafa-ical status enabled
 if [ -a \$FILE ]; then config setprop zarafa-licensed status enabled; fi
 config setprop zarafa-monitor status enabled
 config setprop zarafa-server status enabled
 config setprop zarafa-spooler status enabled
 config setprop zarafa-indexer status enabled
 config setprop zarafa-dagent status enabled
 exit 0
fi
if [ "\$1" == disabled ]; then
 config setprop zarafa-gateway status disabled
 config setprop zarafa-ical status disabled
 if [ -a \$FILE ]; then config setprop zarafa-licensed status disabled; fi
 config setprop zarafa-monitor status disabled
 config setprop zarafa-server status disabled
 config setprop zarafa-spooler status disabled
 config setprop zarafa-indexer status disabled
 config setprop zarafa-dagent status disabled
 exit 0
fi
echo "Usage: start|stop|restart|enabled|disabled"
exit 0
HERE2


#
#--- zarafa-create-user-action ---
#
echo
echo "Creating zarafa-create-user-action ..."
echo
cat <<HERE3 > /etc/e-smith/events/actions/zarafa-create-user
#!/bin/sh
clear
/bin/echo "Enter the username of the ZARAFA-user"
/bin/echo "If you have a multicompany-setup, format of the SME-username and the ZARAFA-username"
/bin/echo "has to be [username].[companyname] !!!"
read USERNAME
/bin/echo "Enter password:"
read PASSWORD
/bin/echo "Enter e-mail address:"
read EMAIL
/bin/echo "Enter full name:"
read FULLNAME
/bin/echo "Executing..."
/usr/bin/zarafa-admin -c "\$USERNAME" -p "\$PASSWORD" -e "\$EMAIL" -f "\$FULLNAME"
/usr/bin/zarafa-admin -l
/sbin/e-smith/db accounts setprop \$USERNAME zarafa enabled 
/etc/e-smith/events/actions/qmail-update-user
HERE3


#
#--- zarafa-create-company-action ---
#
echo
echo "Creating zarafa-create-company-action ..."
echo
cat <<HERE4 > /etc/e-smith/events/actions/zarafa-create-company
#!/bin/sh
clear
/bin/echo "Enter the companyname :"
read COMPANYNAME
/bin/echo "Executing..."
/usr/bin/zarafa-admin --create-company "\$COMPANYNAME"
HERE4


/bin/chmod 554 /etc/e-smith/events/actions/zarafa-expand-templates
/bin/chmod 554 /etc/e-smith/events/actions/zarafa-services
/bin/chmod 554 /etc/e-smith/events/actions/zarafa-create-user
/bin/chmod 554 /etc/e-smith/events/actions/zarafa-create-company

#
#--- zarafa-configuration-helper-action ---
#
echo
echo "Creating zarafa-configuration-helper-action ..."
echo
cat <<HERE5 > /etc/e-smith/events/actions/helpers.inc
# -*- Mode: sh -*-
replace() {
	file=\$1
	option=\$2
	value=\$3
	
	# escape &-signs, and % for sed
	value=\`echo \$value | sed -e 's/\&/\\\\\&/g' -e 's/\%/\\\\\%/g'\`
	sed -i -e "s%\([[:space:]]*\$option[[:space:]]*=[[:space:]]*\).*%\1\$value%" \$file

}
HERE5

. /etc/e-smith/events/actions/helpers.inc

##########################################
# Creating zarafa-db-creation-templates
##########################################

#
#--- /etc/e-smith/db/configuration/migrate/80zarafa ---
#
echo
echo "Creating /etc/e-smith/db/configuration/migrate/80zarafa ..."
echo
cat <<HERE6 > /etc/e-smith/db/configuration/migrate/80zarafa
{
    use MIME::Base64 qw(encode_base64);

    my \$rec = \$DB->get('zarafa-server') || \$DB->new_record('zarafa-server', {type => 'service'});

    my \$pw = \$rec->prop('DbPassword');
    return "" if \$pw;

    \$rec->set_prop('DbPassword', sprintf("%15.0f", int( (1000000000000000) * rand() )));
}
HERE6

#
#--- /etc/e-smith/templates/etc/e-smith/sql/init/80zarafa ---
#
echo
echo "Creating /etc/e-smith/templates/etc/e-smith/sql/init/80zarafa ..."
echo
cat <<HERE7 > /etc/e-smith/templates/etc/e-smith/sql/init/80zarafa
{
    my \$db = \${'zarafa-server'}{DbName} || 'zarafa';
    my \$user = \${'zarafa-server'}{DbUser} || 'zarafa';
    my \$pass = \${'zarafa-server'}{DbPassword} || 'changeme';
    \$OUT .= <<END
#! /bin/sh
    if [ -d /var/lib/mysql/\$db ]; then
      exit
    fi
    /usr/bin/mysql <<EOF
    CREATE DATABASE \$db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    use \$db;
 
    use mysql;
    GRANT ALL PRIVILEGES ON \$db.* TO \$user\@localhost
            IDENTIFIED BY '\$pass';
    flush privileges;
EOF
END
}
HERE7

#
#--- /etc/e-smith/templates.metadata/etc/e-smith/sql/init/80zarafa ---
#
echo
echo "Creating /etc/e-smith/templates.metadata/etc/e-smith/sql/init/80zarafa ..."
echo
cat <<HERE8 > /etc/e-smith/templates.metadata/etc/e-smith/sql/init/80zarafa
PERMS=0750
HERE8

##########################################
# Creating SME-HTTPD-templates
##########################################

#
#--- /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases ---
#
echo
echo "Creating /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases ..."
echo
cat <<HERE9 > /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases
{
    # vim: ft=perl:

    \$haveSSL = (exists \${modSSL}{status} and \${modSSL}{status} eq "enabled") ?  'yes' : 'no';
    my \$zwebmailStatus = \$zarafa{'status'} || "disabled";
    my \$zwebmailAccessType = \$zarafa{'access'} || "SSL";

    my \$dirs;
    \$dirs{zarafa} = '/usr/share/zarafa-webaccess';
    \$dirs{webaccess} = '/usr/share/zarafa-webaccess';
    \$dirs{webmail} = '/usr/share/zarafa-webaccess';
    if (\$imp{'status'} eq 'enabled') {\$dirs{webmail} = ''};
    \$dirs{webapp} = '/usr/share/zarafa-webapp';
   
    return "    # Zarafa is disabled in this VirtualHost\n"
                unless \$zwebmailStatus eq 'enabled';

    foreach \$place ('zarafa','webmail','webaccess','webapp')
    {
        if ((\$port eq "80") && (\$haveSSL eq 'yes') && (\$zwebmailAccessType eq 'SSL'))
        {
            \$OUT .= "    RewriteRule ^/\$place(/.*|\\$)    https://%{HTTP_HOST}/\$place\\\$1 [L,R]\n";
        } else {
            if ((\$dirs{\$place}) ne '') {\$OUT .= "    Alias	 /\$place   \$dirs{\$place}\n"};
        }
    }																		
}
HERE9

#
#--- /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias ---
#
echo
echo "Creating /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias ..."
echo
cat <<HERE10 > /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias
{
    my \$zstatus = \$zarafa{'status'};

    if (defined \$zstatus && \$zstatus eq 'enabled')
    {
        \$OUT .= qq(
#--------------------------------------------------------------------
# Zarafa specific configuration files.
#--------------------------------------------------------------------

Alias /zarafa /usr/share/zarafa-webaccess/
 <Directory /usr/share/zarafa-webaccess/>
  Options -Indexes
  AllowOverride All
  order allow,deny
  allow from all
  AddType application/x-httpd-php .php
  php_flag magic_quotes_gpc off
  php_flag track_vars on
 </Directory>

Alias /webapp /usr/share/zarafa-webapp/
 <Directory /usr/share/zarafa-webapp/>
  Options -Indexes
  AllowOverride All
  order allow,deny
  allow from all
  AddType application/x-httpd-php .php
  php_flag magic_quotes_gpc off
  php_flag track_vars on
 </Directory>
	    
);
    }    
    else
    {
       \$OUT .= "# Zarafa Webmail is not configured as it is disabled in the config db";
    }
}
HERE10

##########################################
# Creating SME-QMAIL-user-templates
##########################################

#
#--- /etc/e-smith/templates-user/.qmail/80Zarafa ---
#
echo
echo "Creating /etc/e-smith/templates-user/.qmail/80Zarafa ..."
echo
cat <<HERE11 > /etc/e-smith/templates-user/.qmail/80Zarafa
{
   my \$zarafa = \$user->prop('zarafa') || 'disabled';
   my \$zarafa2 = \${'zarafa-server'}{GlobalForward} || 'disabled';

   if (\$zarafa eq 'enabled' || \$zarafa2 eq 'enabled')
   { return "| /usr/bin/zarafa-dagent -q \$USERNAME ; if [ \\$\\? -ne 0 ] ; then exit -1; else exit 99; fi;"
   }
}
HERE11

#
#--- /etc/e-smith/templates-user/.qmail-junkmail/01Zarafa ---
#
echo
echo "Creating /etc/e-smith/templates-user/.qmail-junkmail/01Zarafa ..."
echo
cat <<HERE12 > /etc/e-smith/templates-user/.qmail-junkmail/01Zarafa
{
    # vim: ft=perl:
    die "USERNAME not set." unless defined (\$USERNAME);

    use esmith::AccountsDB;
    \$adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB";

    \$user = \$adb->get(\$USERNAME) or die "No user \$USERNAME in AccountsDB";

    my \$zarafa = \$user->prop('zarafa') || 'disabled';
    my \$zarafa2 = \${'zarafa-server'}{GlobalForward} || 'disabled';
    return "| /usr/bin/zarafa-dagent -qj \$USERNAME ; if [ \\$\\? -ne 0 ] ; then exit -1; else exit 99; fi;"
           if (\$zarafa eq 'enabled' || \$zarafa2 eq 'enabled');
}
HERE12


##########################################
# Creating Zarafa-configuration-templates
##########################################

#
#--- unix config ---
#
echo
echo "Creating zarafa-unix-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/unix.cfg
cat <<HERE13 > /etc/e-smith/templates/etc/zarafa/unix.cfg/unix.cfg
{
use esmith::AccountsDB
}
##############################################################
#  UNIX USER PLUGIN SETTINGS
#
# Any of these directives that are required, are only required if the
# userplugin parameter is set to unix.

# Charset used in /etc/passwd for the fullname of a user. Normally this
# is us-ascii, but this can differ according to your setup.
# The charset specified here must be supported by your iconv(1)
# setup. See iconv -l for all charsets.
fullname_charset = iso-8859-15

# Default email domain for constructing new users
# Required, no default
default_domain = { \${'zarafa-server'}{DomainName} || \$DomainName; }

# The lowest user id that is considered a regular user
# Optional, default = 1000
min_user_uid = 101

# The highest user id that is considered a regular user
# Optional, default = 10000
max_user_uid = 10000

# A list of user ids that are not considered to be regular users
# Optional, default = empty
# except_user_uids =
except_user_uids = {
\$accounts = esmith::AccountsDB->open_ro or die "Could not open AccountsDB";
{
while ((\$name, \$passwd, \$uid, \$gid, \$quota,
    \$comment, \$gcos, \$dir, \$shell) = getpwent())
{
\$user = \$accounts->get(\$name);
    
\$OUT .= "\$uid "
    unless \$uid <= 101 or (defined \$user and \$user->prop('type') eq "user");
}
}
}

# The lowest group id that is considered a regular group
# Optional, default = 1000
min_group_gid = 5000

# The highest group id that is considered a regular group
# Optional, default = 10000
max_group_gid = 10000

# A list of group ids that are not considered to be regular groups
# Optional, default = empty
# except_group_gids =
except_group_gids = {
setpwent();
while ((\$name, \$passwd, \$uid, \$gid, \$quota,
    \$comment, \$gcos, \$dir, \$shell) = getpwent())
{
\$group = \$accounts->get(\$name);
    
\$OUT .= "\$gid "
    unless \$gid < 5000 or (defined \$group and \$group->prop('type') eq "group");
}
endpwent();
}

# Create a user as non-active when it has this unix shell
non_login_shell = /bin/false
HERE13


#
#--- sysconfig config ---
#
echo
echo "Creating zarafa-sysconfig-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/sysconfig/zarafa
cat /etc/sysconfig/zarafa | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/sysconfig/zarafa/zarafa
replace /etc/e-smith/templates/etc/sysconfig/zarafa/zarafa ZARAFA_LOCALE '"{ ${'\''zarafa'\''}{language} || '\''en_US.UTF-8'\'' ; }"'
replace /etc/e-smith/templates/etc/sysconfig/zarafa/zarafa ZARAFA_USERSCRIPT_LOCALE '"{ ${'\''zarafa'\''}{language} || '\''en_US.UTF-8'\'' ; }"'


#
#--- licensed config ---
#
echo
echo "Creating zarafa-licensed-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/licensed.cfg
cat /usr/share/doc/zarafa-licensed/example-config/licensed.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg
replace /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg log_method '{ ${'\''zarafa-licensed'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg log_level '{ ${'\''zarafa-licensed'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg log_timestamp '{ ${'\''zarafa-licensed'\''}{log_timestamp} || '\''1'\''; }'

#
#--- server config ---
#
echo
echo "Creating zarafa-server-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/server.cfg
cat /usr/share/doc/zarafa/example-config/server.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_tcp_enabled '{ ${'\''zarafa-server'\''}{server_tcp_enabled} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_tcp_port	'{ ${'\''zarafa-server'\''}{TCPPort} || '\''236'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_pipe_enabled '{ ${'\''zarafa-server'\''}{server_pipe_enabled} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_name '{ ${'\''zarafa-server'\''}{server_name} || '\''Zarafa'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg database_engine '{ ${'\''zarafa-server'\''}{database_engine} || '\''mysql'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg allow_local_users '{ ${'\''zarafa-server'\''}{allow_local_users} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg local_admin_users '{ ${'\''zarafa-server'\''}{local_admin_users} || '\''root'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg system_email_address '{ ${'\''zarafa-server'\''}{system_email_address} || '\''postmaster@localhost'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg session_timeout '{ ${'\''zarafa-server'\''}{session_timeout} || '\''300'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg license_timeout '{ ${'\''zarafa-server'\''}{license_timeout} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg log_method '{ ${'\''zarafa-server'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg log_level '{ ${'\''zarafa-server'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg log_timestamp '{ ${'\''zarafa-server'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg audit_log_enabled '{ ${'\''zarafa-server'\''}{audit_log_enabled} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg audit_log_level	'{ ${'\''zarafa-server'\''}{audit_log_level} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg audit_log_timestamp '{ ${'\''zarafa-server'\''}{audit_log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_host '{ ${'\''zarafa-server'\''}{mysql_host} || '\''localhost'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_port '{ ${'\''zarafa-server'\''}{mysql_port} || '\''3306'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_user '{ ${'\''zarafa-server'\''}{DbUser} || '\''zarafa'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_password '{ ${'\''zarafa-server'\''}{DbPassword}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_database '{ ${'\''zarafa-server'\''}{DbName} || '\''zarafa'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg attachment_storage '{ ${'\''zarafa-server'\''}{attachment_storage} || '\''files'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg attachment_path '/home/e-smith/files/zarafa'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg attachment_compression '{ ${'\''zarafa-server'\''}{attachment_compression} || '\''6'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_enabled '{ ${'\''zarafa-ssl'\''}{server_ssl_enabled} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_port	'{ ${'\''zarafa-ssl'\''}{TCPPort} || '\''237'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_key_file '/home/e-smith/ssl.pem/{$SystemName}.{$DomainName}.pem'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_key_pass '{ ${'\''zarafa-server'\''}{DbPassword}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_ca_file '/home/e-smith/ssl.crt/{$SystemName}.{$DomainName}.crt'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_ca_path '/home/e-smith/ssl.crt'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sslkeys_path '/home/e-smith/ssl.pem'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg threads	'{ ${'\''zarafa-server'\''}{threads} || '\''8'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg watchdog_frequency '{ ${'\''zarafa-server'\''}{watchdog_frequency} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg watchdog_max_age '{ ${'\''zarafa-server'\''}{watchdog_max_age} || '\''500'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_max_keep_alive_requests '{ ${'\''zarafa-server'\''}{server_max_keep_alive_requests} || '\''100'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_recv_timeout '{ ${'\''zarafa-server'\''}{server_recv_timeout} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_read_timeout '{ ${'\''zarafa-server'\''}{server_read_timeout} || '\''60'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_send_timeout '{ ${'\''zarafa-server'\''}{server_send_timeout} || '\''60'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg softdelete_lifetime '{ ${'\''zarafa-server'\''}{softdelete_lifetime} || '\''30'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sync_lifetime '{ ${'\''zarafa-server'\''}{sync_lifetime} || '\''365'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sync_log_all_changes '{ ${'\''zarafa-server'\''}{sync_log_all_changes} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_sso '{ ${'\''zarafa-server'\''}{enable_sso} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_gab '{ ${'\''zarafa-server'\''}{enable_gab} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg auth_method '{ ${'\''zarafa-server'\''}{auth_method} || '\''plugin'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg pam_service '{ ${'\''zarafa-server'\''}{pam_service} || '\''passwd'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_cell_size '{ ${'\''zarafa-server'\''}{cache_cell_size} || '\''268435456'\''; }' 
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_object_size '{ ${'\''zarafa-server'\''}{cache_object_size} || '\''5242880'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_indexedobject_size '{ ${'\''zarafa-server'\''}{cache_indexedobject_size} || '\''16777216'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_quota_size '{ ${'\''zarafa-server'\''}{cache_quota_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_quota_lifetime '{ ${'\''zarafa-server'\''}{cache_quota_lifetime} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_acl_size '{ ${'\''zarafa-server'\''}{cache_acl_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_store_size '{ ${'\''zarafa-server'\''}{cache_store_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_user_size	'{ ${'\''zarafa-server'\''}{cache_user_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_userdetails_size '{ ${'\''zarafa-server'\''}{cache_userdetails_size} || '\''26214400'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_userdetails_lifetime '{ ${'\''zarafa-server'\''}{cache_userdetails_lifetime} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_server_size '{ ${'\''zarafa-server'\''}{cache_server_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_server_lifetime '{ ${'\''zarafa-server'\''}{cache_server_lifetime} || '\''30'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg quota_warn '{ ${'\''zarafa-server'\''}{quota_warn} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg quota_soft '{ ${'\''zarafa-server'\''}{quota_soft} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg quota_hard '{ ${'\''zarafa-server'\''}{quota_hard} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg companyquota_warn '{ ${'\''zarafa-server'\''}{companyquota_warn} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg user_plugin '{ ${'\''zarafa-server'\''}{user_plugin} || '\''db'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg user_plugin_config '{ ${'\''zarafa-server'\''}{user_plugin_config}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg user_safe_mode '{ ${'\''zarafa-server'\''}{user_safe_mode} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg thread_stacksize '{ ${'\''zarafa-server'\''}{thread_stacksize} || '\''512'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_hosted_zarafa '{ ${'\''zarafa-server'\''}{enable_hosted_zarafa} || '\''false'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_distributed_zarafa '{ ${'\''zarafa-server'\''}{enable_distributed_zarafa} || '\''false'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg storename_format '{ ${'\''zarafa-server'\''}{storename_format} || '\''%f'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg loginname_format '{ ${'\''zarafa-server'\''}{loginname_format} || '\''%u'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg client_update_enabled '{ ${'\''zarafa-server'\''}{client_update_enabled} || '\''false'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg client_update_path '{ ${'\''zarafa-server'\''}{client_update_path} || '\''/var/lib/zarafa/client'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg client_update_log_level '{ ${'\''zarafa-server'\''}{client_update_log_level} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg hide_everyone '{ ${'\''zarafa-server'\''}{hide_everyone} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg hide_system '{ ${'\''zarafa-server'\''}{hide_system} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg index_services_enabled '{ ${'\''zarafa-server'\''}{index_services_enabled} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg index_services_search_timeout '{ ${'\''zarafa-server'\''}{index_services_search_timeout} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg index_services_prefix_chars '{ ${'\''zarafa-server'\''}{index_services_prefix_chars} || '\''3'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_enhanced_ics '{ ${'\''zarafa-server'\''}{enable_enhanced_ics} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sync_gab_realtime '{ ${'\''zarafa-server'\''}{sync_gab_realtime} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg disabled_features '{ ${'\''zarafa-server'\''}{disabled_features}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg max_deferred_records '{ ${'\''zarafa-server'\''}{max_deferred_records} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg max_deferred_records_folder '{ ${'\''zarafa-server'\''}{max_deferred_records_folder} || '\''20'\''; }'


#
#--- dagent config ---
#
echo
echo "Creating zarafa-dagent-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/dagent.cfg
cat /usr/share/doc/zarafa-dagent/example-config/dagent.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_method '{ ${'\''zarafa-dagent'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_level '{ ${'\''zarafa-dagent'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_timestamp '{ ${'\''zarafa-dagent'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_raw_message '{ ${'\''zarafa-dagent'\''}{log_raw_message} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg lmtp_port '{ ${'\''zarafa-dagent'\''}{lmtp_port} || '\''2003'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg lmtp_max_threads '{ ${'\''zarafa-dagent'\''}{lmtp_max_threads} || '\''20'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg process_model '{ ${'\''zarafa-dagent'\''}{process_model} || '\''fork'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg spam_header_name '{ ${'\''zarafa-dagent'\''}{spam_header_name} || '\''X-Spam-Status'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg spam_header_value '{ ${'\''zarafa-dagent'\''}{spam_header_value} || '\''Yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg archive_on_delivery '{ ${'\''zarafa-dagent'\''}{archive_on_delivery} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg set_rule_headers '{ ${'\''zarafa-dagent'\''}{set_rule_headers} || '\''yes'\''; }'


#
#--- spooler config ---
#
echo
echo "Creating zarafa-spooler-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/spooler.cfg
cat /usr/share/doc/zarafa-spooler/example-config/spooler.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg smtp_port '{ ${'\''zarafa-spooler'\''}{smtp_port} || '\''25'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg log_method '{ ${'\''zarafa-spooler'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg log_level '{ ${'\''zarafa-spooler'\''}{log_level} || '\''3'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg log_timestamp '{ ${'\''zarafa-spooler'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg max_threads '{ ${'\''zarafa-spooler'\''}{max_threads} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg fax_domain '{ ${'\''zarafa-spooler'\''}{fax_domain} || '\''fax.local'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg fax_international '{ ${'\''zarafa-spooler'\''}{fax_international} || '\''00'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg always_send_delegates '{ ${'\''zarafa-spooler'\''}{always_send_delegates} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg allow_redirect_spoofing '{ ${'\''zarafa-spooler'\''}{allow_redirect_spoofing} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg copy_delegate_mails '{ ${'\''zarafa-spooler'\''}{copy_delegate_mails} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg allow_delegate_meeting_request '{ ${'\''zarafa-spooler'\''}{allow_delegate_meeting_request} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg allow_send_to_everyone '{ ${'\''zarafa-spooler'\''}{allow_send_to_everyone} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg always_send_tnef '{ ${'\''zarafa-spooler'\''}{always_send_tnef} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg always_send_utf8 '{ ${'\''zarafa-spooler'\''}{always_send_utf8} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg charset_upgrade '{ ${'\''zarafa-spooler'\''}{charset_upgrade} || '\''windows-1252'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg expand_groups '{ ${'\''zarafa-spooler'\''}{expand_groups} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg archive_on_send '{ ${'\''zarafa-spooler'\''}{archive_on_send} || '\''no'\''; }'


#
#--- monitor config ---
#
echo
echo "Creating zarafa-monitor-configuration-template ..."
echo "The monitor program sends quota warning mails to users who are over quota."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/monitor.cfg
cat /usr/share/doc/zarafa-monitor/example-config/monitor.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg log_method '{ ${'\''zarafa-monitor'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg log_level '{ ${'\''zarafa-monitor'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg log_timestamp '{ ${'\''zarafa-monitor'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg quota_check_interval '{ ${'\''zarafa-monitor'\''}{quota_check_interval} || '\''15'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg mailquota_resend_interval '{ ${'\''zarafa-monitor'\''}{mailquota_resend_interval} || '\''1'\''; }'


#
#--- gateway config ---
#
echo
echo "Creating zarafa-gateway-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/gateway.cfg
cat /usr/share/doc/zarafa-gateway/example-config/gateway.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg server_socket 'http://localhost:{${'\''zarafa-server'\''}{TCPPort}||'\''236'\'';}/zarafa'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3_enable '{ if (${'\''zarafa-pop3'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3_port '{ ${'\''zarafa-pop3'\''}{TCPPort} || '\''8110'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3s_enable '{ if (${'\''zarafa-pop3s'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3s_port '{ ${'\''zarafa-pop3s'\''}{TCPPort} || '\''8995'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_enable '{ if (${'\''zarafa-imap'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_port '{ ${'\''zarafa-imap'\''}{TCPPort} || '\''8143'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imaps_enable '{ if (${'\''zarafa-imaps'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imaps_port '{ ${'\''zarafa-imaps'\''}{TCPPort} || '\''8993'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_only_mailfolders '{ ${'\''zarafa-imap'\''}{imap_only_mailfolders} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_public_folders '{ ${'\''zarafa-imap'\''}{imap_public_folders} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_capability_idle '{ ${'\''zarafa-imap'\''}{imap_capability_idle} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_max_messagesize '{ ${'\''zarafa-imap'\''}{imap_max_messagesize} || '\''134217728'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_generate_utf8 '{ ${'\''zarafa-imap'\''}{imap_generate_utf8} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_expunge_on_delete '{ ${'\''zarafa-imap'\''}{imap_expunge_on_delete} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_store_rfc822 '{ ${'\''zarafa-imap'\''}{imap_store_rfc822} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg ssl_private_key_file '/home/e-smith/ssl.key/{$SystemName}.{$DomainName}.key'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg ssl_certificate_file '/home/e-smith/ssl.crt/{$SystemName}.{$DomainName}.crt'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg ssl_verify_client '{ ${'\''zarafa-gateway'\''}{ssl_verify_client} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg process_model '{ ${'\''zarafa-gateway'\''}{process_model} || '\''fork'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg log_method '{ ${'\''zarafa-gateway'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg log_level '{ ${'\''zarafa-gateway'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg log_timestamp '{ ${'\''zarafa-gateway'\''}{log_timestamp} || '\''1'\''; }'


#
#--- ical config ---
#
echo
echo "Creating zarafa-ical-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/ical.cfg
cat /usr/share/doc/zarafa-ical/example-config/ical.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ical_enable '{ if (${'\''zarafa-ical'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ical_port '{ ${'\''zarafa-ical'\''}{TCPPort} || '\''8088'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg icals_enable '{ if (${'\''zarafa-icals'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg icals_port '{ ${'\''zarafa-icals'\''}{TCPPort} || '\''8089'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg server_socket 'http://localhost:{${'\''zarafa-server'\''}{TCPPort}||'\''236'\'';}/zarafa'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg process_model '{ ${'\''zarafa-ical'\''}{process_model} || '\''fork'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg log_method '{ ${'\''zarafa-ical'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg log_level '{ ${'\''zarafa-ical'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg log_timestamp '{ ${'\''zarafa-ical'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ssl_private_key_file '/home/e-smith/ssl.key/{$SystemName}.{$DomainName}.key'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ssl_certificate_file '/home/e-smith/ssl.crt/{$SystemName}.{$DomainName}.crt'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ssl_verify_client '{ ${'\''zarafa-ical'\''}{ssl_verify_client} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg server_timezone '{$TimeZone}'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg default_charset '{ ${'\''zarafa-ical'\''}{default_charset} || '\''utf-8'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg enable_ical_get '{ ${'\''zarafa-ical'\''}{enable_ical_get} || '\''yes'\''; }'


#
#--- indexer config ---
#
echo
echo "Creating zarafa-indexer-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/indexer.cfg
cat /usr/share/doc/zarafa-indexer/example-config/indexer.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg cleanup_lockfiles '{ ${'\''zarafa-indexer'\''}{cleanup_lockfiles} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg limit_results	'{ ${'\''zarafa-indexer'\''}{limit_results} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg log_method '{ ${'\''zarafa-indexer'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg log_level '{ ${'\''zarafa-indexer'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg log_timestamp '{ ${'\''zarafa-indexer'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_interval '{ ${'\''zarafa-indexer'\''}{index_interval} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_threads '{ ${'\''zarafa-indexer'\''}{index_threads} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_max_field_length '{ ${'\''zarafa-indexer'\''}{index_max_field_length} || '\''10000'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_merge_factor '{ ${'\''zarafa-indexer'\''}{index_merge_factor} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_max_buffered_docs '{ ${'\''zarafa-indexer'\''}{index_max_buffered_docs} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_min_merge_docs '{ ${'\''zarafa-indexer'\''}{index_min_merge_docs} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_max_merge_docs '{ ${'\''zarafa-indexer'\''}{index_max_merge_docs} || '\''2147483647'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_term_interval '{ ${'\''zarafa-indexer'\''}{index_term_interval} || '\''128'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_cache_timeout '{ ${'\''zarafa-indexer'\''}{index_cache_timeout} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachments '{ ${'\''zarafa-indexer'\''}{index_attachments} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachment_max_size '{ ${'\''zarafa-indexer'\''}{index_attachment_max_size} || '\''5120'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachment_parser_max_memory '{ ${'\''zarafa-indexer'\''}{index_attachment_parser_max_memory} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachment_parser_max_cputime '{ ${'\''zarafa-indexer'\''}{index_attachment_parser_max_cputime} || '\''0'\''; }'


######################################
# Configuring SME-events : Templates to expand
######################################

/bin/echo 
/bin/echo "Configuring SME-events : Templates2expand"
/bin/echo 
mkdir -p /etc/e-smith/events/email-update/templates2expand/etc/zarafa
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/gateway.cfg
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/ical.cfg
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/server.cfg
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/unix.cfg
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/spooler.cfg
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/licensed.cfg
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/monitor.cfg
touch /etc/e-smith/events/email-update/templates2expand/etc/zarafa/dagent.cfg

mkdir -p /etc/e-smith/events/group-create/templates2expand/etc/zarafa
touch /etc/e-smith/events/group-create/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/group-delete/templates2expand/etc/zarafa
touch /etc/e-smith/events/group-delete/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/group-modify/templates2expand/etc/zarafa
touch /etc/e-smith/events/group-modify/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/user-create/templates2expand/etc/zarafa
touch /etc/e-smith/events/user-create/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/user-delete/templates2expand/etc/zarafa
touch /etc/e-smith/events/user-delete/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/user-modify/templates2expand/etc/zarafa
touch /etc/e-smith/events/user-modify/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/ibay-create/templates2expand/etc/zarafa
touch /etc/e-smith/events/ibay-create/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/machine-account-create/templates2expand/etc/zarafa
touch /etc/e-smith/events/machine-account-create/templates2expand/etc/zarafa/unix.cfg

mkdir -p /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/e-smith/sql/init/80zarafa
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/gateway.cfg
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/ical.cfg
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/server.cfg
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/unix.cfg
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/spooler.cfg
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/licensed.cfg
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/monitor.cfg
touch /etc/e-smith/events/post-upgrade/templates2expand/etc/zarafa/dagent.cfg


######################################
# Configuring SME-events : Services to adjust
######################################

/bin/echo 
/bin/echo "Configuring SME-events : Services2adjust"
/bin/echo 
mkdir -p /etc/e-smith/events/machine-account-create/services2adjust
ln -s reload /etc/e-smith/events/group-create/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/group-delete/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/group-modify/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/user-create/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/user-delete/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/user-modify/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/ibay-create/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/machine-account-create/services2adjust/zarafa-server
ln -s reload /etc/e-smith/events/timezone-update/services2adjust/zarafa-server


######################################
# Setting up SME-db-entries
######################################

/bin/echo 
/bin/echo "Enter the language of your choice for your zarafa-mailboxes and public store(s)."
/bin/echo "Values: en_US.UTF-8, en_GB.UTF-8, nl_NL.UTF-8, fr_FR.UTF-8, de_DE.UTF-8, ..."
/bin/echo 
read ZARAFALANGUAGE
/sbin/e-smith/config set zarafa service status enabled language $ZARAFALANGUAGE
/sbin/e-smith/expand-template /etc/sysconfig/zarafa

/bin/echo 
/bin/echo "Initialize-default-databases"
/bin/echo 
/etc/e-smith/events/actions/initialize-default-databases

/bin/echo 
/bin/echo "Setting up db-entries for Zarafa"
/bin/echo 
/sbin/e-smith/db configuration setprop mysqld InnoDB enabled
/sbin/e-smith/db configuration setprop smtpd tnef2mime disabled
/sbin/e-smith/db configuration setprop zarafa-server access private status enabled TCPPort 236 index_services_enabled yes
/bin/echo 
/bin/echo "Enter your user plugin."
/bin/echo "Values: unix or db (ldap is not supported, multicompany-support only with db-plugin)."
/bin/echo 
read USERPLUGIN
/sbin/e-smith/db configuration setprop zarafa-server user_plugin $USERPLUGIN

if [ "$USERPLUGIN" == unix ]; then
/sbin/e-smith/db configuration setprop zarafa-server user_plugin_config /etc/zarafa/unix.cfg
fi

if [ "$USERPLUGIN" == db ]; then
/bin/echo
/bin/echo "Do you want to set up a multicompany-environment ?"
/bin/echo "Values: yes or no."
/bin/echo
read MULTICOMPANY
/sbin/e-smith/db configuration setprop zarafa-server Multicompany $MULTICOMPANY
/sbin/e-smith/db configuration delprop zarafa-server user_plugin_config
if [ "$MULTICOMPANY" == yes ]; then
/sbin/e-smith/db configuration setprop zarafa-server enable_hosted_zarafa true
/sbin/e-smith/db configuration setprop zarafa-server loginname_format %u.%c
else
/sbin/e-smith/db configuration setprop zarafa-server enable_hosted_zarafa false
/sbin/e-smith/db configuration setprop zarafa-server loginname_format %u
fi
fi

/sbin/e-smith/db configuration setprop zarafa access SSL
/sbin/e-smith/db configuration set zarafa-ical service access private status enabled TCPPort 8088
/sbin/e-smith/db configuration set zarafa-icals service access public status enabled TCPPort 8089
/sbin/e-smith/db configuration set zarafa-imap service access private status enabled TCPPort 8143
/sbin/e-smith/db configuration set zarafa-imaps service access public status enabled TCPPort 8993
/sbin/e-smith/db configuration set zarafa-pop3 service access private status enabled TCPPort 8110
/sbin/e-smith/db configuration set zarafa-pop3s service access public status enabled TCPPort 8995
/sbin/e-smith/db configuration set zarafa-ssl service access public status enabled TCPPort 237
/sbin/e-smith/db configuration set zarafa-gateway service status enabled
/sbin/e-smith/db configuration set zarafa-spooler service status enabled
/sbin/e-smith/db configuration set zarafa-monitor service status enabled
/sbin/e-smith/db configuration set zarafa-indexer service status enabled
/sbin/e-smith/db configuration set zarafa-licensed service status enabled
/sbin/e-smith/db configuration set zarafa-dagent service status enabled


######################################
# Setting up the Zarafa-db
######################################

/bin/echo
/bin/echo "Expanding the my.cnf-template"
/bin/echo
/sbin/e-smith/expand-template /etc/my.cnf

/bin/echo
/bin/echo "Restarting mysqld"
/bin/echo
/usr/bin/sv t /service/mysqld

/bin/echo
/bin/echo "Signal-event remoteaccess-update"
/bin/echo
/sbin/e-smith/signal-event remoteaccess-update

/bin/echo
/bin/echo "Creating the Zarafa-database"
/bin/echo
/sbin/e-smith/expand-template /etc/e-smith/sql/init/80zarafa
/etc/rc.d/init.d/mysql.init start


######################################
# Expanding the Zarafa-configuration-templates
######################################

/bin/echo
/bin/echo "Expanding the Zarafa-configuration-templates"
/bin/echo
/etc/e-smith/events/actions/zarafa-expand-templates


######################################
# Configuration of the Webaccess
######################################

/bin/echo
/bin/echo "Configuration of the Webaccess and Z-push"
/bin/echo
/bin/chown -R www:www /var/lib/zarafa-webaccess/tmp
/bin/chown -R www:www /var/lib/zarafa-webapp/tmp
FILE=/etc/httpd/conf.d/zarafa-webaccess.conf; if [ -a $FILE ]; then /bin/rm -f $FILE; fi
FILE=/etc/httpd/conf.d/zarafa-webapp.conf; if [ -a $FILE ]; then /bin/rm -f $FILE; fi

/bin/echo
/bin/echo "Expanding http.conf-template"
/bin/echo
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

/bin/echo
/bin/echo "Restarting httpd"
/bin/echo
/usr/bin/sv restart /service/httpd-e-smith


######################################
# Setting up more symbolic links
######################################

/bin/echo
/bin/echo "Setting up more symbolic links"
/bin/echo
ln -s /lib/libcrypto.so.0.9.8e /usr/lib/libcrypto.so.0.9.8
ln -s /lib/libssl.so.0.9.8e /usr/lib/libssl.so.0.9.8
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-dagent
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-gateway
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-indexer
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-licensed
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-monitor
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-spooler
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-ical
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99zarafa-server


#######################################
# Installing a license-key
#######################################

/bin/echo 
/bin/echo "Installing a license-key"
/bin/echo 
if [ -x /usr/bin/zarafa-licensed ]; then
	if [ ! -f /etc/zarafa/license/base ]; then
		mkdir -p /etc/zarafa/license
		SERIAL="0"
		while [ ${#SERIAL} -ne 25 -a ${#SERIAL} -ne 0 ]; do
			if [ -n "$SERIAL" ]; then
				echo "Serial number must be 25 characters or empty"
			fi
			echo -ne "Server serial number (leave empty for none) []\t\t: "
			read SERIAL
		done
		SERIAL=`echo $SERIAL | tr [a-z] [A-Z]`
		echo $SERIAL > /etc/zarafa/license/base
		echo
		echo "The correctness of the serial will be checked when the Zarafa-server starts."
		echo
	fi
fi


#######################################
# Starting Zarafa
#######################################

/bin/echo 
/bin/echo "Starting Zarafa-services"
/bin/echo 
/etc/e-smith/events/actions/zarafa-services start

/bin/echo
/bin/echo "Setting permissions on files"
/bin/echo
FILE=/var/log/zarafa/dagent.log; if [ -a $FILE ]; then /bin/chmod 666 $FILE; fi
/bin/chmod 554 /etc/e-smith/events/actions/zarafa-update


#######################################
# Creating public store(s)
#######################################

if [ "$USERPLUGIN" == unix ]; then
/bin/echo
/bin/echo "creating Public store"
/bin/echo
/usr/bin/zarafa-admin --utf8 -s
fi

if [ "$USERPLUGIN" == db ]; then
if [ "$MULTICOMPANY" == no ]; then
/bin/echo
/bin/echo "creating Public store"
/bin/echo
/usr/bin/zarafa-admin --utf8 -s
fi
fi

if [ "$USERPLUGIN" == db ]; then
if [ "$MULTICOMPANY" == yes ]; then
 /bin/echo
 /bin/echo "Make your first company. Enter your first companyname :"
 /bin/echo
 read COMPANYNAME
 /usr/bin/zarafa-admin --create-company "$COMPANYNAME"
 /bin/echo
 /bin/echo "!!! REMEMBER !!! : for a multicompany-environment the username-format of the SME-user and the ZARAFA-user,"
 /bin/echo "has to be : [username].[companyname] !!!"
 /bin/echo
fi
fi

To save :
CTRL + X
yes
<ENTER>
nano -w /etc/e-smith/events/actions/zarafa-update
#!/bin/sh

/bin/echo "Stopping the Zarafa-services"
/etc/e-smith/events/actions/zarafa-services stop

#
#--- zarafa-configuration-helper-action ---
#
echo
echo "Creating zarafa-configuration-helper-action ..."
echo
cat <<HERE1 > /etc/e-smith/events/actions/helpers.inc
# -*- Mode: sh -*-
replace() {
	file=\$1
	option=\$2
	value=\$3
	
	# escape &-signs, and % for sed
	value=\`echo \$value | sed -e 's/\&/\\\\\&/g' -e 's/\%/\\\\\%/g'\`
	sed -i -e "s%\([[:space:]]*\$option[[:space:]]*=[[:space:]]*\).*%\1\$value%" \$file

}
HERE1

. /etc/e-smith/events/actions/helpers.inc

#
#--- sysconfig config ---
#
echo
echo "Creating zarafa-sysconfig-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/sysconfig/zarafa
cat /etc/sysconfig/zarafa | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/sysconfig/zarafa/zarafa
replace /etc/e-smith/templates/etc/sysconfig/zarafa/zarafa ZARAFA_LOCALE '"{ ${'\''zarafa'\''}{language} || '\''en_US.UTF-8'\'' ; }"'
replace /etc/e-smith/templates/etc/sysconfig/zarafa/zarafa ZARAFA_USERSCRIPT_LOCALE '"{ ${'\''zarafa'\''}{language} || '\''en_US.UTF-8'\'' ; }"'


#
#--- licensed config ---
#
echo
echo "Creating zarafa-licensed-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/licensed.cfg
cat /usr/share/doc/zarafa-licensed/example-config/licensed.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg
replace /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg log_method '{ ${'\''zarafa-licensed'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg log_level '{ ${'\''zarafa-licensed'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/licensed.cfg/licensed.cfg log_timestamp '{ ${'\''zarafa-licensed'\''}{log_timestamp} || '\''1'\''; }'

#
#--- server config ---
#
echo
echo "Creating zarafa-server-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/server.cfg
cat /usr/share/doc/zarafa/example-config/server.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_tcp_enabled '{ ${'\''zarafa-server'\''}{server_tcp_enabled} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_tcp_port	'{ ${'\''zarafa-server'\''}{TCPPort} || '\''236'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_pipe_enabled '{ ${'\''zarafa-server'\''}{server_pipe_enabled} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_name '{ ${'\''zarafa-server'\''}{server_name} || '\''Zarafa'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg database_engine '{ ${'\''zarafa-server'\''}{database_engine} || '\''mysql'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg allow_local_users '{ ${'\''zarafa-server'\''}{allow_local_users} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg local_admin_users '{ ${'\''zarafa-server'\''}{local_admin_users} || '\''root'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg system_email_address '{ ${'\''zarafa-server'\''}{system_email_address} || '\''postmaster@localhost'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg session_timeout '{ ${'\''zarafa-server'\''}{session_timeout} || '\''300'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg license_timeout '{ ${'\''zarafa-server'\''}{license_timeout} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg log_method '{ ${'\''zarafa-server'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg log_level '{ ${'\''zarafa-server'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg log_timestamp '{ ${'\''zarafa-server'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg audit_log_enabled '{ ${'\''zarafa-server'\''}{audit_log_enabled} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg audit_log_level	'{ ${'\''zarafa-server'\''}{audit_log_level} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg audit_log_timestamp '{ ${'\''zarafa-server'\''}{audit_log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_host '{ ${'\''zarafa-server'\''}{mysql_host} || '\''localhost'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_port '{ ${'\''zarafa-server'\''}{mysql_port} || '\''3306'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_user '{ ${'\''zarafa-server'\''}{DbUser} || '\''zarafa'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_password '{ ${'\''zarafa-server'\''}{DbPassword}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg mysql_database '{ ${'\''zarafa-server'\''}{DbName} || '\''zarafa'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg attachment_storage '{ ${'\''zarafa-server'\''}{attachment_storage} || '\''files'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg attachment_path '/home/e-smith/files/zarafa'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg attachment_compression '{ ${'\''zarafa-server'\''}{attachment_compression} || '\''6'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_enabled '{ ${'\''zarafa-ssl'\''}{server_ssl_enabled} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_port	'{ ${'\''zarafa-ssl'\''}{TCPPort} || '\''237'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_key_file '/home/e-smith/ssl.pem/{$SystemName}.{$DomainName}.pem'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_key_pass '{ ${'\''zarafa-server'\''}{DbPassword}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_ca_file '/home/e-smith/ssl.crt/{$SystemName}.{$DomainName}.crt'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_ssl_ca_path '/home/e-smith/ssl.crt'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sslkeys_path '/home/e-smith/ssl.pem'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg threads	'{ ${'\''zarafa-server'\''}{threads} || '\''8'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg watchdog_frequency '{ ${'\''zarafa-server'\''}{watchdog_frequency} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg watchdog_max_age '{ ${'\''zarafa-server'\''}{watchdog_max_age} || '\''500'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_max_keep_alive_requests '{ ${'\''zarafa-server'\''}{server_max_keep_alive_requests} || '\''100'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_recv_timeout '{ ${'\''zarafa-server'\''}{server_recv_timeout} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_read_timeout '{ ${'\''zarafa-server'\''}{server_read_timeout} || '\''60'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg server_send_timeout '{ ${'\''zarafa-server'\''}{server_send_timeout} || '\''60'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg softdelete_lifetime '{ ${'\''zarafa-server'\''}{softdelete_lifetime} || '\''30'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sync_lifetime '{ ${'\''zarafa-server'\''}{sync_lifetime} || '\''365'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sync_log_all_changes '{ ${'\''zarafa-server'\''}{sync_log_all_changes} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_sso '{ ${'\''zarafa-server'\''}{enable_sso} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_gab '{ ${'\''zarafa-server'\''}{enable_gab} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg auth_method '{ ${'\''zarafa-server'\''}{auth_method} || '\''plugin'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg pam_service '{ ${'\''zarafa-server'\''}{pam_service} || '\''passwd'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_cell_size '{ ${'\''zarafa-server'\''}{cache_cell_size} || '\''268435456'\''; }' 
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_object_size '{ ${'\''zarafa-server'\''}{cache_object_size} || '\''5242880'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_indexedobject_size '{ ${'\''zarafa-server'\''}{cache_indexedobject_size} || '\''16777216'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_quota_size '{ ${'\''zarafa-server'\''}{cache_quota_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_quota_lifetime '{ ${'\''zarafa-server'\''}{cache_quota_lifetime} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_acl_size '{ ${'\''zarafa-server'\''}{cache_acl_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_store_size '{ ${'\''zarafa-server'\''}{cache_store_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_user_size	'{ ${'\''zarafa-server'\''}{cache_user_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_userdetails_size '{ ${'\''zarafa-server'\''}{cache_userdetails_size} || '\''26214400'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_userdetails_lifetime '{ ${'\''zarafa-server'\''}{cache_userdetails_lifetime} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_server_size '{ ${'\''zarafa-server'\''}{cache_server_size} || '\''1048576'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg cache_server_lifetime '{ ${'\''zarafa-server'\''}{cache_server_lifetime} || '\''30'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg quota_warn '{ ${'\''zarafa-server'\''}{quota_warn} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg quota_soft '{ ${'\''zarafa-server'\''}{quota_soft} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg quota_hard '{ ${'\''zarafa-server'\''}{quota_hard} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg companyquota_warn '{ ${'\''zarafa-server'\''}{companyquota_warn} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg user_plugin '{ ${'\''zarafa-server'\''}{user_plugin} || '\''db'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg user_plugin_config '{ ${'\''zarafa-server'\''}{user_plugin_config}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg user_safe_mode '{ ${'\''zarafa-server'\''}{user_safe_mode} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg thread_stacksize '{ ${'\''zarafa-server'\''}{thread_stacksize} || '\''512'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_hosted_zarafa '{ ${'\''zarafa-server'\''}{enable_hosted_zarafa} || '\''false'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_distributed_zarafa '{ ${'\''zarafa-server'\''}{enable_distributed_zarafa} || '\''false'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg storename_format '{ ${'\''zarafa-server'\''}{storename_format} || '\''%f'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg loginname_format '{ ${'\''zarafa-server'\''}{loginname_format} || '\''%u'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg client_update_enabled '{ ${'\''zarafa-server'\''}{client_update_enabled} || '\''false'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg client_update_path '{ ${'\''zarafa-server'\''}{client_update_path} || '\''/var/lib/zarafa/client'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg client_update_log_level '{ ${'\''zarafa-server'\''}{client_update_log_level} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg hide_everyone '{ ${'\''zarafa-server'\''}{hide_everyone} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg hide_system '{ ${'\''zarafa-server'\''}{hide_system} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg index_services_enabled '{ ${'\''zarafa-server'\''}{index_services_enabled} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg index_services_search_timeout '{ ${'\''zarafa-server'\''}{index_services_search_timeout} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg index_services_prefix_chars '{ ${'\''zarafa-server'\''}{index_services_prefix_chars} || '\''3'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg enable_enhanced_ics '{ ${'\''zarafa-server'\''}{enable_enhanced_ics} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg sync_gab_realtime '{ ${'\''zarafa-server'\''}{sync_gab_realtime} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg disabled_features '{ ${'\''zarafa-server'\''}{disabled_features}; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg max_deferred_records '{ ${'\''zarafa-server'\''}{max_deferred_records} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/server.cfg/server.cfg max_deferred_records_folder '{ ${'\''zarafa-server'\''}{max_deferred_records_folder} || '\''20'\''; }'


#
#--- dagent config ---
#
echo
echo "Creating zarafa-dagent-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/dagent.cfg
cat /usr/share/doc/zarafa-dagent/example-config/dagent.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_method '{ ${'\''zarafa-dagent'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_level '{ ${'\''zarafa-dagent'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_timestamp '{ ${'\''zarafa-dagent'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg log_raw_message '{ ${'\''zarafa-dagent'\''}{log_raw_message} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg lmtp_port '{ ${'\''zarafa-dagent'\''}{lmtp_port} || '\''2003'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg lmtp_max_threads '{ ${'\''zarafa-dagent'\''}{lmtp_max_threads} || '\''20'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg process_model '{ ${'\''zarafa-dagent'\''}{process_model} || '\''fork'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg spam_header_name '{ ${'\''zarafa-dagent'\''}{spam_header_name} || '\''X-Spam-Status'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg spam_header_value '{ ${'\''zarafa-dagent'\''}{spam_header_value} || '\''Yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg archive_on_delivery '{ ${'\''zarafa-dagent'\''}{archive_on_delivery} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/dagent.cfg/dagent.cfg set_rule_headers '{ ${'\''zarafa-dagent'\''}{set_rule_headers} || '\''yes'\''; }'


#
#--- spooler config ---
#
echo
echo "Creating zarafa-spooler-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/spooler.cfg
cat /usr/share/doc/zarafa-spooler/example-config/spooler.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg smtp_port '{ ${'\''zarafa-spooler'\''}{smtp_port} || '\''25'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg log_method '{ ${'\''zarafa-spooler'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg log_level '{ ${'\''zarafa-spooler'\''}{log_level} || '\''3'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg log_timestamp '{ ${'\''zarafa-spooler'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg max_threads '{ ${'\''zarafa-spooler'\''}{max_threads} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg fax_domain '{ ${'\''zarafa-spooler'\''}{fax_domain} || '\''fax.local'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg fax_international '{ ${'\''zarafa-spooler'\''}{fax_international} || '\''00'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg always_send_delegates '{ ${'\''zarafa-spooler'\''}{always_send_delegates} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg allow_redirect_spoofing '{ ${'\''zarafa-spooler'\''}{allow_redirect_spoofing} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg copy_delegate_mails '{ ${'\''zarafa-spooler'\''}{copy_delegate_mails} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg allow_delegate_meeting_request '{ ${'\''zarafa-spooler'\''}{allow_delegate_meeting_request} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg allow_send_to_everyone '{ ${'\''zarafa-spooler'\''}{allow_send_to_everyone} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg always_send_tnef '{ ${'\''zarafa-spooler'\''}{always_send_tnef} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg always_send_utf8 '{ ${'\''zarafa-spooler'\''}{always_send_utf8} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg charset_upgrade '{ ${'\''zarafa-spooler'\''}{charset_upgrade} || '\''windows-1252'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg expand_groups '{ ${'\''zarafa-spooler'\''}{expand_groups} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/spooler.cfg/spooler.cfg archive_on_send '{ ${'\''zarafa-spooler'\''}{archive_on_send} || '\''no'\''; }'


#
#--- monitor config ---
#
echo
echo "Creating zarafa-monitor-configuration-template ..."
echo "The monitor program sends quota warning mails to users who are over quota."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/monitor.cfg
cat /usr/share/doc/zarafa-monitor/example-config/monitor.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg log_method '{ ${'\''zarafa-monitor'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg log_level '{ ${'\''zarafa-monitor'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg log_timestamp '{ ${'\''zarafa-monitor'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg quota_check_interval '{ ${'\''zarafa-monitor'\''}{quota_check_interval} || '\''15'\''; }'
replace /etc/e-smith/templates/etc/zarafa/monitor.cfg/monitor.cfg mailquota_resend_interval '{ ${'\''zarafa-monitor'\''}{mailquota_resend_interval} || '\''1'\''; }'


#
#--- gateway config ---
#
echo
echo "Creating zarafa-gateway-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/gateway.cfg
cat /usr/share/doc/zarafa-gateway/example-config/gateway.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg server_socket 'http://localhost:{${'\''zarafa-server'\''}{TCPPort}||'\''236'\'';}/zarafa'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3_enable '{ if (${'\''zarafa-pop3'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3_port '{ ${'\''zarafa-pop3'\''}{TCPPort} || '\''8110'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3s_enable '{ if (${'\''zarafa-pop3s'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg pop3s_port '{ ${'\''zarafa-pop3s'\''}{TCPPort} || '\''8995'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_enable '{ if (${'\''zarafa-imap'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_port '{ ${'\''zarafa-imap'\''}{TCPPort} || '\''8143'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imaps_enable '{ if (${'\''zarafa-imaps'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imaps_port '{ ${'\''zarafa-imaps'\''}{TCPPort} || '\''8993'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_only_mailfolders '{ ${'\''zarafa-imap'\''}{imap_only_mailfolders} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_public_folders '{ ${'\''zarafa-imap'\''}{imap_public_folders} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_capability_idle '{ ${'\''zarafa-imap'\''}{imap_capability_idle} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_max_messagesize '{ ${'\''zarafa-imap'\''}{imap_max_messagesize} || '\''134217728'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_generate_utf8 '{ ${'\''zarafa-imap'\''}{imap_generate_utf8} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_expunge_on_delete '{ ${'\''zarafa-imap'\''}{imap_expunge_on_delete} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg imap_store_rfc822 '{ ${'\''zarafa-imap'\''}{imap_store_rfc822} || '\''yes'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg ssl_private_key_file '/home/e-smith/ssl.key/{$SystemName}.{$DomainName}.key'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg ssl_certificate_file '/home/e-smith/ssl.crt/{$SystemName}.{$DomainName}.crt'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg ssl_verify_client '{ ${'\''zarafa-gateway'\''}{ssl_verify_client} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg process_model '{ ${'\''zarafa-gateway'\''}{process_model} || '\''fork'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg log_method '{ ${'\''zarafa-gateway'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg log_level '{ ${'\''zarafa-gateway'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/gateway.cfg/gateway.cfg log_timestamp '{ ${'\''zarafa-gateway'\''}{log_timestamp} || '\''1'\''; }'


#
#--- ical config ---
#
echo
echo "Creating zarafa-ical-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/ical.cfg
cat /usr/share/doc/zarafa-ical/example-config/ical.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ical_enable '{ if (${'\''zarafa-ical'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ical_port '{ ${'\''zarafa-ical'\''}{TCPPort} || '\''8088'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg icals_enable '{ if (${'\''zarafa-icals'\''}{status} eq '\''enabled'\'') {'\''yes'\''} else {'\''no'\''}; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg icals_port '{ ${'\''zarafa-icals'\''}{TCPPort} || '\''8089'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg server_socket 'http://localhost:{${'\''zarafa-server'\''}{TCPPort}||'\''236'\'';}/zarafa'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg process_model '{ ${'\''zarafa-ical'\''}{process_model} || '\''fork'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg log_method '{ ${'\''zarafa-ical'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg log_level '{ ${'\''zarafa-ical'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg log_timestamp '{ ${'\''zarafa-ical'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ssl_private_key_file '/home/e-smith/ssl.key/{$SystemName}.{$DomainName}.key'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ssl_certificate_file '/home/e-smith/ssl.crt/{$SystemName}.{$DomainName}.crt'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg ssl_verify_client '{ ${'\''zarafa-ical'\''}{ssl_verify_client} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg server_timezone '{$TimeZone}'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg default_charset '{ ${'\''zarafa-ical'\''}{default_charset} || '\''utf-8'\''; }'
replace /etc/e-smith/templates/etc/zarafa/ical.cfg/ical.cfg enable_ical_get '{ ${'\''zarafa-ical'\''}{enable_ical_get} || '\''yes'\''; }'


#
#--- indexer config ---
#
echo
echo "Creating zarafa-indexer-configuration-template ..."
echo
mkdir -p /etc/e-smith/templates/etc/zarafa/indexer.cfg
cat /usr/share/doc/zarafa-indexer/example-config/indexer.cfg | sed -e 's/\r$//g' >  /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg cleanup_lockfiles '{ ${'\''zarafa-indexer'\''}{cleanup_lockfiles} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg limit_results	'{ ${'\''zarafa-indexer'\''}{limit_results} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg log_method '{ ${'\''zarafa-indexer'\''}{log_method} || '\''file'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg log_level '{ ${'\''zarafa-indexer'\''}{log_level} || '\''2'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg log_timestamp '{ ${'\''zarafa-indexer'\''}{log_timestamp} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_interval '{ ${'\''zarafa-indexer'\''}{index_interval} || '\''5'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_threads '{ ${'\''zarafa-indexer'\''}{index_threads} || '\''1'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_max_field_length '{ ${'\''zarafa-indexer'\''}{index_max_field_length} || '\''10000'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_merge_factor '{ ${'\''zarafa-indexer'\''}{index_merge_factor} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_max_buffered_docs '{ ${'\''zarafa-indexer'\''}{index_max_buffered_docs} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_min_merge_docs '{ ${'\''zarafa-indexer'\''}{index_min_merge_docs} || '\''10'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_max_merge_docs '{ ${'\''zarafa-indexer'\''}{index_max_merge_docs} || '\''2147483647'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_term_interval '{ ${'\''zarafa-indexer'\''}{index_term_interval} || '\''128'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_cache_timeout '{ ${'\''zarafa-indexer'\''}{index_cache_timeout} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachments '{ ${'\''zarafa-indexer'\''}{index_attachments} || '\''no'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachment_max_size '{ ${'\''zarafa-indexer'\''}{index_attachment_max_size} || '\''5120'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachment_parser_max_memory '{ ${'\''zarafa-indexer'\''}{index_attachment_parser_max_memory} || '\''0'\''; }'
replace /etc/e-smith/templates/etc/zarafa/indexer.cfg/indexer.cfg index_attachment_parser_max_cputime '{ ${'\''zarafa-indexer'\''}{index_attachment_parser_max_cputime} || '\''0'\''; }'


/bin/echo "webaccess config"
/bin/chown -R www:www /var/lib/zarafa-webaccess/tmp
/bin/chown -R www:www /var/lib/zarafa-webapp/tmp
FILE=/etc/httpd/conf.d/zarafa-webaccess.conf; if [ -a $FILE ]; then /bin/rm -f $FILE; fi
FILE=/etc/httpd/conf.d/zarafa-webapp.conf; if [ -a $FILE ]; then /bin/rm -f $FILE; fi


/bin/echo "Expanding Zarafa-templates"
/etc/e-smith/events/actions/zarafa-expand-templates

/bin/echo "Expanding http.conf-template"
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

/bin/echo "Restarting httpd"
/usr/bin/sv restart /service/httpd-e-smith

/bin/echo "Starting Zarafa-services"
/etc/e-smith/events/actions/zarafa-services start

/bin/echo "Setting permissions on files"
FILE=/var/log/zarafa/dagent.log; if [ -a $FILE ]; then /bin/chmod 666 $FILE; fi

To save :
CTRL + X
yes
<ENTER>
Execute zarafa-install (see script above)
/bin/chmod 554 /etc/e-smith/events/actions/zarafa-install
cd /etc/e-smith/events/actions/
./zarafa-install
signal-event post-upgrade; signal-event reboot

UPGRADING of Zarafa (7.0.x -> 7.0.x)

Download via the Zarafawebsite the package for ZCP corresponding with the newest php53-mapi.rpm (cf. version above)

cd /to an installdirectory, ex. : /root/InstallZarafa

wget http://download.zarafa.com/community/final/7.0/[version]/zcp-[version]-rhel-5-[cpu-arch]-free.tar.gz
Unpack the corresponding package for ZCP :

Go (cd /...) to the installdirectory (if you haven't done this yet) :

cd /to the installdirectory

And unpack :

tar -zxvf zcp-*
Go (cd ./zcp-...) to the created subdirectory (zcp-...) :
cd ./zcp- ... 
Remove the devel packages
Move the windows-directory to an installshare in your network
Download the latest webapp.rpm too in the same subdirectory :
wget http://download.zarafa.com/community/final/WebApp/[version]/rhel/[zarafa-webapp-version.noarch.rpm]
Remove the existing php53-mapi.rpm first :
rpm -e php53-mapi --nodeps
Install all rpm's in the unpacked package of ZCP and the webapp.rpm too :
yum localinstall *.rpm

All packages have dependencies that cannot be resolved if you install only part of the rpm's.

If you only want to upgrade one package (ex. the Webapp) :

cd /to the new Webapp.rpm
rpm -Uvh --force zarafa-webapp-[version].noarch
Remove the default php-mapi.rpm

We have to remove the installation of the default php-mapi (because it's not built for php 5.3).

rpm -e php-mapi --nodeps
Install the php53-mapi.rpm

Install the php53-mapi.rpm of the EPEL-repository :

-If you downloaded the rpm :

rpm -Uvh --force php53-mapi

-If you did set the EPEL-repository :

yum install php53-mapi --enablerepo=epel --enablerepo=epel-testing
Execute zarafa-update (see script above !!!)
cd /etc/e-smith/events/actions/
./zarafa-update

OPTIONAL : Search in the Zarafa-releasenotes for new keys/options in the config-files and adjust the values of these new keys/options in the zarafa-config-templates :

http://doc.zarafa.com/7.0/Release_Notes/en-US/html-single/
signal-event post-upgrade; signal-event reboot

Z-PUSH

INSTALLATION of Z-push (1.5.x or 2.0.x)

VERSION 1.5
Download the Z-push-package (version 1.5 !!)
wget http://zarafa-deutschland.de/z-push-download/final/1.5/[z-push-latest version]

Save in an installdirectory, ex. : root/InstallZPush


Unpack the package for Z-push :

Go (cd /...) to the installdirectory (if you haven't done this yet) :

cd /to the installdirectory

And unpack :

tar -zxvf z-push-[latest version] -C /var/www/html
Change the name of the created z-push-directory in /var/www/html to 'z-push'
nano -w /etc/e-smith/events/actions/z-push-install
#!/bin/sh

#
#--- /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases ---
#
echo
echo "Creating /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases ..."
echo
cat <<HERE1 > /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases
{
    # vim: ft=perl:

    \$haveSSL = (exists \${modSSL}{status} and \${modSSL}{status} eq "enabled") ?  'yes' : 'no';
    my \$zwebmailStatus = \$zarafa{'status'} || "disabled";
    my \$zwebmailAccessType = \$zarafa{'access'} || "SSL";

    my \$dirs;
    \$dirs{zarafa} = '/usr/share/zarafa-webaccess';
    \$dirs{webaccess} = '/usr/share/zarafa-webaccess';
    \$dirs{webmail} = '/usr/share/zarafa-webaccess';
    if (\$imp{'status'} eq 'enabled') {\$dirs{webmail} = ''};
    \$dirs{webapp} = '/usr/share/zarafa-webapp';
    \$dirs{'Microsoft-Server-ActiveSync'} = '/var/www/html/z-push/index.php';

    return "    # Zarafa is disabled in this VirtualHost\n"
                unless \$zwebmailStatus eq 'enabled';

    foreach \$place ('zarafa','webmail','webaccess','webapp','Microsoft-Server-ActiveSync')
    {
        if ((\$port eq "80") && (\$haveSSL eq 'yes') && (\$zwebmailAccessType eq 'SSL'))
        {
            \$OUT .= "    RewriteRule ^/\$place(/.*|\\$)    https://%{HTTP_HOST}/\$place\\\$1 [L,R]\n";
        } else {
            if ((\$dirs{\$place}) ne '') {\$OUT .= "    Alias	 /\$place   \$dirs{\$place}\n"};
        }
    }																		
}
HERE1

#
#--- /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias ---
#
echo
echo "Creating /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias ..."
echo
cat <<HERE2 > /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias
{
    my \$zstatus = \$zarafa{'status'};

    if (defined \$zstatus && \$zstatus eq 'enabled')
    {
        \$OUT .= qq(
#--------------------------------------------------------------------
# Zarafa specific configuration files.
#--------------------------------------------------------------------

Alias /zarafa /usr/share/zarafa-webaccess/
 <Directory /usr/share/zarafa-webaccess/>
  Options -Indexes
  AllowOverride All
  order allow,deny
  allow from all
  AddType application/x-httpd-php .php
  php_flag magic_quotes_gpc off
  php_flag track_vars on
 </Directory>

Alias /webapp /usr/share/zarafa-webapp/
 <Directory /usr/share/zarafa-webapp/>
  Options -Indexes
  AllowOverride All
  order allow,deny
  allow from all
  AddType application/x-httpd-php .php
  php_flag magic_quotes_gpc off
  php_flag track_vars on
 </Directory>
	    
<Directory /var/www/html/>
    Options -Indexes
    AllowOverride All
    order allow,deny
    allow from all
    AddType application/x-httpd-php .php .php3
    php_flag  magic_quotes_gpc  off
 </Directory>

<Directory /var/www/html/z-push/>
   Options -Indexes
   AllowOverride All
   order allow,deny
   allow from all
   AddType application/x-httpd-php .php
   php_flag magic_quotes_gpc off
   php_flag register_globals off
   php_flag magic_quotes_runtime off
   php_flag short_open_tag on
 </Directory>

);
    }    
    else
    {
       \$OUT .= "# Zarafa Webmail is not configured as it is disabled in the config db";
    }
}
HERE2

######################################
# Configuration of Z-push
######################################

/bin/echo
/bin/echo "Configuration of Z-push"
/bin/echo
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chown -R www:www $FILE; fi
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chmod 755 $FILE; fi

/bin/echo 
/bin/echo "Need to debug Z-push ?"
/bin/echo "Values: yes or no."
/bin/echo 
read DEBUGZPUSH
if [ "$DEBUGZPUSH" == yes ]; then
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/touch /var/www/html/z-push/debug.txt; fi
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chown www:www /var/www/html/z-push/debug.txt; fi
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chmod 755 /var/www/html/z-push/debug.txt; fi
else
rm -f /var/www/html/z-push/debug.txt
fi

/bin/echo
/bin/echo "Expanding http.conf-template"
/bin/echo
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

/bin/echo
/bin/echo "Restarting httpd"
/bin/echo
/usr/bin/sv restart /service/httpd-e-smith


To save :
CTRL + X
yes
<ENTER>
nano -w /etc/e-smith/events/actions/z-push-update
#!/bin/sh

######################################
# Configuration of Z-push
######################################

/bin/echo
/bin/echo "Configuration of Z-push"
/bin/echo
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chown -R www:www $FILE; fi
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chmod 755 $FILE; fi

/bin/echo 
/bin/echo "Need to debug Z-push ?"
/bin/echo "Values: yes or no."
/bin/echo 
read DEBUGZPUSH
if [ "$DEBUGZPUSH" == yes ]; then
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/touch /var/www/html/z-push/debug.txt; fi
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chown www:www /var/www/html/z-push/debug.txt; fi
FILE=/var/www/html/z-push/state; if [ -d $FILE ]; then /bin/chmod 755 /var/www/html/z-push/debug.txt; fi
else
rm -f /var/www/html/z-push/debug.txt
fi

/bin/echo
/bin/echo "Expanding http.conf-template"
/bin/echo
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

/bin/echo
/bin/echo "Restarting httpd"
/bin/echo
/usr/bin/sv restart /service/httpd-e-smith


To save :
CTRL + X
yes
<ENTER>
See further : "Any version"
VERSION 2.0
Download the Z-push-package (version 2.0 !!)
wget http://zarafa-deutschland.de/z-push-download/final/2.0/[z-push-latest version]

Save in an installdirectory, ex. : root/InstallZPush

Unpack the package for Z-push :

Go (cd /...) to the installdirectory (if you haven't done this yet) :

cd /to the installdirectory

And unpack :

tar -zxvf z-push-[latest version] -C /usr/share
Change the name of the created z-push-directory in /usr/share to 'z-push'
nano -w /etc/e-smith/events/actions/z-push-install
#!/bin/sh

#
#--- /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases ---
#
echo
echo "Creating /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases ..."
echo
cat <<HERE1 > /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/29ZarafaAliases
{
    # vim: ft=perl:

    \$haveSSL = (exists \${modSSL}{status} and \${modSSL}{status} eq "enabled") ?  'yes' : 'no';
    my \$zwebmailStatus = \$zarafa{'status'} || "disabled";
    my \$zwebmailAccessType = \$zarafa{'access'} || "SSL";

    my \$dirs;
    \$dirs{zarafa} = '/usr/share/zarafa-webaccess';
    \$dirs{webaccess} = '/usr/share/zarafa-webaccess';
    \$dirs{webmail} = '/usr/share/zarafa-webaccess';
    if (\$imp{'status'} eq 'enabled') {\$dirs{webmail} = ''};
    \$dirs{webapp} = '/usr/share/zarafa-webapp';
    \$dirs{'Microsoft-Server-ActiveSync'} = '/usr/share/z-push/index.php';

    return "    # Zarafa is disabled in this VirtualHost\n"
                unless \$zwebmailStatus eq 'enabled';

    foreach \$place ('zarafa','webmail','webaccess','webapp','Microsoft-Server-ActiveSync')
    {
        if ((\$port eq "80") && (\$haveSSL eq 'yes') && (\$zwebmailAccessType eq 'SSL'))
        {
            \$OUT .= "    RewriteRule ^/\$place(/.*|\\$)    https://%{HTTP_HOST}/\$place\\\$1 [L,R]\n";
        } else {
            if ((\$dirs{\$place}) ne '') {\$OUT .= "    Alias	 /\$place   \$dirs{\$place}\n"};
        }
    }																		
}
HERE1

#
#--- /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias ---
#
echo
echo "Creating /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias ..."
echo
cat <<HERE2 > /etc/e-smith/templates/etc/httpd/conf/httpd.conf/86ZarafaAlias
{
    my \$zstatus = \$zarafa{'status'};

    if (defined \$zstatus && \$zstatus eq 'enabled')
    {
        \$OUT .= qq(
#--------------------------------------------------------------------
# Zarafa specific configuration files.
#--------------------------------------------------------------------

Alias /zarafa /usr/share/zarafa-webaccess/
 <Directory /usr/share/zarafa-webaccess/>
  Options -Indexes
  AllowOverride All
  order allow,deny
  allow from all
  AddType application/x-httpd-php .php
  php_flag magic_quotes_gpc off
  php_flag track_vars on
 </Directory>

Alias /webapp /usr/share/zarafa-webapp/
 <Directory /usr/share/zarafa-webapp/>
  Options -Indexes
  AllowOverride All
  order allow,deny
  allow from all
  AddType application/x-httpd-php .php
  php_flag magic_quotes_gpc off
  php_flag track_vars on
 </Directory>

<Directory /usr/share/z-push/>
   Options -Indexes
   AllowOverride All
   order allow,deny
   allow from all
   AddType application/x-httpd-php .php .php3
   php_flag magic_quotes_gpc off
   php_flag register_globals off
   php_flag magic_quotes_runtime off
   php_flag short_open_tag on
 </Directory>

);
    }    
    else
    {
       \$OUT .= "# Zarafa Webmail is not configured as it is disabled in the config db";
    }
}
HERE2

######################################
# Configuration of Z-push
######################################

/bin/echo
/bin/echo "Configuration of Z-push"
/bin/echo
mkdir -p /var/lib/z-push
mkdir -p /var/log/z-push 
FILE=/var/lib/z-push; if [ -d $FILE ]; then /bin/chown -R www:www $FILE; fi
FILE=/var/lib/z-push; if [ -d $FILE ]; then /bin/chmod 755 $FILE; fi
FILE=/var/log/z-push; if [ -d $FILE ]; then /bin/chown -R www:www $FILE; fi
FILE=/var/log/z-push; if [ -d $FILE ]; then /bin/chmod 755 $FILE; fi

/bin/echo
/bin/echo "Expanding http.conf-template"
/bin/echo
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

/bin/echo
/bin/echo "Restarting httpd"
/bin/echo
/usr/bin/sv restart /service/httpd-e-smith


To save :
CTRL + X
yes
<ENTER>
nano -w /etc/e-smith/events/actions/z-push-update
#!/bin/sh

######################################
# Configuration of Z-push
######################################

/bin/echo
/bin/echo "Configuration of Z-push"
/bin/echo
mkdir -p /var/lib/z-push
mkdir -p /var/log/z-push
FILE=/var/lib/z-push; if [ -d $FILE ]; then /bin/chown -R www:www $FILE; fi
FILE=/var/lib/z-push; if [ -d $FILE ]; then /bin/chmod 755 $FILE; fi
FILE=/var/log/z-push; if [ -d $FILE ]; then /bin/chown -R www:www $FILE; fi
FILE=/var/log/z-push; if [ -d $FILE ]; then /bin/chmod 755 $FILE; fi

/bin/echo
/bin/echo "Expanding http.conf-template"
/bin/echo
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

/bin/echo
/bin/echo "Restarting httpd"
/bin/echo
/usr/bin/sv restart /service/httpd-e-smith


To save :
CTRL + X
yes
<ENTER>
See further : "Any version"
ANY VERSION (1.5 or 2.0)
Edit the config.php file in the Z-Push directory to fit your needs.

ex. Set your timezone in the config.php file.

Execute z-push-install (see script above)
/bin/chmod 554 /etc/e-smith/events/actions/z-push-install
cd /etc/e-smith/events/actions/
./z-push-install

UPGRADING of Z-push

VERSION 1.5 (1.5.x -> 1.5.x)
Download the Z-push-package (version 1.5 !!)
wget http://zarafa-deutschland.de/z-push-download/final/1.5/[z-push-latest version]

Save in an installdirectory, ex. : root/InstallZPush

Unpack the corresponding package for ZCP and the package for Z-push :

Go (cd /...) to the installdirectory (if you haven't done this yet) :

cd /to the installdirectory

And unpack :

tar -zxvf z-push-[latest version] -C /var/www/html
Change the name of the created z-push-directory in /var/www/html to 'z-push'
See further : "Any version"
VERSION 2.0 (2.0.x -> 2.0.x)
Download the Z-push-package (version 2.0 !!)
wget http://zarafa-deutschland.de/z-push-download/final/2.0/[z-push-latest version]

Save in an installdirectory, ex. : root/InstallZPush


Unpack the package for Z-push :

Go (cd /...) to the installdirectory (if you haven't done this yet) :

cd /to the installdirectory

And unpack :

tar -zxvf z-push-[latest version] -C /usr/share
Change the name of the created z-push-directory in /usr/share to 'z-push'
See further : "Any version"
VERSION 1.5 -> 2.0

The easiest way to upgrade is to follow the steps for a new installation of version 2.0. The states of Z-Push 1.X are not compatible and there is no upgrade path, but as this version implements a fully automatic resynchronisation of devices it should not affect the users and work without the user interaction

ANY VERSION
Edit the config.php file in the Z-Push directory to fit your needs.

ex. Set your timezone in the config.php file.

Execute z-push-update (see script above !!!!)
/bin/chmod 554 /etc/e-smith/events/actions/z-push-update
cd /etc/e-smith/events/actions/
./z-push-update