tbrehm
2008-08-18 f94f455f022be7cbdeae37ebde64211da7d0d138
install/update.php
@@ -69,11 +69,23 @@
include_once('dist/lib/'.$distname.'.lib.php');
include_once('dist/conf/'.$distname.'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = $conf_old["server_id"];
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
@@ -128,13 +140,37 @@
   system("mysql -h ".$conf['mysql']['host']." -u ".$conf['mysql']['admin_user']." ".$conf['mysql']['database']." < existing_db.sql");
}
//** Update server ini
$tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
$old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config']));
unset($tmp_server_rec);
$tpl_ini_array = ini_to_array(rf('tpl/server.ini.master'));
// update the new template with the old values
foreach($old_ini_array as $tmp_section_name => $tmp_section_content) {
   foreach($tmp_section_content as $tmp_var_name => $tmp_var_content) {
      $tpl_ini_array[$tmp_section_name][$tmp_var_name] = $tmp_var_content;
   }
}
$new_ini = array_to_ini($tpl_ini_array);
$inst->db->query("UPDATE server SET config = '".addslashes($new_ini)."' WHERE server_id = ".$conf['server_id']);
unset($old_ini_array);
unset($tpl_ini_array);
unset($new_ini);
//** Shall the services be reconfigured during update
$reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', array('yes','no'),'yes');
if($reconfigure_services_answer == 'yes') {
   //** Configure postfix
   $inst->configure_postfix('dont-create-certs');
   //* Configure postfix
   swriteln('Configuring Jailkit');
   $inst->configure_jailkit();
   //** Configure saslauthd
   swriteln('Configuring SASL');
   $inst->configure_saslauthd();
@@ -170,30 +206,24 @@
   //** Configure Apache
   swriteln('Configuring Apache');
   $inst->configure_apache();
   //* Configure DBServer
   swriteln('Configuring DBServer');
   $inst->configure_dbserver();
   //if(@is_dir('/etc/Bastille')) {
      //* Configure Firewall
      swriteln('Configuring Firewall');
      $inst->configure_firewall();
   //}
}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** We want to check if the server is a module or cgi based php enabled server
//** TODO: Don't always ask for this somehow ?
$fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
if($fast_cgi == 'yes') {
    $alias = $inst->free_query('Script Alias', '/php/');
    $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
    $inst->conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
    $inst->conf['apache']['vhost_cgi_alias_path'] = $path;
} else {
    $inst->conf['apache']['vhost_cgi_alias'] = "";
    $inst->conf['apache']['vhost_cgi_alias_path'] = "";
}
//** Customise the port ISPConfig runs on
$inst->conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
$inst->install_ispconfig();