Marius Burkard
2016-07-08 9bcd2fd54728b9e634442f584268da03acaea633
commit | author | age
532ae5 1 <?php
L 2
3 /*
4 Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /*
32     ISPConfig 3 installer.
b04e82 33     
TB 34     -------------------------------------------------------------------------------------
35     - Interactive install
36     -------------------------------------------------------------------------------------
37     run:
38     
39     php install.php
40     
41     -------------------------------------------------------------------------------------
42     - Noninteractive (autoinstall) mode
43     -------------------------------------------------------------------------------------
44     
45     The autoinstall mode can read the installer questions from a .ini style file or from
46     a php config file. Examples for both file types are in the docs folder. 
47     See autoinstall.ini.sample and autoinstall.conf_sample.php.
48     
49     run:
50     
51     php install.php --autoinstall=autoinstall.ini
52     
53     or
54     
55     php install.php --autoinstall=autoinstall.conf.php
56     
532ae5 57 */
L 58
59 error_reporting(E_ALL|E_STRICT);
60
7334d4 61 define('INSTALLER_RUN', true);
T 62
532ae5 63 //** The banner on the command line
b1a6a5 64 echo "\n\n".str_repeat('-', 80)."\n";
532ae5 65 echo " _____ ___________   _____              __ _         ____
L 66 |_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
67   | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
68   | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
69  _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
70  \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
71                                               __/ |
72                                              |___/ ";
b1a6a5 73 echo "\n".str_repeat('-', 80)."\n";
532ae5 74 echo "\n\n>> Initial configuration  \n\n";
L 75
76 //** Include the library with the basic installer functions
b1a6a5 77 require_once 'lib/install.lib.php';
532ae5 78
L 79 //** Include the base class of the installer class
b1a6a5 80 require_once 'lib/installer_base.lib.php';
532ae5 81
L 82 //** Ensure that current working directory is install directory
83 $cur_dir = getcwd();
84 if(realpath(dirname(__FILE__)) != $cur_dir) {
85     chdir( realpath(dirname(__FILE__)) );
86 }
87
88 //** Install logfile
89 define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
90 define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
91
ccbf14 92 //** Include the templating lib
TB 93 require_once 'lib/classes/tpl.inc.php';
94
532ae5 95 //** Check for existing installation
L 96 /*if(is_dir("/usr/local/ispconfig")) {
97     die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.');
98 }*/
99
100 //** Get distribution identifier
101 $dist = get_distname();
102
103 if($dist['id'] == '') die('Linux distribution or version not recognized.');
104
bcd725 105 //** Include the autoinstaller configuration (for non-interactive setups)
FT 106 error_reporting(E_ALL ^ E_NOTICE);
b04e82 107
TB 108 //** Get commandline options
109 $cmd_opt = getopt('', array('autoinstall::'));
110
111 //** Load autoinstall file
112 if(isset($cmd_opt['autoinstall']) && is_file($cmd_opt['autoinstall'])) {
113     $path_parts = pathinfo($cmd_opt['autoinstall']);
114     if($path_parts['extension'] == 'php') {
115         include_once $cmd_opt['autoinstall'];
116     } elseif($path_parts['extension'] == 'ini') {
117         $tmp = ini_to_array(file_get_contents('autoinstall.ini'));
c8509b 118         if(!is_array($tmp['install'])) $tmp['install'] = array();
MC 119         if(!is_array($tmp['ssl_cert'])) $tmp['ssl_cert'] = array();
120         if(!is_array($tmp['expert'])) $tmp['expert'] = array();
121         if(!is_array($tmp['update'])) $tmp['update'] = array();
b04e82 122         $autoinstall = $tmp['install'] + $tmp['ssl_cert'] + $tmp['expert'] + $tmp['update'];
TB 123         unset($tmp);
124     }
125     unset($path_parts);
126     define('AUTOINSTALL', true);
127 } else {
128     $autoinstall = array();
129     define('AUTOINSTALL', false);
130 }
131
bcd725 132
532ae5 133 //** Include the distribution-specific installer class library and configuration
b1a6a5 134 if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php';
MC 135 include_once 'dist/lib/'.$dist['id'].'.lib.php';
3b8b9e 136 include_once 'dist/conf/'.$dist['confid'].'.conf.php';
532ae5 137
L 138 //****************************************************************************************************
b1a6a5 139 //** Installer Interface
532ae5 140 //****************************************************************************************************
L 141 $inst = new installer();
cc45ab 142 if (!$inst->get_php_version()) die('ISPConfig requieres PHP '.$inst->min_php."\n");
ead7ad 143 $retval=shell_exec("which which");
FS 144 if (empty($retval)) die ("ISPConfig requieres which \n");
60b700 145
532ae5 146 swriteln($inst->lng('    Following will be a few questions for primary configuration so be careful.'));
L 147 swriteln($inst->lng('    Default values are in [brackets] and can be accepted with <ENTER>.'));
148 swriteln($inst->lng('    Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
149
150 //** Check log file is writable (probably not root or sudo)
151 if(!is_writable(dirname(ISPC_LOG_FILE))){
b1a6a5 152     die("ERROR: Cannot write to the ".dirname(ISPC_LOG_FILE)." directory. Are you root or sudo ?\n\n");
532ae5 153 }
L 154
155 if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
156     die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
157 }
158
159 if(is_dir('/usr/local/ispconfig')) {
160     die('ISPConfig 3 installation found. Please use update.php instead if install.php to update the installation.');
161 }
162
163 //** Detect the installed applications
164 $inst->find_installed_apps();
165
8cf78b 166 //** Select the language and set default timezone
b04e82 167 $conf['language'] = $inst->simple_query('Select language', array('en', 'de'), 'en','language');
3898c9 168 $conf['timezone'] = get_system_timezone();
532ae5 169
992797 170 //* Set default theme
f598b0 171 $conf['theme'] = 'default';
992797 172 $conf['language_file_import_enabled'] = true;
f598b0 173
532ae5 174 //** Select installation mode
b04e82 175 $install_mode = $inst->simple_query('Installation mode', array('standard', 'expert'), 'standard','install_mode');
532ae5 176
L 177
178 //** Get the hostname
179 $tmp_out = array();
180 exec('hostname -f', $tmp_out);
5a56e6 181 $conf['hostname'] = @$tmp_out[0];
7eade0 182 unset($tmp_out);
bb690d 183 //** Prevent empty hostname
FS 184 $check = false;
185 do {
186     $conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', $conf['hostname'], 'hostname');
187     $conf['hostname']=trim($conf['hostname']);
188     $check = @($conf['hostname'] !== '')?true:false;
189     if(!$check) swriteln('Hostname may not be empty.');
190 } while (!$check);
ee405d 191
532ae5 192 // Check if the mysql functions are loaded in PHP
f1926a 193 if(!function_exists('mysqli_connect')) die('No PHP MySQLi functions available. Please ensure that the PHP MySQL module is loaded.');
532ae5 194
L 195 //** Get MySQL root credentials
196 $finished = false;
197 do {
b04e82 198     $tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host'],'mysql_hostname');     
82e9b9 199     $tmp_mysql_server_port = $inst->free_query('MySQL server port', $conf['mysql']['port'],'mysql_port');
b04e82 200     $tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user'],'mysql_root_user');     
TB 201     $tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password'],'mysql_root_password');     
202     $tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database'],'mysql_database');     
203     $tmp_mysql_server_charset = $inst->free_query('MySQL charset', $conf['mysql']['charset'],'mysql_charset');
bcd725 204     
8cf78b 205     if($install_mode == 'expert') {
T 206         swriteln("The next two questions are about the internal ISPConfig database user and password.\nIt is recommended to accept the defaults which are 'ispconfig' as username and a random password.\nIf you use a different password, use only numbers and chars for the password.\n");
bcd725 207         
b04e82 208         $conf['mysql']['ispconfig_user'] = $inst->free_query('ISPConfig mysql database username', $conf['mysql']['ispconfig_user'],'mysql_ispconfig_user');     
TB 209         $conf['mysql']['ispconfig_password'] = $inst->free_query('ISPConfig mysql database password', $conf['mysql']['ispconfig_password'],'mysql_ispconfig_password');
8cf78b 210     }
b1a6a5 211
532ae5 212     //* Initialize the MySQL server connection
7baf73 213     if(@mysqli_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, '', (int)$tmp_mysql_server_port)) {
532ae5 214         $conf['mysql']['host'] = $tmp_mysql_server_host;
82e9b9 215         $conf['mysql']['port'] = $tmp_mysql_server_port;
532ae5 216         $conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
L 217         $conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password;
218         $conf['mysql']['database'] = $tmp_mysql_server_database;
219         $conf['mysql']['charset'] = $tmp_mysql_server_charset;
220         $finished = true;
221     } else {
8a8cc2 222         swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysqli_connect_error());
532ae5 223     }
L 224 } while ($finished == false);
225 unset($finished);
226
227 // Resolve the IP address of the MySQL hostname.
b1a6a5 228 $tmp = explode(':', $conf['mysql']['host']);
532ae5 229 if(!$conf['mysql']['ip'] = gethostbyname($tmp[0])) die('Unable to resolve hostname'.$tmp[0]);
L 230 unset($tmp);
231
232
233 //** Initializing database connection
b1a6a5 234 include_once 'lib/mysql.lib.php';
532ae5 235 $inst->db = new db();
L 236
237 //** Begin with standard or expert installation
a75c81 238
FS 239 $conf['services']['mail'] = false;
240 $conf['services']['web'] = false;
241 $conf['services']['dns'] = false;
242 $conf['services']['file'] = false;
243 $conf['services']['db'] = true;
244 $conf['services']['vserver'] = false;
245 $conf['services']['firewall'] = false;
246 $conf['services']['proxy'] = false;
247 $conf['services']['xmpp'] = false;
248
da3c0c 249 //** Get Server ID
MB 250 // $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1');
251 // Server ID is an autoInc value of the mysql database now
252 if($install_mode == 'expert' && strtolower($inst->simple_query('Shall this server join an existing ISPConfig multiserver setup', array('y', 'n'), 'n','join_multiserver_setup')) == 'y') {
253     $conf['mysql']['master_slave_setup'] = 'y';
b1a6a5 254
da3c0c 255     //** Get MySQL root credentials
MB 256     $finished = false;
257     do {
258         $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname'); 
259         $tmp_mysql_server_port = $inst->free_query('MySQL master server port', $conf['mysql']['master_port'],'mysql_master_port');
260         $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user');     
261         $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password'); 
262         $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
263
264         //* Initialize the MySQL server connection
265         if(@mysqli_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, $tmp_mysql_server_database, (int)$tmp_mysql_server_port)) {
266             $conf['mysql']['master_host'] = $tmp_mysql_server_host;
267             $conf['mysql']['master_port'] = $tmp_mysql_server_port;
268             $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
269             $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
270             $conf['mysql']['master_database'] = $tmp_mysql_server_database;
271             $finished = true;
272         } else {
273             swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_connect_error());
274         }
275     } while ($finished == false);
276     unset($finished);
277
278     // initialize the connection to the master database
279     $inst->dbmaster = new db();
280     if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
281     $inst->dbmaster->setDBData($conf['mysql']["master_host"], $conf['mysql']["master_admin_user"], $conf['mysql']["master_admin_password"]);
282     $inst->dbmaster->setDBName($conf['mysql']["master_database"]);
283
284 } else {
285     // the master DB is the same then the slave DB
d22277 286     $inst->dbmaster = $inst->db;
da3c0c 287 }
b1a6a5 288
da3c0c 289 //* Create the mysql database
MB 290 $inst->configure_database();
291
292 //* Check for Web-Server
293 if(!$conf['apache']['installed'] && !$conf['nginx']['installed']) {
294     $conf['apache']['installed'] = $inst->force_configure_app('Apache', ($install_mode == 'expert'));
295     $conf['nginx']['installed'] = $inst->force_configure_app('nginx', ($install_mode == 'expert'));
296 }
297
298 //* Configure Webserver - Apache or nginx
299 if($conf['apache']['installed'] == true && $conf['nginx']['installed'] == true) {
300     $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache', 'nginx'), 'apache','http_server');
301     if($http_server_to_use == 'apache'){
302         $conf['nginx']['installed'] = false;
303         $conf['services']['file'] = true;
304     } else {
305         $conf['apache']['installed'] = false;
306     }
307 }
308
309 //* Insert the Server record into the database
310 if($install_mode == 'expert') {
311     swriteln('Adding ISPConfig server record to database.');
312     swriteln('');
313 }
314 $inst->add_database_server_record();
315
316 if($install_mode == 'standard' || strtolower($inst->simple_query('Configure Mail', array('y', 'n') , 'y','configure_mail') ) == 'y') {
a75c81 317
FS 318     //* Configure Postgrey
da3c0c 319     $force = @($conf['postgrey']['installed']) ? true : $inst->force_configure_app('Postgrey', ($install_mode == 'expert'));
a75c81 320     if($force) swriteln('Configuring Postgrey');
FS 321
322     //* Configure Postfix
da3c0c 323     $force = @($conf['postfix']['installed']) ? true : $inst->force_configure_app('Postfix', ($install_mode == 'expert'));
a75c81 324     if($force) {
FS 325         swriteln('Configuring Postfix');
326         $conf['services']['mail'] = true;
da3c0c 327         $inst->configure_postfix();
a75c81 328     }
FS 329
330     if($conf['services']['mail']) {
331         //* Configure Mailman
da3c0c 332         $force = @($conf['mailman']['installed']) ? true : $inst->force_configure_app('Mailman', ($install_mode == 'expert'));
a75c81 333         if($force) {
FS 334             swriteln('Configuring Mailman');
335             $inst->configure_mailman();
da3c0c 336         }
a75c81 337
FS 338         //* Check for Dovecot and Courier
339         if(!$conf['dovecot']['installed'] && !$conf['courier']['installed']) {
da3c0c 340             $conf['dovecot']['installed'] = $inst->force_configure_app('Dovecot', ($install_mode == 'expert'));
MB 341             $conf['courier']['installed'] = $inst->force_configure_app('Courier', ($install_mode == 'expert'));
a75c81 342         }
FS 343         //* Configure Mailserver - Dovecot or Courier
344         if($conf['dovecot']['installed'] && $conf['courier']['installed']) {
345             $mail_server_to_use = $inst->simple_query('Dovecot and Courier detected. Select server to use with ISPConfig:', array('dovecot', 'courier'), 'dovecot','mail_server');
346             if($mail_server_to_use == 'dovecot'){
347                 $conf['courier']['installed'] = false;
348             } else {
349                 $conf['dovecot']['installed'] = false;
350             }
351         }
352         //* Configure Dovecot
353         if($conf['dovecot']['installed']) {
354             swriteln('Configuring Dovecot');
355             $inst->configure_dovecot();
356         }
357         //* Configure Courier
358         if($conf['courier']['installed']) {
359             swriteln('Configuring Courier');
360             $inst->configure_courier();
361             swriteln('Configuring SASL');
362             $inst->configure_saslauthd();
363             swriteln('Configuring PAM');
364             $inst->configure_pam();
365         }
366
367         //* Configure Spamasassin
da3c0c 368         $force = @($conf['spamassassin']['installed']) ? true : $inst->force_configure_app('Spamassassin', ($install_mode == 'expert'));
a75c81 369         if($force) {
FS 370             swriteln('Configuring Spamassassin');
371             $inst->configure_spamassassin();
372         }
da3c0c 373
a75c81 374         //* Configure Amavis
da3c0c 375         $force = @($conf['amavis']['installed']) ? true : $inst->force_configure_app('Amavisd', ($install_mode == 'expert'));
a75c81 376         if($force) {
FS 377             swriteln('Configuring Amavisd');
378             $inst->configure_amavis();
379         }
380
381         //* Configure Getmail
da3c0c 382         $force = @($conf['getmail']['installed']) ? true : $inst->force_configure_app('Getmail', ($install_mode == 'expert'));
a75c81 383         if($force) {
FS 384             swriteln('Configuring Getmail');
385             $inst->configure_getmail();
386         }
da3c0c 387     } else {
MB 388         swriteln('[ERROR] Postfix not installed - skipping Mail');
389     }
390 }
a75c81 391
da3c0c 392 //* Configure Jailkit
MB 393 $force = @($conf['jailkit']['installed']) ? true : $inst->force_configure_app('Jailkit', ($install_mode == 'expert'));
394 if($force) {
395     swriteln('Configuring Jailkit');
396     $inst->configure_jailkit();
397 }
a75c81 398
da3c0c 399 //* Configure Pureftpd
MB 400 $force = @($conf['pureftpd']['installed']) ? true : $inst->force_configure_app('pureftpd', ($install_mode == 'expert'));
401 if($force) {
402     swriteln('Configuring Pureftpd');
403     $inst->configure_pureftpd();
404 }
405
406 //** Configure DNS
407 if($install_mode == 'standard' || strtolower($inst->simple_query('Configure DNS Server', array('y', 'n'), 'y','configure_dns')) == 'y') {
a75c81 408     //* Check for DNS
da3c0c 409     if(!$conf['powerdns']['installed'] && !$conf['bind']['installed'] && !$conf['mydns']['installed']) {
MB 410         if($install_mode == 'expert') $conf['powerdns']['installed'] = $inst->force_configure_app('PowerDNS', ($install_mode == 'expert'));
411         $conf['bind']['installed'] = $inst->force_configure_app('BIND', ($install_mode == 'expert'));
412         $conf['mydns']['installed'] = $inst->force_configure_app('MyDNS', ($install_mode == 'expert'));
a75c81 413     }
FS 414     //* Configure PowerDNS
da3c0c 415     if($install_mode == 'expert' && $conf['powerdns']['installed']) {
a75c81 416         swriteln('Configuring PowerDNS');
FS 417         $inst->configure_powerdns();
418         $conf['services']['dns'] = true;
419     }
420     //* Configure Bind
421     if($conf['bind']['installed']) {
422         swriteln('Configuring BIND');
423         $inst->configure_bind();
424         $conf['services']['dns'] = true;
57e982 425         if(!is_installed('haveged')) {
ead7ad 426             swriteln("[INFO] haveged not detected - DNSSEC can fail");
FS 427         }
a75c81 428     }
FS 429     //* Configure MyDNS
430     if($conf['mydns']['installed']) {
431         swriteln('Configuring MyDNS');
432         $inst->configure_mydns();
433         $conf['services']['dns'] = true;
434     }
435
da3c0c 436 }
a75c81 437
da3c0c 438 if($install_mode == 'standard' || strtolower($inst->simple_query('Configure Web Server', array('y', 'n'), 'y','configure_webserver')) == 'y') {
532ae5 439     //* Configure Apache
a75c81 440     if($conf['apache']['installed']){
4ffb51 441         swriteln('Configuring Apache');
F 442         $inst->configure_apache();
a75c81 443         $conf['services']['web'] = true;
FS 444         $conf['services']['file'] = true;
445         //* Configure Vlogger
da3c0c 446         $force = @($conf['vlogger']['installed']) ? true : $inst->force_configure_app('vlogger', ($install_mode == 'expert'));
a75c81 447         if($force) {
FS 448             swriteln('Configuring vlogger');
449             $inst->configure_vlogger();
450         }
451         //* Configure squid
452 /*
da3c0c 453         $force = @($conf['squid']['installed']) ? true : $inst->force_configure_app('squid', ($install_mode == 'expert'));
a75c81 454         if($force) {
FS 455             swriteln('Configuring Squid');
456             $inst->configure_squid();
457             $conf['services']['proxy'] = true;
da3c0c 458             if($conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script']))system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null');
a75c81 459         }
FS 460 */
4ffb51 461     }
F 462     //* Configure nginx
a75c81 463     if($conf['nginx']['installed']){
4ffb51 464         swriteln('Configuring nginx');
F 465         $inst->configure_nginx();
a75c81 466         $conf['services']['web'] = true;
4ffb51 467     }
da3c0c 468 }
b1a6a5 469
da3c0c 470 //* Configure OpenVZ
MB 471 $force = @($conf['openvz']['installed']) ? true : $inst->force_configure_app('OpenVZ', ($install_mode == 'expert'));
472 if($force) {
473     $conf['services']['vserver'] = true;
474     swriteln('Configuring OpenVZ');
475 }
b1a6a5 476
da3c0c 477 if($install_mode == 'standard' || strtolower($inst->simple_query('Configure Firewall Server', array('y', 'n'), 'y','configure_firewall')) == 'y') {
a75c81 478     //* Check for Firewall
FS 479     if(!$conf['ufw']['installed'] && !$conf['firewall']['installed']) {
da3c0c 480         $conf['ufw']['installed'] = $inst->force_configure_app('Ubuntu Firewall', ($install_mode == 'expert'));
MB 481         $conf['firewall']['installed'] = $inst->force_configure_app('Bastille Firewall', ($install_mode == 'expert'));
a75c81 482     }
FS 483     //* Configure Firewall - Ubuntu or Bastille
484     if($conf['ufw']['installed'] && $conf['firewall']['installed']) {
485         $firewall_to_use = $inst->simple_query('Ubuntu and Bastille Firewall detected. Select firewall to use with ISPConfig:', array('bastille', 'ubuntu'), 'bastille','firewall_server');
486         if($firewall_to_use == 'bastille'){
487             $conf['ufw']['installed'] = false;
488         } else {
489             $conf['firewall']['installed'] = false;
490         }
491     }
492     //* Configure Ubuntu Firewall
493     if($conf['ufw']['installed']){
bd68aa 494         swriteln('Configuring Ubuntu Firewall');
MC 495         $inst->configure_ufw_firewall();
496         $conf['services']['firewall'] = true;
a75c81 497     }
FS 498     //* Configure Bastille Firewall
499     if($conf['firewall']['installed']){
bd68aa 500         swriteln('Configuring Bastille Firewall');
MC 501         $inst->configure_bastille_firewall();
a75c81 502         $conf['services']['firewall'] = true;
56ad03 503         $conf['bastille']['installed'] = true;
bd68aa 504     }
da3c0c 505 }
c12af9 506
da3c0c 507 //* Configure XMPP
MB 508 $force = @($conf['xmpp']['installed']) ? true : $inst->force_configure_app('Metronome XMPP Server', ($install_mode == 'expert'));
509 if($force) {
510     swriteln('Configuring Metronome XMPP Server');
511     $inst->configure_xmpp();
512     $conf['services']['xmpp'] = true;
513 }
b1a6a5 514
da3c0c 515 //* Configure Fail2ban
MB 516 $force = @($conf['fail2ban']['installed']) ? true : $inst->force_configure_app('Fail2ban', ($install_mode == 'expert'));
517 if($force) {
518     swriteln('Configuring Fail2ban');
519     $inst->configure_fail2ban();
520 }
b1a6a5 521
da3c0c 522 if($conf['services']['web'] == true) {
a75c81 523     //** Configure apps vhost
FS 524     swriteln('Configuring Apps vhost');
525     $inst->configure_apps_vhost();
da3c0c 526 }
9f94a1 527
da3c0c 528 //** Configure ISPConfig :-)
MB 529 $install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y';
530 if($install_mode == 'standard' || strtolower($inst->simple_query('Install ISPConfig Web Interface', array('y', 'n'), $install_ispconfig_interface_default,'install_ispconfig_web_interface')) == 'y') {
532ae5 531     swriteln('Installing ISPConfig');
b1a6a5 532
da3c0c 533     //** We want to check if the server is a module or cgi based php enabled server
MB 534     //** TODO: Don't always ask for this somehow ?
535     /*
536     $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
537
538     if($fast_cgi == 'yes') {
539         $alias = $inst->free_query('Script Alias', '/php/');
540         $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
541         $conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
542     } else {
543         $conf['apache']['vhost_cgi_alias'] = "";
544     }
545     */
546
547     //** Customise the port ISPConfig runs on
b04e82 548     $ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080','ispconfig_port');
55cb02 549     $conf['interface_password'] = $inst->free_query('Admin password', 'admin');
272da6 550     if($conf['interface_password'] != 'admin') {
FS 551         $check = false;
552         do {
553             unset($temp_password);
480eba 554             $temp_password = $inst->free_query('Re-enter admin password', '');
272da6 555             $check = @($temp_password == $conf['interface_password'])?true:false;
480eba 556             if(!$check) swriteln('Passwords do not match.');
272da6 557         } while (!$check);
FS 558     }
559     unset($check);
560     unset($temp_password);
dec0df 561     if($conf['apache']['installed'] == true) $conf['apache']['vhost_port']  = $ispconfig_vhost_port;
T 562     if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port']  = $ispconfig_vhost_port;
563     unset($ispconfig_vhost_port);
532ae5 564
b04e82 565     if(strtolower($inst->simple_query('Do you want a secure (SSL) connection to the ISPConfig web interface', array('y', 'n'), 'y','ispconfig_use_ssl')) == 'y') {     
b1a6a5 566         $inst->make_ispconfig_ssl_cert();
939b92 567     }
da3c0c 568     $inst->install_ispconfig_interface = true;
939b92 569
da3c0c 570 } else {
MB 571     $inst->install_ispconfig_interface = false;
572 }
b1a6a5 573
da3c0c 574 $inst->install_ispconfig();
532ae5 575
da3c0c 576 //* Configure DBServer
MB 577 swriteln('Configuring DBServer');
578 $inst->configure_dbserver();
b1a6a5 579
da3c0c 580 //* Configure ISPConfig
MB 581 swriteln('Installing ISPConfig crontab');
582 if($conf['cron']['installed']) {
532ae5 583     swriteln('Installing ISPConfig crontab');
L 584     $inst->install_crontab();
da3c0c 585 } else swriteln('[ERROR] Cron not found');
b1a6a5 586
da3c0c 587 swriteln('Detect IP addresses');
MB 588 $inst->detect_ips();
b1a6a5 589
da3c0c 590 swriteln('Restarting services ...');
MB 591 if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
592 if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
593 if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
594 if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
595 if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '') system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
596 if($conf['courier']['installed'] == true){
597     if($conf['courier']['courier-authdaemon'] != '') system($inst->getinitcommand($conf['courier']['courier-authdaemon'], 'restart'));
598     if($conf['courier']['courier-imap'] != '') system($inst->getinitcommand($conf['courier']['courier-imap'], 'restart'));
599     if($conf['courier']['courier-imap-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-imap-ssl'], 'restart'));
600     if($conf['courier']['courier-pop'] != '') system($inst->getinitcommand($conf['courier']['courier-pop'], 'restart'));
601     if($conf['courier']['courier-pop-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-pop-ssl'], 'restart'));
602 }
603 if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
604 if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
605 if($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart'));
606 //* Reload is enough for nginx
607 if($conf['nginx']['installed'] == true){
608     if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload'));
609     if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
610 }
611 if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
612 if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
613 if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
614 if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
615 //if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['squid']['init_script']))     system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null');
616 if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null');
617 if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '') system($inst->getinitcommand($conf['ufw']['init_script'], 'restart').' &> /dev/null');
618 if($conf['xmpp']['installed'] == true && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['init_script'], 'restart').' &> /dev/null');
b1a6a5 619
532ae5 620
d5f2d5 621 $inst->create_mount_script();
MC 622
1ed92e 623 //* Create md5 filelist
TB 624 $md5_filename = '/usr/local/ispconfig/security/data/file_checksums_'.date('Y-m-d_h-i').'.md5';
625 exec('find /usr/local/ispconfig -type f -print0 | xargs -0 md5sum > '.$md5_filename);
626 chmod($md5_filename,0700);
627
532ae5 628
L 629 echo "Installation completed.\n";
630
631
bedf79 632 ?>