From 7452b296cbca0001091aa19ff945f2e756f33da6 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Wed, 22 Jan 2014 09:08:48 -0500
Subject: [PATCH] Merge branch 'stable-3.0.5' of /home/git/repositories/pixcept/ispconfig3 into stable-3.0.5

---
 install/lib/installer_base.lib.php |    9 +++++++++
 install/lib/install.lib.php        |   17 +++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/install/lib/install.lib.php b/install/lib/install.lib.php
index eac79e9..501cf3b 100644
--- a/install/lib/install.lib.php
+++ b/install/lib/install.lib.php
@@ -666,6 +666,23 @@
 	}
 }
 
+function hasLine($filename, $search_pattern, $strict = 0) {
+	if($lines = @file($filename)) {
+		foreach($lines as $line) {
+			if($strict == 0) {
+				if(stristr($line, $search_pattern)) {
+					return true;
+				}
+			} else {
+				if(trim($line) == $search_pattern) {
+					return true;
+				}
+			}
+		}
+	}
+	return false;
+}
+
 function is_installed($appname) {
 	exec('which '.escapeshellcmd($appname).' 2> /dev/null', $out, $returncode);
 	if(isset($out[0]) && stristr($out[0], $appname) && $returncode == 0) {
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 14d054a..1f691ae 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -1225,6 +1225,15 @@
 			replaceLine('/etc/apache2/ports.conf', 'Listen 443', 'Listen 443', 1);
 		}
 
+		if(is_file('/etc/apache2/apache.conf')) {
+			if(hasLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 1) == false) {
+				if(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.conf', 1) == false) {
+					replaceLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 'Include sites-enabled/', 1, 1);
+				} elseif(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 1) == false) {
+					replaceLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 'IncludeOptional sites-enabled/*.vhost', 1, 1);
+				}
+			}
+		}
 
 		//* Copy the ISPConfig configuration include
 		$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];

--
Gitblit v1.9.1