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