From ff1d9a79ff1859c0efc00b32e0d911ef5de05d71 Mon Sep 17 00:00:00 2001
From: wyrie <wyrie@ispconfig3>
Date: Mon, 11 Oct 2010 08:54:14 +0000
Subject: [PATCH] Installer: Gentoo updates
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

• Added configure_dovecot function
• Updated functions configure_postfix, configure_pureftpd, configure_apache, install_ispconfig, configure_apps_vhost
• Bug fix in configure_amavis where installer was not including the ispconfig config file
• Bug fix in configure_apache where in suphp.conf the php handler line would be duplicated through updates
• replace double-quoted strings with single-quoted whenever appropriate
• changed inline comments to coding standards
• fixed OS specific paths
• changes to installer_base 1) add_database_server_record added os specific override of awstats paths 2) find_installed_apps courier not detecting correctly for gentoo
---
 install/dist/conf/gentoo.conf.php             |  28 +-
 install/dist/lib/gentoo.lib.php               | 352 +++++++++++-------
 .../dist/tpl/gentoo/apache_apps.vhost.master  |  45 +++
 .../gentoo/apache_apps_fcgi_starter.master    |   6 +
 .../tpl/gentoo/apache_ispconfig.vhost.master  |  67 ++++
 .../apache_ispconfig_fcgi_starter.master      |   6 +
 install/dist/tpl/gentoo/dovecot.conf.master   |  96 +++++
 install/lib/installer_base.lib.php            |   8 +-
 8 files changed, 459 insertions(+), 149 deletions(-)
 create mode 100644 install/dist/tpl/gentoo/apache_apps.vhost.master
 create mode 100644 install/dist/tpl/gentoo/apache_apps_fcgi_starter.master
 create mode 100644 install/dist/tpl/gentoo/apache_ispconfig.vhost.master
 create mode 100644 install/dist/tpl/gentoo/apache_ispconfig_fcgi_starter.master
 create mode 100644 install/dist/tpl/gentoo/dovecot.conf.master

diff --git a/install/dist/conf/gentoo.conf.php b/install/dist/conf/gentoo.conf.php
index c6a6dbd170..1fd634ac3e 100644
--- a/install/dist/conf/gentoo.conf.php
+++ b/install/dist/conf/gentoo.conf.php
@@ -88,8 +88,8 @@ $conf['apache']['vhost_conf_dir'] = $conf['apache']['config_dir'] . '/vhosts.d';
 $conf['apache']['vhost_conf_enabled_dir'] = $conf['apache']['vhost_conf_dir']; 
 $conf['apache']['vhost_default'] = '00_default_vhost.conf';
 $conf['apache']['vhost_port'] = '8080';
-$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
-$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
+$conf['apache']['php_ini_path_apache'] = '/etc/php/apache2-php5/php.ini';
+$conf['apache']['php_ini_path_cgi'] = '/etc/php/cgi-php5/php.ini';
 
 //* Website base settings
 $conf['web']['website_basedir'] = '/var/www';
@@ -103,24 +103,14 @@ $conf['web']['apps_vhost_servername'] = '';
 $conf['web']['apps_vhost_user'] = 'ispapps';
 $conf['web']['apps_vhost_group'] = 'ispapps';
 
-//* Fastcgi
-$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php/cgi-php5';
-//TODO do fastcgi setup
-$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
-//* Website base settings
-$conf['web']['website_basedir'] = '/var/www';
-$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
-$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
-
-//* Apps base settings
-$conf['web']['apps_vhost_ip'] = '_default_';
-$conf['web']['apps_vhost_port'] = '8081';
-$conf['web']['apps_vhost_servername'] = '';
-$conf['web']['apps_vhost_user'] = 'ispapps';
-$conf['web']['apps_vhost_group'] = 'ispapps';
+//* Awstats settings
+$conf['awstats']['conf_dir'] = '/etc/awstats';
+$conf['awstats']['data_dir'] = '/var/lib/awstats';
+$conf['awstats']['pl'] = '/usr/bin/awstats.pl';
+$conf['awstats']['buildstaticpages_pl'] = '/usr/bin/awstats_buildstaticpages.pl';
 
 //* Fastcgi
-$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
+$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php/cgi-php5';
 $conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
 
 //* Postfix
@@ -191,7 +181,7 @@ $conf['powerdns']['init_script'] = 'pdns.local';
 //* BIND DNS Server
 $conf['bind']['installed'] = false; // will be detected automatically during installation
 $conf['bind']['bind_user'] = 'root';
-$conf['bind']['bind_group'] = 'bind';
+$conf['bind']['bind_group'] = 'named';
 $conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
 $conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
 $conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
diff --git a/install/dist/lib/gentoo.lib.php b/install/dist/lib/gentoo.lib.php
index e6f4a0999b..b9899085f6 100644
--- a/install/dist/lib/gentoo.lib.php
+++ b/install/dist/lib/gentoo.lib.php
@@ -36,15 +36,15 @@ class installer extends installer_base
 		
 		if (is_dir($conf['jailkit']['config_dir']))
 		{
-			$jkinit_content = $this->get_template_file($conf['jailkit']['jk_init'], true); // get contents
+			$jkinit_content = $this->get_template_file($conf['jailkit']['jk_init'], true); //* get contents
 			$this->write_config_file($conf['jailkit']['config_dir'] . '/' . $conf['jailkit']['jk_init'], $jkinit_content);
 			
-			$jkchroot_content = $this->get_template_file($conf['jailkit']['jk_chrootsh'], true); // get contents
+			$jkchroot_content = $this->get_template_file($conf['jailkit']['jk_chrootsh'], true); //* get contents
 			$this->write_config_file($conf['jailkit']['config_dir'] . '/' . $conf['jailkit']['jk_chrootsh'], $jkchroot_content);
 		}
 		
-		$command = "chown root:root /var/www";
-		caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+		$command = 'chown root:root /var/www';
+		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
     }
 	
 	public function configure_postfix($options = '')
@@ -58,18 +58,18 @@ class installer extends installer_base
             $this->error("The postfix configuration directory '$config_dir' does not exist.");
         }
         
