Marius Burkard
2016-05-23 9376d70f0ccba49ead95ef47f0ecba568ea2d6e1
commit | author | age
8896ab 1 <?php
N 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 updater.
b04e82 33     
TB 34     -------------------------------------------------------------------------------------
35     - Interactive update
36     -------------------------------------------------------------------------------------
37     run:
38     
39     php update.php
40     
41     -------------------------------------------------------------------------------------
42     - Noninteractive (autoupdate) mode
43     -------------------------------------------------------------------------------------
44     
45     The autoupdate mode can read the updater 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 update.php --autoinstall=autoinstall.ini
52     
53     or
54     
55     php update.php --autoinstall=autoinstall.conf.php
56     
8896ab 57 */
N 58
59 error_reporting(E_ALL|E_STRICT);
60
992797 61 define('INSTALLER_RUN', true);
MC 62
8896ab 63 //** The banner on the command line
b1a6a5 64 echo "\n\n".str_repeat('-', 80)."\n";
8896ab 65 echo " _____ ___________   _____              __ _         ____
N 66 |_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
67   | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
68   | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
69  _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
70  \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
71                                               __/ |
72                                              |___/ ";
b1a6a5 73 echo "\n".str_repeat('-', 80)."\n";
8896ab 74 echo "\n\n>> Update  \n\n";
N 75
76 //** Include the library with the basic installer functions
b1a6a5 77 require_once 'lib/install.lib.php';
8896ab 78
N 79 //** Include the library with the basic updater functions
b1a6a5 80 require_once 'lib/update.lib.php';
8896ab 81
N 82 //** Include the base class of the installer class
b1a6a5 83 require_once 'lib/installer_base.lib.php';
8896ab 84
N 85 //** Ensure that current working directory is install directory
86 $cur_dir = getcwd();
87 if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
88
89 //** Install logfile
90 define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
91 define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
92
ccbf14 93 //** Include the templating lib
TB 94 require_once 'lib/classes/tpl.inc.php';
95
8896ab 96 //** Check for ISPConfig 2.x versions
N 97 if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
98     die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
99 }
100
101 //** Get distribution identifier
102 $dist = get_distname();
103
b1a6a5 104 include_once "/usr/local/ispconfig/server/lib/config.inc.php";
8896ab 105 $conf_old = $conf;
N 106 unset($conf);
107
108 if($dist['id'] == '') die('Linux distribution or version not recognized.');
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 }
bcd725 136
8896ab 137 //** Include the distribution-specific installer class library and configuration
b1a6a5 138 if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php';
MC 139 include_once 'dist/lib/'.$dist['id'].'.lib.php';
140 include_once 'dist/conf/'.$dist['id'].'.conf.php';
8896ab 141
N 142 //** Get hostname
143 exec('hostname -f', $tmp_out);
144 $conf['hostname'] = $tmp_out[0];
145 unset($tmp_out);
146
147 //** Set the mysql login information
148 $conf["mysql"]["host"] = $conf_old["db_host"];
149 $conf["mysql"]["database"] = $conf_old["db_database"];
150 $conf['mysql']['charset'] = 'utf8';
151 $conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
152 $conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
153 $conf['language'] = $conf_old['language'];
d6b361 154 $conf['theme'] = $conf_old['theme'];
8896ab 155 if($conf['language'] == '{language}') $conf['language'] = 'en';
355efb 156 $conf['timezone'] = (isset($conf_old['timezone']))?$conf_old['timezone']:'UTC';
8cf78b 157 if($conf['timezone'] == '{timezone}' or trim($conf['timezone']) == '') $conf['timezone'] = 'UTC';
992797 158 $conf['language_file_import_enabled'] = (isset($conf_old['language_file_import_enabled']))?$conf_old['language_file_import_enabled']:true;
8896ab 159
N 160 if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
161 if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
162 if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
163 if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
164
165 //* Check if this is a master / slave setup
166 if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
167     $conf['mysql']['master_slave_setup'] = 'y';
168 }
169
170 // Resolve the IP address of the mysql hostname.
171 if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
172
173 $conf['server_id'] = intval($conf_old["server_id"]);
174 $conf['ispconfig_log_priority'] = $conf_old["log_priority"];
175
176 $inst = new installer();
cc45ab 177 if (!$inst->get_php_version()) die('ISPConfig requieres PHP '.$inst->min_php."\n");
8896ab 178 $inst->is_update = true;
N 179
8cf78b 180 echo "This application will update ISPConfig 3 on your server.\n\n";
T 181
182 //* Make a backup before we start the update
b04e82 183 $do_backup = $inst->simple_query('Shall the script create a ISPConfig backup in /var/backup/ now?', array('yes', 'no'), 'yes','do_backup');
bcd725 184
8cf78b 185 if($do_backup == 'yes') {
b1a6a5 186
8cf78b 187     //* Create the backup directory
cc6568 188     $backup_path = '/var/backup/ispconfig_'.@date('Y-m-d_H-i');
8cf78b 189     $conf['backup_path'] = $backup_path;
T 190     exec("mkdir -p $backup_path");
191     exec("chown root:root $backup_path");
192     exec("chmod 700 $backup_path");
b1a6a5 193
8cf78b 194     //* Do the backup
T 195     swriteln('Creating backup of "/usr/local/ispconfig" directory...');
b1a6a5 196     exec("tar pcfz $backup_path/ispconfig_software.tar.gz /usr/local/ispconfig 2> /dev/null", $out, $returnvar);
8cf78b 197     if($returnvar != 0) die("Backup failed. We stop here...\n");
b1a6a5 198
8cf78b 199     swriteln('Creating backup of "/etc" directory...');
b1a6a5 200     exec("tar pcfz $backup_path/etc.tar.gz /etc 2> /dev/null", $out, $returnvar);
8cf78b 201     if($returnvar != 0) die("Backup failed. We stop here...\n");
b1a6a5 202
8cf78b 203     exec("chown root:root $backup_path/*.tar.gz");
T 204     exec("chmod 700 $backup_path/*.tar.gz");
205 }
206
8896ab 207
N 208 //** Initialize the MySQL server connection
b1a6a5 209 include_once 'lib/mysql.lib.php';
8896ab 210
N 211 //** Database update is a bit brute force and should be rebuild later ;)
212
213 /*
214  * Try to read the DB-admin settings
215  */
b1a6a5 216 $clientdb_host   = '';
MC 217 $clientdb_user   = '';
218 $clientdb_password  = '';
219 include_once "/usr/local/ispconfig/server/lib/mysql_clientdb.conf";
8896ab 220 $conf["mysql"]["admin_user"] = $clientdb_user;
N 221 $conf["mysql"]["admin_password"] = $clientdb_password;
b1a6a5 222 $clientdb_host   = '';
MC 223 $clientdb_user   = '';
224 $clientdb_password  = '';
8896ab 225
edf806 226 //** Test mysql root connection
T 227 $finished = false;
228 do {
f1926a 229     if(@mysqli_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) {
edf806 230         $finished = true;
T 231     } else {
8a8cc2 232         swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_connect_error());
b04e82 233         $conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password'],'mysql_root_password');
edf806 234     }
T 235 } while ($finished == false);
236 unset($finished);
8896ab 237
N 238 /*
b1a6a5 239  *  Prepare the dump of the database
8896ab 240  */
N 241 prepareDBDump();
242
243 //* initialize the database
244 $inst->db = new db();
245
246 //* initialize the master DB, if we have a multiserver setup
247 if($conf['mysql']['master_slave_setup'] == 'y') {
b1a6a5 248     //** Get MySQL root credentials
MC 249     $finished = false;
250     do {
b04e82 251         $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname');
82e9b9 252         $tmp_mysql_server_port = $inst->free_query('MySQL master server port', $conf['mysql']['master_port'],'mysql_master_port');
b04e82 253         $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user');     
TB 254         $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password');
255         $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'mysql_master_database');
b1a6a5 256
MC 257         //* Initialize the MySQL server connection
8a8cc2 258         if(@mysqli_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, $tmp_mysql_server_database, (int)$tmp_mysql_server_port)) {
b1a6a5 259             $conf['mysql']['master_host'] = $tmp_mysql_server_host;
82e9b9 260             $conf['mysql']['master_port'] = $tmp_mysql_server_port;
b1a6a5 261             $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
MC 262             $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
263             $conf['mysql']['master_database'] = $tmp_mysql_server_database;
264             $finished = true;
265         } else {
8a8cc2 266             swriteln($inst->lng('Unable to connect to mysql server').' '.mysqli_connect_error());
b1a6a5 267         }
MC 268     } while ($finished == false);
269     unset($finished);
270
271     // initialize the connection to the master database
272     $inst->dbmaster = new db();
273     if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
305dda 274     $inst->dbmaster->setDBData($conf['mysql']["master_host"], $conf['mysql']["master_admin_user"], $conf['mysql']["master_admin_password"]);
MC 275     $inst->dbmaster->setDBName($conf['mysql']["master_database"]);
8896ab 276 } else {
N 277     $inst->dbmaster = $inst->db;
278 }
279
280 /*
281  *  Check all tables
282 */
283 checkDbHealth();
284
285 /*
286  *  dump the new Database and reconfigure the server.ini
287  */
288 updateDbAndIni();
289
290 /*
291  * Reconfigure the permisson if needed
292  * (if this is done at client side, only this client is updated.
293  * If this is done at server side, all clients are updated.
294  */
295 //if($conf_old['dbmaster_user'] != '' or $conf_old['dbmaster_host'] != '') {
b1a6a5 296 //** Update master database rights
b04e82 297 $reconfigure_master_database_rights_answer = $inst->simple_query('Reconfigure Permissions in master database?', array('yes', 'no'), 'no','reconfigure_permissions_in_master_database');
8896ab 298
b1a6a5 299 if($reconfigure_master_database_rights_answer == 'yes') {
MC 300     $inst->grant_master_database_rights();
301 }
8896ab 302 //}
N 303
cffef2 304 //** Detect the installed applications
FS 305 $inst->find_installed_apps();
306
307 $conf['services']['mail'] = $conf['postfix']['installed'];
308 if ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed']) $conf['services']['dns'] = true;
309 if ($conf['apache']['installed'] || $conf['nginx']['installed']) $conf['services']['web'] = true;
310 $conf['services']['xmpp'] =  $conf['xmpp']['installed'];;
311 if ($conf['ufw']['installed'] || $conf['firewall']['installed']) $conf['services']['firewall'] = true;
312 $conf['services']['vserver'] = $conf['services']['vserver'];
313 $conf['services']['db'] = true;
314
315
8896ab 316 //** Shall the services be reconfigured during update
418f62 317 $reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', array('yes', 'no', 'selected'), 'yes','reconfigure_services');
8896ab 318
418f62 319 if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'selected') {
b1a6a5 320
8896ab 321     if($conf['services']['mail']) {
418f62 322
8896ab 323         //** Configure postfix
acb2f9 324         if($inst->reconfigure_app('Postfix and IMAP/POP3', $reconfigure_services_answer)) {
418f62 325             swriteln('Configuring Postfix');
FS 326             $inst->configure_postfix('dont-create-certs');
acb2f9 327
FS 328             if($conf['dovecot']['installed'] == true) {
3dded7 329                 //* Configure dovecot
FS 330                 swriteln('Configuring Dovecot');
331                 $inst->configure_dovecot();
acb2f9 332             } elseif ($conf['courier']['installed'] == true) {
FS 333                 //** Configure saslauthd
334                 swriteln('Configuring SASL');
335                 $inst->configure_saslauthd();
336
337                 //** Configure PAM
338                 swriteln('Configuring PAM');
339                 $inst->configure_pam();
340
341                 //* Configure courier
342                 swriteln('Configuring Courier');
343                 $inst->configure_courier();
344             }
345
418f62 346         }
b1a6a5 347
8896ab 348         //** Configure mailman
418f62 349         if($conf['mailman']['installed'] == true && $inst->reconfigure_app('Mailman', $reconfigure_services_answer)) {
f9d95c 350             swriteln('Configuring Mailman');
CS 351             $inst->configure_mailman('update');
8896ab 352         }
N 353
354         //** Configure Spamasassin
418f62 355         if($inst->reconfigure_app('Spamassassin', $reconfigure_services_answer)) {
FS 356             swriteln('Configuring Spamassassin');
357             $inst->configure_spamassassin();
358         }
8896ab 359
N 360         //** Configure Amavis
418f62 361         if($conf['amavis']['installed'] == true && $inst->reconfigure_app('Amavisd', $reconfigure_services_answer)) {
e7516a 362             swriteln('Configuring Amavisd');
CS 363             $inst->configure_amavis();
364         }
8896ab 365
N 366         //** Configure Getmail
418f62 367         if ($inst->reconfigure_app('Getmail', $reconfigure_services_answer)) {
FS 368             swriteln('Configuring Getmail');
369             $inst->configure_getmail();
370         }
8896ab 371     }
b1a6a5 372
418f62 373     if($conf['services']['dns'] && $inst->reconfigure_app('DNS', $reconfigure_services_answer)) {
8896ab 374         //* Configure DNS
N 375         if($conf['powerdns']['installed'] == true) {
376             swriteln('Configuring PowerDNS');
377             $inst->configure_powerdns();
378         } elseif($conf['bind']['installed'] == true) {
379             swriteln('Configuring BIND');
380             $inst->configure_bind();
57e982 381             if(!is_installed('haveged')) {
ead7ad 382                 swriteln("[INFO] haveged not detected - DNSSEC can fail");
FS 383             }
8896ab 384         } else {
N 385             swriteln('Configuring MyDNS');
386             $inst->configure_mydns();
387         }
388     }
b1a6a5 389
8896ab 390     if($conf['services']['web']) {
b1a6a5 391
418f62 392         if($conf['pureftpd']['installed'] == true && $inst->reconfigure_app('Pureftpd', $reconfigure_services_answer)) {
FS 393             //** Configure Pureftpd
394             swriteln('Configuring Pureftpd');
395             $inst->configure_pureftpd();
4ffb51 396         }
b1a6a5 397
418f62 398         if($inst->reconfigure_app('Web-Server', $reconfigure_services_answer)) {
FS 399             if($conf['webserver']['server_type'] == 'apache'){
400                 //** Configure Apache
401                 swriteln('Configuring Apache');
402                 $inst->configure_apache();
8896ab 403
418f62 404                 //** Configure vlogger
FS 405                 swriteln('Configuring vlogger');
406                 $inst->configure_vlogger();
407             } else {
408                 //** Configure nginx
409                 swriteln('Configuring nginx');
410                 $inst->configure_nginx();
411             }
412
413             //** Configure apps vhost
414             swriteln('Configuring Apps vhost');
415             $inst->configure_apps_vhost();
416             }
cffef2 417     
FS 418             //* Configure Jailkit
419             if($inst->reconfigure_app('Jailkit', $reconfigure_services_answer)) {
420                 swriteln('Configuring Jailkit');
421                 $inst->configure_jailkit();
422             }
423
418f62 424         }
FS 425
426     if($conf['services']['xmpp'] && $inst->reconfigure_app('XMPP', $reconfigure_services_answer)) {
fbe2d6 427         //** Configure Metronome XMPP
MF 428         $inst->configure_xmpp('dont-create-certs');
429     }
430
418f62 431     if($conf['services']['firewall'] && $inst->reconfigure_app('Firewall', $reconfigure_services_answer)) {
bd68aa 432         if($conf['ufw']['installed'] == true) {
MC 433             //* Configure Ubuntu Firewall
434             $conf['services']['firewall'] = true;
435             swriteln('Configuring Ubuntu Firewall');
436             $inst->configure_ufw_firewall();
437         } else {
8896ab 438             //* Configure Bastille Firewall
N 439             swriteln('Configuring Bastille Firewall');
bd68aa 440             $inst->configure_bastille_firewall();
8896ab 441         }
N 442     }
b1a6a5 443
418f62 444     //* Configure DBServer
FS 445     swriteln('Configuring Database');
446     $inst->configure_dbserver();
447
4ffb51 448     /*
8896ab 449     if($conf['squid']['installed'] == true) {
N 450         swriteln('Configuring Squid');
451         $inst->configure_squid();
452     } else if($conf['nginx']['installed'] == true) {
453         swriteln('Configuring Nginx');
454         $inst->configure_nginx();
455     }
4ffb51 456     */
8896ab 457 }
N 458
459 //** Configure ISPConfig
460 swriteln('Updating ISPConfig');
6ba4fa 461 if($conf['apache']['installed'] == true){
FT 462     if(!is_file($conf['apache']['vhost_conf_dir'].'/ispconfig.vhost')) $inst->install_ispconfig_interface = false;
463 }
464 if($conf['nginx']['installed'] == true){
465     if(!is_file($conf['nginx']['vhost_conf_dir'].'/ispconfig.vhost')) $inst->install_ispconfig_interface = false;
466 }
8896ab 467
b67344 468 if ($conf['services']['web'] && $inst->install_ispconfig_interface) {
8896ab 469     //** Customise the port ISPConfig runs on
N 470     $ispconfig_port_number = get_ispconfig_port_number();
bcd725 471     if($autoupdate['ispconfig_port'] == 'default') $autoupdate['ispconfig_port'] = $ispconfig_port_number;
4ffb51 472     if($conf['webserver']['server_type'] == 'nginx'){
b04e82 473         $conf['nginx']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number,'ispconfig_port');
4ffb51 474     } else {
b04e82 475         $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number,'ispconfig_port');
4ffb51 476     }
b1a6a5 477
MC 478
8896ab 479     // $ispconfig_ssl_default = (is_ispconfig_ssl_enabled() == true)?'y':'n';
b04e82 480     if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate', array('yes', 'no'), 'no','create_new_ispconfig_ssl_cert')) == 'yes') {
8896ab 481         $inst->make_ispconfig_ssl_cert();
N 482     }
483 }
484
485 $inst->install_ispconfig();
486
5b3f25 487 // Cleanup
TB 488 $inst->cleanup_ispconfig();
489
8896ab 490 //** Configure Crontab
b04e82 491 $update_crontab_answer = $inst->simple_query('Reconfigure Crontab?', array('yes', 'no'), 'yes','reconfigure_crontab');
8896ab 492 if($update_crontab_answer == 'yes') {
N 493     swriteln('Updating Crontab');
494     $inst->install_crontab();
495 }
496
497 //** Restart services:
498 if($reconfigure_services_answer == 'yes') {
499     swriteln('Restarting services ...');
1e67c1 500     if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
8896ab 501     if($conf['services']['mail']) {
3327ed 502         if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
FT 503         if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
504         if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
505         if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '') system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
506         if($conf['courier']['installed'] == true){
507             if($conf['courier']['courier-authdaemon'] != '') system($inst->getinitcommand($conf['courier']['courier-authdaemon'], 'restart'));
508             if($conf['courier']['courier-imap'] != '') system($inst->getinitcommand($conf['courier']['courier-imap'], 'restart'));
509             if($conf['courier']['courier-imap-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-imap-ssl'], 'restart'));
510             if($conf['courier']['courier-pop'] != '') system($inst->getinitcommand($conf['courier']['courier-pop'], 'restart'));
511             if($conf['courier']['courier-pop-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-pop-ssl'], 'restart'));
512         }
513         if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
514         if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
8896ab 515     }
N 516     if($conf['services']['web']) {
33bcd0 517         if($conf['webserver']['server_type'] == 'apache' && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart'));
4ffb51 518         //* Reload is enough for nginx
F 519         if($conf['webserver']['server_type'] == 'nginx'){
33bcd0 520             if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload'));
FT 521             if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
4ffb51 522         }
3327ed 523         if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
8896ab 524     }
N 525     if($conf['services']['dns']) {
33bcd0 526         if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
FT 527         if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
528         if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
8896ab 529     }
b1a6a5 530
fbe2d6 531     if($conf['services']['xmpp']) {
461977 532         if($conf['xmpp']['installed'] == true && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['init_script'], 'restart').' &> /dev/null');
fbe2d6 533     }
MF 534
8896ab 535     if($conf['services']['proxy']) {
b1a6a5 536         // if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script']))     system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null');
33bcd0 537         if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null');
8896ab 538     }
b1a6a5 539
8896ab 540     if($conf['services']['firewall']) {
b1a6a5 541         if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['ufw']['init_script']))     system($conf['init_scripts'].'/'.$conf['ufw']['init_script'].' restart &> /dev/null');
8896ab 542     }
N 543 }
544
75b7fc 545 //* Set default servers
MC 546 setDefaultServers();
547
d5f2d5 548 $inst->create_mount_script();
MC 549
1ed92e 550 //* Create md5 filelist
TB 551 $md5_filename = '/usr/local/ispconfig/security/data/file_checksums_'.date('Y-m-d_h-i').'.md5';
cffa2f 552 exec('find /usr/local/ispconfig -type f -print0 | xargs -0 md5sum > '.$md5_filename . ' 2>/dev/null');
1ed92e 553 chmod($md5_filename,0700);
TB 554
8896ab 555 echo "Update finished.\n";
N 556
557 ?>