Skip to content

Commit ccbf149

Browse files
author
Till Brehm
committed
- Added templating library to installer.
- Added function to detect the apache version to installer. - Added support for apache 2.4 to vhots templates for ispconfig vhost and apps vhost in installer.
1 parent b846a27 commit ccbf149

15 files changed

+2087
-97
lines changed

install/dist/lib/fedora.lib.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,12 @@ public function configure_apache()
645645
$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
646646
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
647647

648-
// copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
649-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.conf.master', 'tpl/apache_ispconfig.conf.master');
648+
$tpl = new tpl('apache_ispconfig.conf.master');
649+
$tpl->setVar('apache_version',getapacheversion());
650+
650651
$records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
651-
652+
$ip_addresses = array();
653+
652654
if(is_array($records) && count($records) > 0) {
653655
foreach($records as $rec) {
654656
if($rec['ip_type'] == 'IPv6') {
@@ -661,15 +663,15 @@ public function configure_apache()
661663
foreach($ports as $port) {
662664
$port = intval($port);
663665
if($port > 0 && $port < 65536 && $ip_address != '') {
664-
$content .= 'NameVirtualHost '.$ip_address.":".$port."\n";
666+
$ip_addresses[] = array('ip_address' => $ip_address, 'port' => $port);
665667
}
666668
}
667669
}
668670
}
669671
}
670672

671-
$content .= "\n";
672-
wf($vhost_conf_dir.'/ispconfig.conf', $content);
673+
wf($vhost_conf_dir.'/ispconfig.conf', $tpl->grab());
674+
unset($tpl);
673675

674676
if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) {
675677
exec("ln -s ".$vhost_conf_dir."/ispconfig.conf ".$vhost_conf_enabled_dir."/000-ispconfig.conf");
@@ -1033,28 +1035,30 @@ public function install_ispconfig()
10331035

10341036

10351037
// Dont just copy over the virtualhost template but add some custom settings
1036-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.vhost.master', "tpl/apache_ispconfig.vhost.master");
1037-
$content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
1038+
$tpl = new tpl('apache_ispconfig.vhost.master');
1039+
$tpl->setVar('vhost_port',$conf['apache']['vhost_port']);
10381040

10391041
// comment out the listen directive if port is 80 or 443
10401042
if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
1041-
$content = str_replace('{vhost_port_listen}', '#', $content);
1043+
$tpl->setVar('vhost_port_listen','#');
10421044
} else {
1043-
$content = str_replace('{vhost_port_listen}', '', $content);
1045+
$tpl->setVar('vhost_port_listen','');
10441046
}
10451047

1046-
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
1047-
$content = str_replace('{ssl_comment}', '', $content);
1048+
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
1049+
$tpl->setVar('ssl_comment','');
10481050
} else {
1049-
$content = str_replace('{ssl_comment}', '#', $content);
1051+
$tpl->setVar('ssl_comment','#');
10501052
}
10511053
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
1052-
$content = str_replace('{ssl_bundle_comment}', '', $content);
1054+
$tpl->setVar('ssl_bundle_comment','');
10531055
} else {
1054-
$content = str_replace('{ssl_bundle_comment}', '#', $content);
1056+
$tpl->setVar('ssl_bundle_comment','#');
10551057
}
1058+
1059+
$tpl->setVar('apache_version',getapacheversion());
10561060

1057-
wf("$vhost_conf_dir/ispconfig.vhost", $content);
1061+
wf($vhost_conf_dir.'/ispconfig.vhost', $tpl->grab());
10581062

10591063
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
10601064
//* and create the symlink

install/dist/lib/gentoo.lib.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ public function configure_apache()
495495

496496

497497
//* Copy the ISPConfig configuration include
498+
/*
498499
$content = $this->get_template_file('apache_ispconfig.conf', true);
499500
500501
$records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
@@ -507,6 +508,35 @@ public function configure_apache()
507508
}
508509
509510
$this->write_config_file($conf['apache']['vhost_conf_dir'].'/000-ispconfig.conf', $content);
511+
*/
512+
513+
$tpl = new tpl('apache_ispconfig.conf.master');
514+
$tpl->setVar('apache_version',getapacheversion());
515+
516+
$records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
517+
$ip_addresses = array();
518+
519+
if(is_array($records) && count($records) > 0) {
520+
foreach($records as $rec) {
521+
if($rec['ip_type'] == 'IPv6') {
522+
$ip_address = '['.$rec['ip_address'].']';
523+
} else {
524+
$ip_address = $rec['ip_address'];
525+
}
526+
$ports = explode(',', $rec['virtualhost_port']);
527+
if(is_array($ports)) {
528+
foreach($ports as $port) {
529+
$port = intval($port);
530+
if($port > 0 && $port < 65536 && $ip_address != '') {
531+
$ip_addresses[] = array('ip_address' => $ip_address, 'port' => $port);
532+
}
533+
}
534+
}
535+
}
536+
}
537+
538+
wf($conf['apache']['vhost_conf_dir'].'/000-ispconfig.conf', $tpl->grab());
539+
unset($tpl);
510540