-        // Install virtual mappings
-        foreach (glob("tpl/mysql-virtual_*.master") as $filename) {
-        	$this->process_postfix_config( basename($filename, ".master") );
+        //* Install virtual mappings
+        foreach (glob('tpl/mysql-virtual_*.master') as $filename) {
+        	$this->process_postfix_config( basename($filename, '.master') );
         }
         
-		// Changing mode and group of the new created config files.
+		//* Changing mode and group of the new created config files.
 		caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                  __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
 		caselog('chgrp '.$cf['group'].' '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null', 
                 __FILE__, __LINE__, 'chgrp on mysql-virtual_*.cf*', 'chgrp on mysql-virtual_*.cf* failed');
 		
-		// Creating virtual mail user and group
+		//* Creating virtual mail user and group
 		$command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
 		if (!is_group($cf['vmail_groupname'])) {
 			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
@@ -101,6 +101,7 @@ class installer extends installer_base
 			'smtpd_tls_key_file = '.$config_dir.'/smtpd.key',
 			'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf',
 			'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf',
+		    'relay_recipient_maps = mysql:'.$config_dir.'/mysql-virtual_relayrecipientmaps.cf',
 			'virtual_create_maildirsize = yes',
 			'virtual_maildir_extended = yes',
 			'virtual_mailbox_limit_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailbox_limit_maps.cf',
@@ -119,23 +120,23 @@ class installer extends installer_base
 			'body_checks = regexp:'.$config_dir.'/body_checks'
 		);
 		
-		// Create the header and body check files
+		//* Create the header and body check files
 		touch($config_dir.'/header_checks');
 		touch($config_dir.'/mime_header_checks');
 		touch($config_dir.'/nested_header_checks');
 		touch($config_dir.'/body_checks');
 		
 		
-		// Make a backup copy of the main.cf file
+		//* Make a backup copy of the main.cf file
 		copy($config_dir.'/main.cf', $config_dir.'/main.cf~');
 		
-		// Executing the postconf commands
+		//* Executing the postconf commands
 		foreach($postconf_commands as $cmd) {
 			$command = "postconf -e '$cmd'";
-			caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
+			caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
 		}
 		
-		// Create the SSL certificate
+		//* Create the SSL certificate
 		if (!stristr($options,'dont-create-certs'))  
 		{
 			$command = 'cd '.$config_dir.'; '
@@ -146,11 +147,13 @@ class installer extends installer_base
 			caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
 		}
 		
-		// We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop.
-		$command = 'chmod 755  /var/run/courier/authdaemon/';
-		caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
+		//* We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop.
+		$command = 'chmod 755  /var/lib/courier/authdaemon/';
+		if (is_dir('/var/lib/courier/authdaemon')) {
+			caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
+		}
 		
-		// Changing maildrop lines in posfix master.cf
+		//* Changing maildrop lines in posfix master.cf
 		$configfile = $config_dir.'/master.cf';
 		$content = rf($configfile);
 
@@ -161,20 +164,20 @@ class installer extends installer_base
         						
 		$this->write_config_file($configfile, $content);
 		
-		// Writing the Maildrop mailfilter file
-		$content = rf("tpl/mailfilter.master");
+		//* Writing the Maildrop mailfilter file
+		$content = rf('tpl/mailfilter.master');
 		$content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content);
 		
 		$this->write_config_file($cf['vmail_mailbox_base'].'/.mailfilter', $content);
 		
-		// Create the directory for the custom mailfilters
+		//* Create the directory for the custom mailfilters
 		if (!is_dir($cf['vmail_mailbox_base'].'/mailfilters')) 
 		{
 			$command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters';
-			caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		}
 		
-		// Chmod and chown the .mailfilter file
+		//* Chmod and chown the .mailfilter file
 		$command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
 		caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
@@ -187,38 +190,93 @@ class installer extends installer_base
 	{
 		global $conf;
 	
-		$content = $this->get_template_file('sasl_smtpd.conf', true, true); // get contents & insert db cred
+		$content = $this->get_template_file('sasl_smtpd.conf', true, true); //* get contents & insert db cred
 		$this->write_config_file($conf['saslauthd']['config_dir'].'/smtpd.conf', $content);
 		
-		// Edit the file saslauthd config file
-		$content = rf($conf["saslauthd"]["config_file"]);
+		//* Edit the file saslauthd config file
+		$content = rf($conf['saslauthd']['config_file']);
 		$content = preg_replace('/(?<=\n)SASLAUTHD_OPTS="\$\{SASLAUTHD_OPTS\}[^"]+"/', 'SASLAUTHD_OPTS="${SASLAUTHD_OPTS} -a pam -r -c -s 128 -t 30 -n 5"', $content);
 		
-		$this->write_config_file($conf["saslauthd"]["config_file"], $content);
+		$this->write_config_file($conf['saslauthd']['config_file'], $content);
 	}
 	
 	public function configure_courier()
     {
     	global $conf;
     	
-		// authmysqlrc
-		$content = $this->get_template_file('authmysqlrc', true, true); // get contents & insert db cred
+		//* authmysqlrc
+		$content = $this->get_template_file('authmysqlrc', true, true); //* get contents & insert db cred
 		$this->write_config_file($conf['courier']['config_dir'].'/authmysqlrc', $content);
 		
-		// authdaemonrc
+		//* authdaemonrc
 		$configfile = $conf['courier']['config_dir'].'/authdaemonrc';
 
 		$content = rf($configfile);
 		$content = preg_replace('/(?<=\n)authmodulelist="[^"]+"/', "authmodulelist=\"authmysql\"", $content);
 		$this->write_config_file($configfile, $content);
 		
-		// create certificates
-		$command = "mkimapdcert";
-		caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+		//* create certificates
+		$command = 'mkimapdcert';
+		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 			
-		$command = "mkpop3dcert";
+		$command = 'mkpop3dcert';
 		caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
     }
