Marius Cramer
2015-11-17 c8509bf2e438adcf80591a6bc072359d6d44ed97
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
992797 61 define('INSTALLER_RUN', true);
MC 62
532ae5 63 //** The banner on the command line
7fe908 64 echo "\n\n".str_repeat('-', 80)."\n";
532ae5 65 echo " _____ ___________   _____              __ _         ____
L 66 |_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
67   | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
68   | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
69  _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
70  \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
71                                               __/ |
72                                              |___/ ";
7fe908 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
7fe908 77 require_once 'lib/install.lib.php';
532ae5 78
L 79 //** Include the base class of the installer class
7fe908 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
7fe908 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';
136 include_once 'dist/conf/'.$dist['id'].'.conf.php';
532ae5 137
L 138 //****************************************************************************************************
7fe908 139 //** Installer Interface
532ae5 140 //****************************************************************************************************
L 141 $inst = new installer();
60b700 142
532ae5 143 swriteln($inst->lng('    Following will be a few questions for primary configuration so be careful.'));
L 144 swriteln($inst->lng('    Default values are in [brackets] and can be accepted with <ENTER>.'));
145 swriteln($inst->lng('    Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
146
147 //** Check log file is writable (probably not root or sudo)
148 if(!is_writable(dirname(ISPC_LOG_FILE))){
7fe908 149     die("ERROR: Cannot write to the ".dirname(ISPC_LOG_FILE)." directory. Are you root or sudo ?\n\n");
532ae5 150 }
L 151
152 if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
153     die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
154 }
155
156 if(is_dir('/usr/local/ispconfig')) {
157     die('ISPConfig 3 installation found. Please use update.php instead if install.php to update the installation.');
158 }
159
160 //** Detect the installed applications
161 $inst->find_installed_apps();
162
8cf78b 163 //** Select the language and set default timezone
b04e82 164 $conf['language'] = $inst->simple_query('Select language', array('en', 'de'), 'en','language');
3898c9 165 $conf['timezone'] = get_system_timezone();
532ae5 166
992797 167 //* Set default theme
f598b0 168 $conf['theme'] = 'default';
992797 169 $conf['language_file_import_enabled'] = true;
f598b0 170
532ae5 171 //** Select installation mode
b04e82 172 $install_mode = $inst->simple_query('Installation mode', array('standard', 'expert'), 'standard','install_mode');
532ae5 173
L 174
175 //** Get the hostname
176 $tmp_out = array();
177 exec('hostname -f', $tmp_out);
b04e82 178 $conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', @$tmp_out[0],'hostname');
532ae5 179 unset($tmp_out);
L 180
181 // Check if the mysql functions are loaded in PHP
182 if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.');
183
184 //** Get MySQL root credentials
185 $finished = false;
186 do {
b04e82 187     $tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host'],'mysql_hostname');     
TB 188     $tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user'],'mysql_root_user');     
189     $tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password'],'mysql_root_password');     
190     $tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database'],'mysql_database');     
191     $tmp_mysql_server_charset = $inst->free_query('MySQL charset', $conf['mysql']['charset'],'mysql_charset');
bcd725 192     
8cf78b 193     if($install_mode == 'expert') {
T 194         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 195         
b04e82 196         $conf['mysql']['ispconfig_user'] = $inst->free_query('ISPConfig mysql database username', $conf['mysql']['ispconfig_user'],'mysql_ispconfig_user');     
TB 197         $conf['mysql']['ispconfig_password'] = $inst->free_query('ISPConfig mysql database password', $conf['mysql']['ispconfig_password'],'mysql_ispconfig_password');
8cf78b 198     }
7fe908 199
532ae5 200     //* Initialize the MySQL server connection
L 201     if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
202         $conf['mysql']['host'] = $tmp_mysql_server_host;
203         $conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
204         $conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password;
205         $conf['mysql']['database'] = $tmp_mysql_server_database;
206         $conf['mysql']['charset'] = $tmp_mysql_server_charset;
207         $finished = true;
208     } else {
209         swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error());
210     }
211 } while ($finished == false);
212 unset($finished);
213
214 // Resolve the IP address of the MySQL hostname.
7fe908 215 $tmp = explode(':', $conf['mysql']['host']);
532ae5 216 if(!$conf['mysql']['ip'] = gethostbyname($tmp[0])) die('Unable to resolve hostname'.$tmp[0]);
L 217 unset($tmp);
218
219
220 //** Initializing database connection
7fe908 221 include_once 'lib/mysql.lib.php';
532ae5 222 $inst->db = new db();
L 223
224 //** Begin with standard or expert installation
225 if($install_mode == 'standard') {
7fe908 226
532ae5 227     //* Create the MySQL database
L 228     $inst->configure_database();
7fe908 229
4ffb51 230     //* Configure Webserver - Apache or nginx
F 231     if($conf['apache']['installed'] == true && $conf['nginx']['installed'] == true) {
b04e82 232         $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache', 'nginx'), 'apache','http_server');
4ffb51 233         if($http_server_to_use == 'apache'){
F 234             $conf['nginx']['installed'] = false;
235         } else {
236             $conf['apache']['installed'] = false;
237         }
238     }
7fe908 239
532ae5 240     //* Insert the Server record into the database
L 241     $inst->add_database_server_record();
242
243     //* Configure Postfix
244     $inst->configure_postfix();
7fe908 245
532ae5 246     //* Configure Mailman
f9d95c 247     if($conf['mailman']['installed'] == true) {
CS 248         $inst->configure_mailman('install');
249     }
7fe908 250
532ae5 251     //* Configure jailkit
L 252     swriteln('Configuring Jailkit');
253     $inst->configure_jailkit();
7fe908 254
532ae5 255     if($conf['dovecot']['installed'] == true) {
L 256         //* Configure Dovecot
257         swriteln('Configuring Dovecot');
258         $inst->configure_dovecot();
259     } else {
260         //* Configure saslauthd
261         swriteln('Configuring SASL');
262         $inst->configure_saslauthd();
263
264         //* Configure PAM
265         swriteln('Configuring PAM');
266         $inst->configure_pam();
7fe908 267
532ae5 268         //* Configure Courier
L 269         swriteln('Configuring Courier');
270         $inst->configure_courier();
271     }
272
273     //* Configure Spamasassin
274     swriteln('Configuring Spamassassin');
275     $inst->configure_spamassassin();
276
277     //* Configure Amavis
278     swriteln('Configuring Amavisd');
279     $inst->configure_amavis();
280
281     //* Configure Getmail
282     swriteln('Configuring Getmail');
283     $inst->configure_getmail();
7fe908 284
532ae5 285     //* Configure Pureftpd
L 286     swriteln('Configuring Pureftpd');
287     $inst->configure_pureftpd();
288
289     //* Configure DNS
290     if($conf['powerdns']['installed'] == true) {
291         swriteln('Configuring PowerDNS');
292         $inst->configure_powerdns();
293     } elseif($conf['bind']['installed'] == true) {
294         swriteln('Configuring BIND');
295         $inst->configure_bind();
296     } else {
297         swriteln('Configuring MyDNS');
298         $inst->configure_mydns();
299     }
7fe908 300
532ae5 301     //* Configure Apache
4ffb51 302     if($conf['apache']['installed'] == true){
F 303         swriteln('Configuring Apache');
304         $inst->configure_apache();
305     }
7fe908 306
4ffb51 307     //* Configure nginx
F 308     if($conf['nginx']['installed'] == true){
309         swriteln('Configuring nginx');
310         $inst->configure_nginx();
311     }
7fe908 312
MC 313     //** Configure Vlogger
314     swriteln('Configuring Vlogger');
315     $inst->configure_vlogger();
316
532ae5 317     //** Configure apps vhost
L 318     swriteln('Configuring Apps vhost');
319     $inst->configure_apps_vhost();
7fe908 320
532ae5 321     //* Configure Firewall
992797 322     //* Configure Bastille Firewall
MC 323     $conf['services']['firewall'] = true;
324     swriteln('Configuring Bastille Firewall');
325     $inst->configure_firewall();
c12af9 326
7fe908 327     //* Configure Fail2ban
MC 328     if($conf['fail2ban']['installed'] == true) {
329         swriteln('Configuring Fail2ban');
330         $inst->configure_fail2ban();
331     }
332
4ffb51 333     /*
80e3c9 334     if($conf['squid']['installed'] == true) {
T 335         $conf['services']['proxy'] = true;
336         swriteln('Configuring Squid');
337         $inst->configure_squid();
338     } else if($conf['nginx']['installed'] == true) {
339         $conf['services']['proxy'] = true;
340         swriteln('Configuring Nginx');
341         $inst->configure_nginx();
342     }
4ffb51 343     */
7fe908 344
532ae5 345     //* Configure ISPConfig
L 346     swriteln('Installing ISPConfig');
7fe908 347
532ae5 348     //** Customize the port ISPConfig runs on
b04e82 349     $ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080','ispconfig_port');
dec0df 350     if($conf['apache']['installed'] == true) $conf['apache']['vhost_port']  = $ispconfig_vhost_port;
T 351     if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port']  = $ispconfig_vhost_port;
352     unset($ispconfig_vhost_port);
532ae5 353
b04e82 354     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') {     
TB 355         $inst->make_ispconfig_ssl_cert();
939b92 356     }
M 357
532ae5 358     $inst->install_ispconfig();
7fe908 359
532ae5 360     //* Configure DBServer
L 361     swriteln('Configuring DBServer');
362     $inst->configure_dbserver();
363
364     //* Configure ISPConfig
365     swriteln('Installing ISPConfig crontab');
366     $inst->install_crontab();
7fe908 367
532ae5 368     swriteln('Restarting services ...');
574a16 369     if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
3327ed 370     if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
FT 371     if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
372     if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
373     if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '') system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
374     if($conf['courier']['installed'] == true){
375         if($conf['courier']['courier-authdaemon'] != '') system($inst->getinitcommand($conf['courier']['courier-authdaemon'], 'restart'));
376         if($conf['courier']['courier-imap'] != '') system($inst->getinitcommand($conf['courier']['courier-imap'], 'restart'));
377         if($conf['courier']['courier-imap-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-imap-ssl'], 'restart'));
378         if($conf['courier']['courier-pop'] != '') system($inst->getinitcommand($conf['courier']['courier-pop'], 'restart'));
379         if($conf['courier']['courier-pop-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-pop-ssl'], 'restart'));
380     }
381     if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
382     if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
33bcd0 383     if($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart'));
4ffb51 384     //* Reload is enough for nginx
F 385     if($conf['nginx']['installed'] == true){
33bcd0 386         if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload'));
FT 387         if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
4ffb51 388     }
3327ed 389     if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
33bcd0 390     if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
FT 391     if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
392     if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
7fe908 393     //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');
33bcd0 394     if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null');
7fe908 395     //if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['ufw']['init_script']))     system($conf['init_scripts'].'/'.$conf['ufw']['init_script'].' restart &> /dev/null');
3327ed 396 } else {
7fe908 397
532ae5 398     //* In expert mode, we select the services in the following steps, only db is always available
L 399     $conf['services']['mail'] = false;
400     $conf['services']['web'] = false;
401     $conf['services']['dns'] = false;
402     $conf['services']['db'] = true;
80e3c9 403     $conf['services']['firewall'] = false;
T 404     $conf['services']['proxy'] = false;
7fe908 405
MC 406
532ae5 407     //** Get Server ID
L 408     // $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1');
409     // Server ID is an autoInc value of the mysql database now
b04e82 410     if(strtolower($inst->simple_query('Shall this server join an existing ISPConfig multiserver setup', array('y', 'n'), 'n','join_multiserver_setup')) == 'y') {
532ae5 411         $conf['mysql']['master_slave_setup'] = 'y';
7fe908 412
532ae5 413         //** Get MySQL root credentials
L 414         $finished = false;
415         do {
b04e82 416             $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname'); 
TB 417             $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user');     
418             $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password'); 
419             $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
7fe908 420
532ae5 421             //* Initialize the MySQL server connection
L 422             if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
423                 $conf['mysql']['master_host'] = $tmp_mysql_server_host;
424                 $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
425                 $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
426                 $conf['mysql']['master_database'] = $tmp_mysql_server_database;
427                 $finished = true;
428             } else {
429                 swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
430             }
431         } while ($finished == false);
432         unset($finished);
7fe908 433
532ae5 434         // initialize the connection to the master database
L 435         $inst->dbmaster = new db();
436         if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
437         $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
438         $inst->dbmaster->dbName = $conf['mysql']["master_database"];
439         $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
440         $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
7fe908 441
532ae5 442     } else {
L 443         // the master DB is the same then the slave DB
444         $inst->dbmaster = $inst->db;
445     }
7fe908 446
532ae5 447     //* Create the mysql database
L 448     $inst->configure_database();
7fe908 449
4ffb51 450     //* Configure Webserver - Apache or nginx
F 451     if($conf['apache']['installed'] == true && $conf['nginx']['installed'] == true) {
b04e82 452         $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache', 'nginx'), 'apache','http_server');
4ffb51 453         if($http_server_to_use == 'apache'){
F 454             $conf['nginx']['installed'] = false;
455         } else {
456             $conf['apache']['installed'] = false;
457         }
458     }
7fe908 459
532ae5 460     //* Insert the Server record into the database
L 461     swriteln('Adding ISPConfig server record to database.');
462     swriteln('');
463     $inst->add_database_server_record();
464
b04e82 465     if(strtolower($inst->simple_query('Configure Mail', array('y', 'n') , 'y','configure_mail') ) == 'y') {
7fe908 466
532ae5 467         $conf['services']['mail'] = true;
7fe908 468
532ae5 469         //* Configure Postfix
L 470         swriteln('Configuring Postfix');
471         $inst->configure_postfix();
7fe908 472
532ae5 473         //* Configure Mailman
L 474         swriteln('Configuring Mailman');
475         $inst->configure_mailman();
476
477         if($conf['dovecot']['installed'] == true) {
478             //* Configure dovecot
479             swriteln('Configuring Dovecot');
480             $inst->configure_dovecot();
481         } else {
7fe908 482
532ae5 483             //* Configure saslauthd
L 484             swriteln('Configuring SASL');
485             $inst->configure_saslauthd();
7fe908 486
532ae5 487             //* Configure PAM
L 488             swriteln('Configuring PAM');
489             $inst->configure_pam();
7fe908 490
532ae5 491             //* Configure courier
L 492             swriteln('Configuring Courier');
493             $inst->configure_courier();
494         }
495
496         //* Configure Spamasassin
497         swriteln('Configuring Spamassassin');
498         $inst->configure_spamassassin();
499
500         //* Configure Amavis
501         swriteln('Configuring Amavisd');
502         $inst->configure_amavis();
503
504         //* Configure Getmail
505         swriteln('Configuring Getmail');
506         $inst->configure_getmail();
7fe908 507
3327ed 508         if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
FT 509         if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
510         if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
511         if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '') system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
512         if($conf['courier']['installed'] == true){
513             if($conf['courier']['courier-authdaemon'] != '') system($inst->getinitcommand($conf['courier']['courier-authdaemon'], 'restart'));
514             if($conf['courier']['courier-imap'] != '') system($inst->getinitcommand($conf['courier']['courier-imap'], 'restart'));
515             if($conf['courier']['courier-imap-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-imap-ssl'], 'restart'));
516             if($conf['courier']['courier-pop'] != '') system($inst->getinitcommand($conf['courier']['courier-pop'], 'restart'));
517             if($conf['courier']['courier-pop-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-pop-ssl'], 'restart'));
518         }
519         if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
520         if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
532ae5 521     }
7fe908 522
532ae5 523     //** Configure Jailkit
b04e82 524     if(strtolower($inst->simple_query('Configure Jailkit', array('y', 'n'), 'y','configure_jailkit') ) == 'y') {
532ae5 525         swriteln('Configuring Jailkit');
L 526         $inst->configure_jailkit();
527     }
7fe908 528
532ae5 529     //** Configure Pureftpd
b04e82 530     if(strtolower($inst->simple_query('Configure FTP Server', array('y', 'n'), 'y','configure_ftp') ) == 'y') {
532ae5 531         swriteln('Configuring Pureftpd');
L 532         $inst->configure_pureftpd();
3327ed 533         if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
532ae5 534     }
7fe908 535
532ae5 536     //** Configure DNS
b04e82 537     if(strtolower($inst->simple_query('Configure DNS Server', array('y', 'n'), 'y','configure_dns')) == 'y') {
532ae5 538         $conf['services']['dns'] = true;
L 539         //* Configure DNS
540         if($conf['powerdns']['installed'] == true) {
541             swriteln('Configuring PowerDNS');
542             $inst->configure_powerdns();
33bcd0 543             if($conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
532ae5 544         } elseif($conf['bind']['installed'] == true) {
L 545             swriteln('Configuring BIND');
546             $inst->configure_bind();
33bcd0 547             if($conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
532ae5 548         } else {
L 549             swriteln('Configuring MyDNS');
550             $inst->configure_mydns();
33bcd0 551             if($conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
532ae5 552         }
7fe908 553
532ae5 554     }
7fe908 555
4ffb51 556     /*
80e3c9 557     //** Configure Squid
7fe908 558     if(strtolower($inst->simple_query('Configure Proxy Server', array('y','n'),'y') ) == 'y') {
80e3c9 559         if($conf['squid']['installed'] == true) {
T 560             $conf['services']['proxy'] = true;
561             swriteln('Configuring Squid');
562             $inst->configure_squid();
563             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');
564         } else if($conf['nginx']['installed'] == true) {
565             $conf['services']['proxy'] = true;
566             swriteln('Configuring Nginx');
567             $inst->configure_nginx();
568             if($conf['nginx']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['nginx']['init_script']))system($conf['init_scripts'].'/'.$conf['nginx']['init_script'].' restart &> /dev/null');
569         }
570     }
4ffb51 571     */
7fe908 572
532ae5 573     //** Configure Apache
4ffb51 574     if($conf['apache']['installed'] == true){
F 575         swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure Apache Server' option.\n");
b04e82 576         if(strtolower($inst->simple_query('Configure Apache Server', array('y', 'n'), 'y','configure_apache')) == 'y') {
4ffb51 577             $conf['services']['web'] = true;
F 578             swriteln('Configuring Apache');
579             $inst->configure_apache();
7fe908 580
4ffb51 581             //** Configure Vlogger
F 582             swriteln('Configuring Vlogger');
583             $inst->configure_vlogger();
7fe908 584
4ffb51 585             //** Configure apps vhost
F 586             swriteln('Configuring Apps vhost');
587             $inst->configure_apps_vhost();
588         }
589     }
7fe908 590
4ffb51 591     //** Configure nginx
F 592     if($conf['nginx']['installed'] == true){
593         swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure nginx Server' option.\n");
b04e82 594         if(strtolower($inst->simple_query('Configure nginx Server', array('y', 'n'), 'y','configure_nginx')) == 'y') {
4ffb51 595             $conf['services']['web'] = true;
F 596             swriteln('Configuring nginx');
597             $inst->configure_nginx();
7fe908 598
4ffb51 599             //** Configure Vlogger
F 600             //swriteln('Configuring Vlogger');
601             //$inst->configure_vlogger();
7fe908 602
4ffb51 603             //** Configure apps vhost
F 604             swriteln('Configuring Apps vhost');
605             $inst->configure_apps_vhost();
606         }
532ae5 607     }
7fe908 608
532ae5 609     //** Configure Firewall
b04e82 610     if(strtolower($inst->simple_query('Configure Firewall Server', array('y', 'n'), 'y','configure_firewall')) == 'y') {
992797 611         //if($conf['bastille']['installed'] == true) {
7fe908 612         //* Configure Bastille Firewall
MC 613         $conf['services']['firewall'] = true;
614         swriteln('Configuring Bastille Firewall');
615         $inst->configure_firewall();
992797 616         /*} elseif($conf['ufw']['installed'] == true) {
80e3c9 617             //* Configure Ubuntu Firewall
T 618             $conf['services']['firewall'] = true;
619             swriteln('Configuring Ubuntu Firewall');
620             $inst->configure_ufw_firewall();
621         }
992797 622         */
80e3c9 623     }
7fe908 624
80e3c9 625     //** Configure Firewall
7fe908 626     /*if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') {
532ae5 627         swriteln('Configuring Firewall');
L 628         $inst->configure_firewall();
80e3c9 629     }*/
7fe908 630
532ae5 631     //** Configure ISPConfig :-)
7b47c0 632     $install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y';
b04e82 633     if(strtolower($inst->simple_query('Install ISPConfig Web Interface', array('y', 'n'), $install_ispconfig_interface_default,'install_ispconfig_web_interface')) == 'y') {
532ae5 634         swriteln('Installing ISPConfig');
7fe908 635
532ae5 636         //** We want to check if the server is a module or cgi based php enabled server
L 637         //** TODO: Don't always ask for this somehow ?
638         /*
639         $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
640
641         if($fast_cgi == 'yes') {
642              $alias = $inst->free_query('Script Alias', '/php/');
643              $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
644              $conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
645         } else {
646              $conf['apache']['vhost_cgi_alias'] = "";
647         }
648         */
649
650         //** Customise the port ISPConfig runs on
b04e82 651         $ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080','ispconfig_port');
4ffb51 652         if($conf['apache']['installed'] == true) $conf['apache']['vhost_port']  = $ispconfig_vhost_port;
F 653         if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port']  = $ispconfig_vhost_port;
654         unset($ispconfig_vhost_port);
7fe908 655
b04e82 656         if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface', array('y', 'n'), 'y','ispconfig_use_ssl')) == 'y') {
TB 657             $inst->make_ispconfig_ssl_cert();
532ae5 658         }
7fe908 659
532ae5 660         $inst->install_ispconfig_interface = true;
7fe908 661
532ae5 662     } else {
L 663         $inst->install_ispconfig_interface = false;
664     }
7fe908 665
532ae5 666     $inst->install_ispconfig();
7fe908 667
532ae5 668     //* Configure DBServer
L 669     swriteln('Configuring DBServer');
670     $inst->configure_dbserver();
7fe908 671
532ae5 672     //* Configure ISPConfig
L 673     swriteln('Installing ISPConfig crontab');
674     $inst->install_crontab();
33bcd0 675     if($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart'));
4ffb51 676     //* Reload is enough for nginx
F 677     if($conf['nginx']['installed'] == true){
33bcd0 678         if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload'));
FT 679         if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
4ffb51 680     }
7fe908 681
MC 682
683
532ae5 684 } //* << $install_mode / 'Standard' or Genius
L 685
1ed92e 686 //* Create md5 filelist
TB 687 $md5_filename = '/usr/local/ispconfig/security/data/file_checksums_'.date('Y-m-d_h-i').'.md5';
688 exec('find /usr/local/ispconfig -type f -print0 | xargs -0 md5sum > '.$md5_filename);
689 chmod($md5_filename,0700);
690
532ae5 691
L 692 echo "Installation completed.\n";
693
694
7fe908 695 ?>