511541
//* Gentoo by default does not include .vhost files. Add include line to config file.
512542
$content = rf($conf['apache']['config_file']);

install/dist/lib/opensuse.lib.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,12 @@ public function configure_apache()
660660
$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
661661
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
662662

663-
//copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
664-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.conf.master', 'tpl/apache_ispconfig.conf.master');
663+
$tpl = new tpl('apache_ispconfig.conf.master');
664+
$tpl->setVar('apache_version',getapacheversion());
665+
665666
$records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
666-
667+
$ip_addresses = array();
668+
667669
if(is_array($records) && count($records) > 0) {
668670
foreach($records as $rec) {
669671
if($rec['ip_type'] == 'IPv6') {
@@ -676,15 +678,15 @@ public function configure_apache()
676678
foreach($ports as $port) {
677679
$port = intval($port);
678680
if($port > 0 && $port < 65536 && $ip_address != '') {
679-
$content .= 'NameVirtualHost '.$ip_address.":".$port."\n";
681+
$ip_addresses[] = array('ip_address' => $ip_address, 'port' => $port);
680682
}
681683
}
682684
}
683685
}
684686
}
685687

686-
$content .= "\n";
687-
wf($vhost_conf_dir.'/ispconfig.conf', $content);
688+
wf($vhost_conf_dir.'/ispconfig.conf', $tpl->grab());
689+
unset($tpl);
688690

689691
if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) {
690692
exec("ln -s ".$vhost_conf_dir."/ispconfig.conf ".$vhost_conf_enabled_dir."/000-ispconfig.conf");
@@ -1089,31 +1091,30 @@ public function install_ispconfig()
10891091

10901092

10911093
// Dont just copy over the virtualhost template but add some custom settings
1092-
1093-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.vhost.master', "tpl/apache_ispconfig.vhost.master");
1094-
$content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
1094+
$tpl = new tpl('apache_ispconfig.vhost.master');
1095+
$tpl->setVar('vhost_port',$conf['apache']['vhost_port']);
10951096

10961097
// comment out the listen directive if port is 80 or 443
10971098
if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
1098-
$content = str_replace('{vhost_port_listen}', '#', $content);
1099+
$tpl->setVar('vhost_port_listen','#');
10991100
} else {
1100-
$content = str_replace('{vhost_port_listen}', '', $content);
1101+
$tpl->setVar('vhost_port_listen','');
11011102
}
11021103

1103-
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
1104-
$content = str_replace('{ssl_comment}', '', $content);
1104+
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
1105+
$tpl->setVar('ssl_comment','');
11051106
} else {
1106-
$content = str_replace('{ssl_comment}', '#', $content);
1107+
$tpl->setVar('ssl_comment','#');
11071108
}
11081109
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
1109-
$content = str_replace('{ssl_bundle_comment}', '', $content);
1110+
$tpl->setVar('ssl_bundle_comment','');
11101111
} else {
1111-
$content = str_replace('{ssl_bundle_comment}', '#', $content);
1112+
$tpl->setVar('ssl_bundle_comment','#');
11121113
}
1114+
1115+
$tpl->setVar('apache_version',getapacheversion());
11131116

1114-
$content = str_replace('/var/www/', '/srv/www/', $content);
1115-
1116-
wf("$vhost_conf_dir/ispconfig.vhost", $content);
1117+
wf($vhost_conf_dir.'/ispconfig.vhost', $tpl->grab());
11171118

11181119
//if(!is_file('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
11191120
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master');

install/install.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
6666
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
6767

68+
//** Include the templating lib
69+
require_once 'lib/classes/tpl.inc.php';
70+
6871
//** Check for existing installation
6972
/*if(is_dir("/usr/local/ispconfig")) {
7073
die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.');

0 commit comments

Comments
 (0)