+    
+    public function configure_dovecot() 
+    {
+    	global $conf;
+    	
+    	$config_dir = $conf['dovecot']['config_dir'];
+    	
+    	$configfile = $conf['postfix']['config_dir'].'/master.cf';
+    	
+    	if(is_file($configfile)) {
+			copy($configfile, $configfile.'~2');
+		}
+		if(is_file($configfile.'~2')) {
+			chmod($configfile.'~2', 0400);
+		}
+    	
+    	//* Configure master.cf and add a line for deliver
+		$content = rf($configfile);
+		
+    	if(!stristr($content,'dovecot/deliver')) {
+			$deliver_content = 'dovecot   unix  -       n       n       -       -       pipe'."\n".'  flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
+			af($conf['postfix']['config_dir'].'/master.cf',$deliver_content);
+		}
+		unset($content);
+		unset($deliver_content);
+		unset($configfile);
+		
+		//* Reconfigure postfix to use dovecot authentication
+		$postconf_commands = array (
+				'dovecot_destination_recipient_limit = 1',
+				'virtual_transport = dovecot',
+				'smtpd_sasl_type = dovecot',
+				'smtpd_sasl_path = private/auth'
+		);
+		
+		//* Make a backup copy of the main.cf file
+		copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~3');
+		
+    	//* Executing the postconf commands
+		foreach($postconf_commands as $cmd) 
+		{
+			$command = "postconf -e '$cmd'";
+			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+		}
+		
+		//* copy dovecot.conf
+		$configfile = $config_dir.'/dovecot.conf';
+		$content = $this->get_template_file('dovecot.conf', true);
+		$this->write_config_file($configfile, $content);
+		
+		//* dovecot-sql.conf
+		$configfile = $config_dir.'/dovecot-sql.conf';
+		$content = $this->get_template_file('debian_dovecot-sql.conf', true, true);
+		$this->write_config_file($configfile, $content);
+    }
 	
 	public function configure_spamassassin()
     {
@@ -232,7 +290,7 @@ class installer extends installer_base
 		$config_dir = $conf['getmail']['config_dir'];
 		
 		if (!is_dir($config_dir)) {
-			exec("mkdir -p ".escapeshellcmd($config_dir));
+			exec('mkdir -p '.escapeshellcmd($config_dir));
 		}
 
 		$command = "useradd -d $config_dir ".$conf['getmail']['user'];
@@ -246,7 +304,7 @@ class installer extends installer_base
 		$command = "chmod -R 700 $config_dir";
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
-		// Getmail will be run from cron. In order to have access to cron the getmail user needs to be part of the cron group.
+		//* Getmail will be run from cron. In order to have access to cron the getmail user needs to be part of the cron group.
 		$command = "gpasswd -a getmail " . $conf['cron']['group'];
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 	}
@@ -255,25 +313,22 @@ class installer extends installer_base
     {
 		global $conf;
 		
-		// Amavisd-new user config file
+		//* Amavisd-new user config file
 		$conf_file = 'amavisd-ispconfig.conf';
 		$conf_path = dirname($conf['amavis']['config_file']) . '/' . $conf_file;
 		
-		$content = $this->get_template_file($conf_file, true, true); // get contents & insert db cred
+		$content = $this->get_template_file($conf_file, true, true); //* get contents & insert db cred
 		$this->write_config_file($conf_path, $content);
 		
-		// Activate config directory in default file
+		//* Activate config directory in default file
 		$amavis_conf = rf($conf['amavis']['config_file']);
-		if (strpos($amavis_conf, $conf_path) === false) 
+		if (stripos($amavis_conf, $conf_path) === false) 
 		{
-			$amavis_conf = preg_replace('/(#-------------\n1;)/', 
-								    "include_config_files('$conf_path');\n$1", 
-									$amavis_conf);
-									
+			$amavis_conf = preg_replace('/^(1;.*)$/m', "include_config_files('$conf_path');\n$1", $amavis_conf);
 			$this->write_config_file($conf['amavis']['config_file'], $amavis_conf);
 		}
 		
-		// Adding the amavisd commands to the postfix configuration
+		//* Adding the amavisd commands to the postfix configuration
 		$postconf_commands = array (
 			'content_filter = amavis:[127.0.0.1]:10024',
 			'receive_override_options = no_address_mappings'
@@ -281,21 +336,21 @@ class installer extends installer_base
 		
     	foreach($postconf_commands as $cmd) {
 			$command = "postconf -e '$cmd'";
-			caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		}
 		
-		// Append the configuration for amavisd to the master.cf file
-		$content = rf($conf["postfix"]["config_dir"].'/master.cf');
+		//* Append the configuration for amavisd to the master.cf file
+		$content = rf($conf['postfix']['config_dir'].'/master.cf');
 		
-		if(!stristr($content,"127.0.0.1:10025")) // Only add the content if we had not addded it before 
+		if(!stristr($content,'127.0.0.1:10025')) //* Only add the content if we had not addded it before 
 		{ 
 			unset($content);
-			$content = $this->get_template_file("master_cf_amavis", true);
-			af($conf["postfix"]["config_dir"].'/master.cf', $content);
+			$content = $this->get_template_file('master_cf_amavis', true);
+			af($conf['postfix']['config_dir'].'/master.cf', $content);
 		}
 		unset($content);
 		
-		// Add the clamav user to the amavis group
+		//* Add the clamav user to the amavis group
 		exec('usermod -a -G amavis clamav');
     }
     
@@ -304,35 +359,37 @@ class installer extends installer_base
 		global $conf;
 		
 		//* configure pure-ftpd for MySQL authentication against the ispconfig database
-		$content = $this->get_template_file('pureftpd_mysql.conf', true, true); // get contents & insert db cred
-		$content = str_replace('{server_id}', $conf["server_id"], $content);
+		$content = $this->get_template_file('pureftpd_mysql.conf', true, true); //* get contents & insert db cred
+		$content = str_replace('{server_id}', $conf['server_id'], $content);
 		
 		$this->write_config_file($conf['pureftpd']['mysql_config_file'], $content, 600, 'root', 'root');
 		
-		// **enable pure-ftpd and server settings
+		//* enable pure-ftpd and server settings
 		$content = rf($conf["pureftpd"]["config_file"]);
 		
 		$content = preg_replace('/#?IS_CONFIGURED="(?:yes|no)"/', 'IS_CONFIGURED="yes"', $content);
 		$content = str_replace('AUTH="-l unix"', 'AUTH="-l mysql:'.$conf['pureftpd']['mysql_config_file'].'"', $content);
 		
-		// Logging defaults to syslog's ftp facility. Override this behaviour for better compatibility with debian/ubuntu
-		// and specify the format.
+		//* Logging defaults to syslog's ftp facility. Override this behaviour for better compatibility with debian/ubuntu
+		//* and specify the format.
 		$logdir = '/var/log/pure-ftpd';
 		if (!is_dir($logdir)) {
 			mkdir($logdir, 0755, true);
 		}
 		
-		/*
+		/**
 		 * @link http://download.pureftpd.org/pub/pure-ftpd/doc/README
 		 * -b brokenclientscompatibility
 		 * -A chrooteveryone
 		 * -E noanonymous
 		 * -O altlog <format>:<log file>
 		 * -Z customerproof (Add safe guards against common customer mistakes ie. like chmod 0 on their own files)
+		 * -D displaydotfiles 
+		 * -H dontresolve
 		 */
-		$content = preg_replace('/MISC_OTHER="[^"]+"/', 'MISC_OTHER="-b -A -E -Z -O clf:'.$logdir.'/transfer.log"', $content);
+		$content = preg_replace('/MISC_OTHER="[^"]+"/', 'MISC_OTHER="-b -A -E -Z -D -H -O clf:'.$logdir.'/transfer.log"', $content);
 		
-		$this->write_config_file($conf["pureftpd"]["config_file"], $content);
+		$this->write_config_file($conf['pureftpd']['config_file'], $content);
     }
     
 	public function configure_powerdns() 
