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