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