@@ -345,7 +402,7 @@ class installer extends installer_base
 		}
 		
 		//* Create the ISPConfig database user in the local database
-        $query = "GRANT ALL ON `".$conf['powerdns']['database']."` . * TO '".$conf['mysql']['ispconfig_user']."'@'localhost';";
+        $query = 'GRANT ALL ON `'.$conf['powerdns']['database'].'` . * TO \''.$conf['mysql']['ispconfig_user'].'\'@\'localhost\';';
 		if(!$this->db->query($query)) {
 			$this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage);
 		}
@@ -363,12 +420,12 @@ class installer extends installer_base
 		}
 		
 		//* Create the powerdns config file
-		$content = $this->get_template_file('pdns.local', true, true); // get contents & insert db cred
+		$content = $this->get_template_file('pdns.local', true, true); //* get contents & insert db cred
 		$content = str_replace('{powerdns_database}', $conf['powerdns']['database'], $content);
 		
 		$this->write_config_file($conf["powerdns"]["config_dir"].'/'.$conf["powerdns"]["config_file"], $content, 600, 'root', 'root');
 
-		// Create symlink to init script to start the correct config file
+		//* Create symlink to init script to start the correct config file
 		if( !is_link($conf['init_scripts'].'/'.$conf['powerdns']['init_script']) ) {
 			symlink($conf['init_scripts'].'/pdns', $conf['init_scripts'].'/'.$conf['powerdns']['init_script']);
 		}
@@ -378,22 +435,25 @@ class installer extends installer_base
     {	
 		global $conf;
 		
-		// Create the logging directory for the vhost logfiles
-		if (!is_dir('/var/log/ispconfig/httpd')) {
-			mkdir('/var/log/ispconfig/httpd', 0755, true);
+		//* Create the logging directory for the vhost logfiles
+		if (!is_dir($conf['ispconfig_log_dir'].'/httpd')) {
+			mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true);
 		}
 		
 		if (is_file($conf['suphp']['config_file'])) 
 		{
 			$content = rf($conf['suphp']['config_file']);
 			
-			$content = preg_replace('/;Handler for php-scripts/',";Handler for php-scripts\nx-httpd-suphp=php:/usr/bin/php-cgi", $content);
-			$content = preg_replace('/;?umask=\d+/','umask=0022', $content);
+			if (!preg_match('|^x-httpd-suphp=php:/usr/bin/php-cgi$|m', $content))
+			{
+				$content = preg_replace('/;Handler for php-scripts/',";Handler for php-scripts\nx-httpd-suphp=php:/usr/bin/php-cgi", $content);
+				$content = preg_replace('/;?umask=\d+/','umask=0022', $content);
+			}
 			
 			$this->write_config_file($conf['suphp']['config_file'], $content);
 		}
 		
-		// Enable ISPConfig default vhost settings
+		//* Enable ISPConfig default vhost settings
 		$default_vhost_path = $conf['apache']['vhost_conf_dir'].'/'.$conf['apache']['vhost_default'];
 		if (is_file($default_vhost_path)) 
 		{
@@ -405,7 +465,7 @@ class installer extends installer_base
 			$this->write_config_file($default_vhost_path, $content);
 		}
 		
-		// Generate default ssl certificates
+		//* Generate default ssl certificates
 		if (!is_dir($conf['apache']['ssl_dir'])) {
 			mkdir($conf['apache']['ssl_dir']);
 		}
@@ -424,7 +484,7 @@ class installer extends installer_base
 		
 		
 		
-		// Copy the ISPConfig configuration include
+		//* Copy the ISPConfig configuration include
 		$content = $this->get_template_file('apache_ispconfig.conf', true);
 		
 		$records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
@@ -438,7 +498,7 @@ class installer extends installer_base
 		
 		$this->write_config_file($conf['apache']['vhost_conf_dir'].'/000-ispconfig.conf', $content);
 		
-		// Gentoo by default does not include .vhost files. Add include line to config file.
+		//* Gentoo by default does not include .vhost files. Add include line to config file.
 		$content = rf($conf['apache']['config_file']);
 		if ( strpos($content, 'Include /etc/apache2/vhosts.d/*.vhost') === false ) {
 			$content = preg_replace('|(Include /etc/apache2/vhosts.d/\*.conf)|',"$1\nInclude /etc/apache2/vhosts.d/*.vhost", $content);
@@ -446,21 +506,21 @@ class installer extends installer_base
 		
 		$this->write_config_file($conf['apache']['config_file'], $content);
 		
-		// make sure that webalizer finds its config file when it is directly in /etc
+		//* make sure that webalizer finds its config file when it is directly in /etc
 		if(is_file('/etc/webalizer.conf') && !is_dir('/etc/webalizer')) 
 		{
 			mkdir('/etc/webalizer', 0755);
 			symlink('/etc/webalizer.conf', '/etc/webalizer/webalizer.conf');
 		}
 		
-    	if(is_file('/etc/webalizer/webalizer.conf')) // Change webalizer mode to incremental 
+    	if(is_file('/etc/webalizer/webalizer.conf')) //* Change webalizer mode to incremental 
     	{
     		replaceLine('/etc/webalizer/webalizer.conf','#IncrementalName','IncrementalName webalizer.current',0,0);
 			replaceLine('/etc/webalizer/webalizer.conf','#Incremental','Incremental     yes',0,0);
 			replaceLine('/etc/webalizer/webalizer.conf','#HistoryName','HistoryName     webalizer.hist',0,0);
 		}
 		
-		// add a sshusers group
+		//* add a sshusers group
 		if (!is_group('sshusers')) 
 		{
 			$command = 'groupadd sshusers';
@@ -474,9 +534,9 @@ class installer extends installer_base
 		
 		//* Create the ispconfig apps vhost user and group
 		
-		$apps_vhost_user = $conf['web']['apps_vhost_user'];
-		$apps_vhost_group = $conf['web']['apps_vhost_group'];
-		$install_dir = $conf['web']['website_basedir'].'/apps';
+		$apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
+		$apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
+		$install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
 		
 		$command = 'groupadd '.$apps_vhost_user;
 		if ( !is_group($apps_vhost_group) ) {
@@ -491,14 +551,18 @@ class installer extends installer_base
 		$command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
-		exec('mkdir -p '.escapeshellcmd($conf['web']['website_basedir'].'/apps'));
+		if (!@is_dir($install_dir)) {
+			mkdir($install_dir, 0755, true);
+		}
+		chown($install_dir, $apps_vhost_user);
+		chgrp($install_dir, $apps_vhost_group);
 		
 		//* Copy the apps vhost file
         $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
         $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
         $apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '') ? '' : 'ServerName '.$conf['web']['apps_vhost_servername'];
         
-        // Dont just copy over the virtualhost template but add some custom settings
+        //* Dont just copy over the virtualhost template but add some custom settings
         $content = $this->get_template_file('apache_apps.vhost', true);
         
         $content = str_replace('{apps_vhost_ip}', $conf['web']['apps_vhost_ip'], $content);
@@ -507,7 +571,7 @@ class installer extends installer_base
 		$content = str_replace('{website_basedir}', $conf['web']['website_basedir'], $content);
 		$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
 		
-		// comment out the listen directive if port is 80 or 443
+		//* comment out the listen directive if port is 80 or 443
 		if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
 			$content = str_replace('{vhost_port_listen}', '#', $content);
 		} else {
@@ -518,8 +582,8 @@ class installer extends installer_base
 		
 		if ( !is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter') ) 
 		{
-			exec('mkdir -p '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
-			exec('cp tpl/apache_apps_fcgi_starter.master '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
+			mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
+			copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
 			exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
 			exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
 			
@@ -532,14 +596,14 @@ class installer extends installer_base
 		
 		$install_dir = $conf['ispconfig_install_dir'];
 		
-    	// Create the ISPConfig installation directory
+    	//* Create the ISPConfig installation directory
 		if(!is_dir($install_dir)) 
 		{
 			$command = "mkdir $install_dir";
 			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		}
 		
-		// Create a ISPConfig user and group
+		//* Create a ISPConfig user and group
 		if (!is_group('ispconfig')) 
 		{
 			$command = 'groupadd ispconfig';
@@ -552,18 +616,18 @@ class installer extends installer_base
 			caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		}
 		
-		// copy the ISPConfig interface part
+		//* copy the ISPConfig interface part
 		$command = "cp -rf ../interface $install_dir";
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
-		// copy the ISPConfig server part
+		//* copy the ISPConfig server part
 		$command = "cp -rf ../server $install_dir";
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
 		
-		// Create the config file for ISPConfig interface
+		//* Create the config file for ISPConfig interface
 		$configfile = 'config.inc.php';
-		$content = $this->get_template_file($configfile, true, true); // get contents & insert db cred
+		$content = $this->get_template_file($configfile, true, true); //* get contents & insert db cred
 		
 		$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
 		$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
@@ -576,10 +640,17 @@ class installer extends installer_base
 		
 		$this->write_config_file("$install_dir/interface/lib/$configfile", $content);
 		
-		// Create the config file for ISPConfig server
+		//* Create the config file for ISPConfig server
 		$this->write_config_file("$install_dir/server/lib/$configfile", $content);
 		
-    	// Enable the server modules and plugins.
+    	//* Create the config file for remote-actions (but only, if it does not exist, because
+		//* the value is a autoinc-value and so changed by the remoteaction_core_module
+		if (!file_exists($install_dir.'/server/lib/remote_action.inc.php')) {
+			$content = '<?php' . "\n" . '$maxid_remote_action = 0;' . "\n" . '?>';
+			$this->write_config_file("$install_dir/server/lib/remote_action.inc.php", $content);
+		}
+		
+    	//* Enable the server modules and plugins.
 		// TODO: Implement a selector which modules and plugins shall be enabled.
 		$dir = $install_dir.'/server/mods-available/';
 		if (is_dir($dir)) {
@@ -590,9 +661,15 @@ class installer extends installer_base
 						$module_name = substr($file,0,-8);
 						$tmp = new $module_name;
 						if($tmp->onInstall()) {
-							if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
+							if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) {
+								@symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
+								// @symlink($install_dir.'/server/mods-available/'.$file, '../mods-enabled/'.$file);
+							}
 							if (strpos($file, '_core_module') !== false) {
-								if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
+								if(!@is_link($install_dir.'/server/mods-core/'.$file)) {
+									@symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
+									// @symlink($install_dir.'/server/mods-available/'.$file, '../mods-core/'.$file);
+								}
 							}
 						}
 						unset($tmp);
@@ -601,7 +678,7 @@ class installer extends installer_base
 				closedir($dh);
 			}
 		}
-		
+
 		$dir = $install_dir.'/server/plugins-available/';
 		if (is_dir($dir)) {
 			if ($dh = opendir($dir)) {
@@ -611,9 +688,13 @@ class installer extends installer_base
 						$plugin_name = substr($file,0,-8);
 						$tmp = new $plugin_name;
 						if(method_exists($tmp,'onInstall') && $tmp->onInstall()) {
-							if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
+							if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) {
+								@symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
+							}
 							if (strpos($file, '_core_plugin') !== false) {
-								if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
+								if(!@is_link($install_dir.'/server/plugins-core/'.$file)) {
+									@symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
+								}
 							}
 						}
 						unset($tmp);
@@ -623,7 +704,7 @@ class installer extends installer_base
 			}
 		}
 		
-		// Update the server config
+		//* Update the server config
 		$mail_server_enabled = ($conf['services']['mail'])?1:0;
 		$web_server_enabled = ($conf['services']['web'])?1:0;
 		$dns_server_enabled = ($conf['services']['dns'])?1:0;
@@ -640,21 +721,23 @@ class installer extends installer_base
 			$this->db->query($sql);
 		}
 		
-		// Chmod the files
+		//* Chmod the files
 		$command = "chmod -R 750 $install_dir";
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 
-		// chown the files to the ispconfig user and group
+		//* chown the files to the ispconfig user and group
 		$command = "chown -R ispconfig:ispconfig $install_dir";
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
-		// Make the global language file directory group writable
+		//* Make the global language file directory group writable
 		exec("chmod -R 770 $install_dir/interface/lib/lang");
 		
-		// Make the temp directory for language file exports writable
-		exec("chmod -R 770 $install_dir/interface/web/temp");
+		//* Make the temp directory for language file exports writable
+		if(is_dir($install_dir.'/interface/web/temp')) {
+			exec("chmod -R 770 $install_dir/interface/web/temp");
+		}
 		
-	    // Make all interface language file directories group writable
+	    //* Make all interface language file directories group writable
 		$handle = @opendir($install_dir.'/interface/web');
 		while ($file = @readdir ($handle)) { 
 	   		if ($file != '.' && $file != '..') {
@@ -670,12 +753,19 @@ class installer extends installer_base
 			}
 		}
 		
-	    // make sure that the server config file (not the interface one) is only readable by the root user
-		exec("chmod 600 $install_dir/server/lib/$configfile");
-		exec("chown root:root $install_dir/server/lib/$configfile");
-		if (is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
-			exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf");
-			exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf");
+	    //* make sure that the server config file (not the interface one) is only readable by the root user
+    	chmod($install_dir.'/server/lib/'.$configfile, 0600);
+		chown($install_dir.'/server/lib/'.$configfile, 'root');
+		chgrp($install_dir.'/server/lib/'.$configfile, 'root');
+
+		chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
+		chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
+		chgrp($install_dir.'/server/lib/remote_action.inc.php', 'root');
+
+		if(@is_file($install_dir.'/server/lib/mysql_clientdb.conf')) {
+			chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
+			chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
+			chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
 		}
 		
 		// TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
@@ -684,22 +774,22 @@ class installer extends installer_base
 		$command = 'usermod -a -G ispconfig '.$conf['apache']['user'];
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
-		// Make the shell scripts executable
+		//* Make the shell scripts executable
 		$command = "chmod +x $install_dir/server/scripts/*.sh";
 		caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		
-		// Copy the ISPConfig vhost for the controlpanel
+		//* Copy the ISPConfig vhost for the controlpanel
 		$content = $this->get_template_file("apache_ispconfig.vhost", true);
 		$content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
 		
-		// comment out the listen directive if port is 80 or 443
+		//* comment out the listen directive if port is 80 or 443
 		if ($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
 			$content = str_replace('{vhost_port_listen}', '#', $content);
 		} else {
 			$content = str_replace('{vhost_port_listen}', '', $content);
 		}
 		
-		if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
+		if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
 			$content = str_replace('{ssl_comment}', '', $content);
 		} else {
 			$content = str_replace('{ssl_comment}', '#', $content);
@@ -712,32 +802,33 @@ class installer extends installer_base
     	{
 			mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
 			copy('tpl/apache_ispconfig_fcgi_starter.master', '/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
+			exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
 			chmod('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', 0755);
-			symlink('/usr/local/ispconfig/interface/web', '/var/www/ispconfig');
+			symlink($install_dir.'/interface/web', '/var/www/ispconfig');
 			exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
 		}
 		
-		// Install the update script
+		//* Install the update script
 		if (is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) {
 			unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
 		}
 		
-		chown('/usr/local/ispconfig/server/scripts/update_from_svn.sh', 'root');
-		chmod('/usr/local/ispconfig/server/scripts/update_from_svn.sh', 0700);
-		chown('/usr/local/ispconfig/server/scripts/update_from_tgz.sh', 'root');
-		chmod('/usr/local/ispconfig/server/scripts/update_from_tgz.sh', 0700);
-		chown('/usr/local/ispconfig/server/scripts/ispconfig_update.sh', 'root');
-		chmod('/usr/local/ispconfig/server/scripts/ispconfig_update.sh', 0700);
+		chown($install_dir.'/server/scripts/update_from_svn.sh', 'root');
+		chmod($install_dir.'/server/scripts/update_from_svn.sh', 0700);
+		chown($install_dir.'/server/scripts/update_from_tgz.sh', 'root');
+		chmod($install_dir.'/server/scripts/update_from_tgz.sh', 0700);
+		chown($install_dir.'/server/scripts/ispconfig_update.sh', 'root');
+		chmod($install_dir.'/server/scripts/ispconfig_update.sh', 0700);
 		
 		if (!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) {
-			symlink('/usr/local/ispconfig/server/scripts/ispconfig_update.sh', '/usr/local/bin/ispconfig_update_from_svn.sh');
+			symlink($install_dir.'/server/scripts/ispconfig_update.sh', '/usr/local/bin/ispconfig_update_from_svn.sh');
 		}
 		
 		if (!is_link('/usr/local/bin/ispconfig_update.sh')) {
-			symlink('/usr/local/ispconfig/server/scripts/ispconfig_update.sh', '/usr/local/bin/ispconfig_update.sh');
+			symlink($install_dir.'/server/scripts/ispconfig_update.sh', '/usr/local/bin/ispconfig_update.sh');
 		}
 		
-		// Make the logs readable for the ispconfig user
+		//* Make the logs readable for the ispconfig user
 		if (is_file('/var/log/maillog')) {
 			exec('chmod +r /var/log/maillog');
 		}
@@ -751,17 +842,20 @@ class installer extends installer_base
 			exec('chmod +r /var/log/clamav/freshclam.log');
 		}
 		
-		// Create the ispconfig log directory
+		//* Create the ispconfig log directory
 		if (!is_dir($conf['ispconfig_log_dir'])) {
 			mkdir($conf['ispconfig_log_dir']);
 		}
 		if (!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) {
-			exec('touch '.$conf['ispconfig_log_dir'].'/ispconfig.log');
+			touch($conf['ispconfig_log_dir'].'/ispconfig.log');
 		}
 		
-		exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh');
-		exec('chown getmail /usr/local/bin/run-getmail.sh');
-		exec('chmod 744 /usr/local/bin/run-getmail.sh');
+		rename($install_dir.'/server/scripts/run-getmail.sh', '/usr/local/bin/run-getmail.sh');
+		
+		if (is_user('getmail')) {
+			chown('/usr/local/bin/run-getmail.sh', 'getmail');
+		}
+		chmod('/usr/local/bin/run-getmail.sh', 0744);
     }
 }
 
diff --git a/install/dist/tpl/gentoo/apache_apps.vhost.master b/install/dist/tpl/gentoo/apache_apps.vhost.master
new file mode 100644
index 0000000000..aa90a73afa
--- /dev/null
+++ b/install/dist/tpl/gentoo/apache_apps.vhost.master
@@ -0,0 +1,45 @@
+
+######################################################
+# This virtual host contains the configuration
+# for the ISPConfig apps vhost
+######################################################
+
+{vhost_port_listen} Listen {apps_vhost_port}
+# NameVirtualHost *:{apps_vhost_port}
+
+<VirtualHost {apps_vhost_ip}:{apps_vhost_port}>
+  ServerAdmin webmaster@localhost
+  {apps_vhost_servername}
+  
+  <IfModule mod_fcgid.c>
+    DocumentRoot {apps_vhost_dir}
+    SuexecUserGroup ispapps ispapps
+    <Directory {apps_vhost_dir}>
+      Options Indexes FollowSymLinks MultiViews +ExecCGI
+      AllowOverride AuthConfig Indexes Limit Options FileInfo
+      <FilesMatch "\.ph(p[3-5]?|tml)$">
+           SetHandler fcgid-script
+      </FilesMatch>
+      FCGIWrapper {website_basedir}/php-fcgi-scripts/apps/.php-fcgi-starter .php
+      Order allow,deny
+      Allow from all
+    </Directory>
+    DirectoryIndex index.php
+  </IfModule>
+  
+  <IfModule mod_php5.c>
+    DocumentRoot {apps_vhost_dir}
+    AddType application/x-httpd-php .php
+    <Directory {apps_vhost_dir}>
+      Options FollowSymLinks
+      AllowOverride None
+      Order allow,deny
+      Allow from all
+    </Directory>
+  </IfModule>
+  
+  ServerSignature Off
+
+</VirtualHost>
+
+
diff --git a/install/dist/tpl/gentoo/apache_apps_fcgi_starter.master b/install/dist/tpl/gentoo/apache_apps_fcgi_starter.master
new file mode 100644
index 0000000000..c4800aaeeb
--- /dev/null
+++ b/install/dist/tpl/gentoo/apache_apps_fcgi_starter.master
@@ -0,0 +1,6 @@
+#!/bin/sh
+PHPRC=/etc/php/cgi-php5/
+export PHPRC
+export PHP_FCGI_MAX_REQUESTS=5000
+export PHP_FCGI_CHILDREN=1
+exec /usr/bin/php-cgi -d magic_quotes_gpc=off
\ No newline at end of file
diff --git a/install/dist/tpl/gentoo/apache_ispconfig.vhost.master b/install/dist/tpl/gentoo/apache_ispconfig.vhost.master
new file mode 100644
index 0000000000..bfd67bb8ea
--- /dev/null
+++ b/install/dist/tpl/gentoo/apache_ispconfig.vhost.master
@@ -0,0 +1,67 @@
+
+######################################################
+# This virtual host contains the configuration
+# for the ISPConfig controlpanel
+######################################################
+
+{vhost_port_listen} Listen {vhost_port}
+NameVirtualHost *:{vhost_port}
+
+<VirtualHost _default_:{vhost_port}>
+  ServerAdmin webmaster@localhost
+  
+  <IfModule mod_fcgid.c>
+    DocumentRoot /var/www/ispconfig/
+    SuexecUserGroup ispconfig ispconfig
+    <Directory /var/www/ispconfig/>
+      Options Indexes FollowSymLinks MultiViews +ExecCGI
+      AllowOverride AuthConfig Indexes Limit Options FileInfo
+      <FilesMatch "\.ph(p[3-5]?|tml)$">
+           SetHandler fcgid-script
+      </FilesMatch>
+      FCGIWrapper /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter .php
+      Order allow,deny
+      Allow from all
+    </Directory>
+    DirectoryIndex index.php
+  </IfModule>
+  
+  <IfModule mod_php5.c>
+    DocumentRoot /usr/local/ispconfig/interface/web/
+    AddType application/x-httpd-php .php
+    <Directory /usr/local/ispconfig/interface/web>
+      Options FollowSymLinks
+      AllowOverride None
+      Order allow,deny
+      Allow from all
+	  php_value magic_quotes_gpc        0
+    </Directory>
+  </IfModule>
+  
+  # ErrorLog /var/log/apache2/error.log
+  # CustomLog /var/log/apache2/access.log combined
+  ServerSignature Off
+  
+  <IfModule mod_security2.c>
+    SecRuleEngine Off
+  </IfModule>
+
+  # SSL Configuration
+  {ssl_comment}SSLEngine On
+  {ssl_comment}SSLCertificateFile /usr/local/ispconfig/interface/ssl/ispserver.crt
+  {ssl_comment}SSLCertificateKeyFile /usr/local/ispconfig/interface/ssl/ispserver.key
+
+</VirtualHost>
+
+<Directory /var/www/php-cgi-scripts>
+    AllowOverride None
+    Order Deny,Allow
+    Deny from all
+</Directory>
+
+<Directory /var/www/php-fcgi-scripts>
+    AllowOverride None
+    Order Deny,Allow
+    Deny from all
+</Directory>
+
diff --git a/install/dist/tpl/gentoo/apache_ispconfig_fcgi_starter.master b/install/dist/tpl/gentoo/apache_ispconfig_fcgi_starter.master
new file mode 100644
index 0000000000..4bb501b940
--- /dev/null
+++ b/install/dist/tpl/gentoo/apache_ispconfig_fcgi_starter.master
@@ -0,0 +1,6 @@
+#!/bin/sh
+PHPRC=/etc/php/cgi-php5/
+export PHPRC
+export PHP_FCGI_MAX_REQUESTS=5000
+export PHP_FCGI_CHILDREN=1
+exec /usr/bin/php-cgi -d magic_quotes_gpc=off -d session.save_path=/usr/local/ispconfig/server/temp
\ No newline at end of file
diff --git a/install/dist/tpl/gentoo/dovecot.conf.master b/install/dist/tpl/gentoo/dovecot.conf.master
new file mode 100644
index 0000000000..fa3093eb48
--- /dev/null
+++ b/install/dist/tpl/gentoo/dovecot.conf.master
@@ -0,0 +1,96 @@
+protocols = imap imaps pop3 pop3s
+disable_plaintext_auth = no
+log_timestamp = "%Y-%m-%d %H:%M:%S "
+mail_privileged_group = mail
+
+ssl_cert_file = /etc/ssl/dovecot/server.crt
+ssl_key_file = /etc/ssl/dovecot/server.key
+
+##
+## IMAP specific settings
+##
+
+protocol imap {
+  login_executable = /usr/libexec/dovecot/imap-login
+  mail_executable = /usr/libexec/dovecot/imap
+  mail_plugins = quota imap_quota 
+  mail_plugin_dir = /usr/lib/dovecot/imap
+}
+  
+##
+## POP3 specific settings
+##
+
+protocol pop3 {
+  login_executable = /usr/libexec/dovecot/pop3-login
+  mail_executable = /usr/libexec/dovecot/pop3
+  pop3_uidl_format = %08Xu%08Xv
+  mail_plugins = quota
+  mail_plugin_dir = /usr/lib/dovecot/pop3 
+}
+
+##
+## LDA specific settings
+##
+
+protocol lda {
+  postmaster_address = postmaster@example.com
+  mail_plugin_dir = /usr/lib/dovecot/lda
+  auth_socket_path = /var/run/dovecot/auth-master
+  mail_plugins = sieve quota
+}
+
+## Plugin settings
+plugin {
+  quota = maildir
+  sieve=/var/vmail/%d/%n/.sieve
+}
+
+##
+## Authentication processes
+##
+
+auth default {
+  mechanisms = plain login
+  passdb pam {
+    args = "*"
+  }
+
+  # SQL database <doc/wiki/AuthDatabase.SQL.txt>
+  passdb sql {
+    # Path for SQL configuration file
+    args = /etc/dovecot/dovecot-sql.conf
+  }
+
+# new quota support:
+  userdb prefetch {
+  }
+
+  userdb sql {
+    args = /etc/dovecot/dovecot-sql.conf
+  }
+
+
+  ## dovecot-lda specific settings
+  ##
+  socket listen {
+    master {
+      path = /var/run/dovecot/auth-master
+      mode = 0600
+      user = vmail # User running Dovecot LDA
+      #group = vmail # Or alternatively mode 0660 + LDA user in this group
+    }
+  client {
+          path = /var/spool/postfix/private/auth
+          mode = 0660
+          user = postfix
+          group = postfix
+        }
+  }
+
+}
+
+mail_location = maildir:/var/vmail/%d/%n/Maildir
+
+mail_uid = 5000
+mail_gid = 5000
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index e330525730..4626c22a8e 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -115,7 +115,7 @@ class installer_base {
 		if(is_installed('postfix')) $conf['postfix']['installed'] = true;
 		if(is_installed('apache') || is_installed('apache2') || is_installed('httpd')) $conf['apache']['installed'] = true;
 		if(is_installed('getmail')) $conf['getmail']['installed'] = true;
-		if(is_installed('couriertcpd')) $conf['courier']['installed'] = true;
+		if(is_installed('courierlogger')) $conf['courier']['installed'] = true;
 		if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
 		if(is_installed('saslsauthd')) $conf['saslauthd']['installed'] = true;
 		if(is_installed('amavisd-new')) $conf['amavis']['installed'] = true;
@@ -221,6 +221,12 @@ class installer_base {
 		$tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir'];
 		$tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
 		$tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
+		
+		if (array_key_exists('awstats', $conf)) {
+			foreach ($conf['awstats'] as $aw_sett => $aw_value) {
+				$tpl_ini_array['web']['awstats_'.$aw_sett] = $aw_value;
+			}
+		}
 
 		$server_ini_content = array_to_ini($tpl_ini_array);
 		$server_ini_content = mysql_real_escape_string($server_ini_content);
-- 
GitLab