Commit cc3fb3d9 authored by oliver's avatar oliver

fixed some bugs in the installer

parent 92bea0b6
......@@ -3,63 +3,77 @@
//*** Debian 4.0 default settings
//* Main
$dist['init_scripts'] = '/etc/init.d';
$dist['runlevel'] = '/etc';
$dist['shells'] = '/etc/shells';
$dist['cron_tab'] = '/var/spool/cron/crontabs/root';
$dist['pam'] = '/etc/pam.d';
$conf['language'] = 'en';
$conf['distname'] = 'debian40';
$conf['hostname'] = 'server1.example.com'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['cron_tab'] = '/var/spool/cron/crontabs/root';
$conf['pam'] = '/etc/pam.d';
//* MySQL
$dist['mysql']['init_script'] = 'mysql';
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = '5sDrewBhk';
//* Apache
$dist['apache']['user'] = 'www-data';
$dist['apache']['group'] = 'www-data';
$dist['apache']['init_script'] = 'apache2';
$dist['apache']['version'] = '2.2';
$dist['apache']['vhost_dist_dir'] = '/etc/apache2/sites-available';
$dist['apache']['vhost_dist_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
//* Postfix
$dist['postfix']['config_dir'] = '/etc/postfix';
$dist['postfix']['init_script'] = 'postfix';
$dist['postfix']['user'] = 'postfix';
$dist['postfix']['group'] = 'postfix';
$dist['postfix']['vmail_userid'] = '5000';
$dist['postfix']['vmail_username'] = 'vmail';
$dist['postfix']['vmail_groupid'] = '5000';
$dist['postfix']['vmail_groupname'] = 'vmail';
$dist['postfix']['vmail_mailbox_base'] = '/home/vmail';
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/home/vmail';
//* Getmail
$dist['getmail']['config_dir'] = '/etc/getmail';
$dist['getmail']['program'] = '/usr/bin/getmail';
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$dist['courier']['config_dir'] = '/etc/courier';
$dist['courier']['courier-authdaemon'] = 'courier-authdaemon';
$dist['courier']['courier-imap'] = 'courier-imap';
$dist['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$dist['courier']['courier-pop'] = 'courier-pop';
$dist['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* SASL
$dist['saslauthd']['config'] = '/etc/default/saslauthd';
$dist['saslauthd']['init_script'] = 'saslauthd';
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$dist['amavis']['config_dir'] = '/etc/amavis';
$dist['amavis']['init_script'] = 'amavis';
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$dist['clamav']['init_script'] = 'clamav-daemon';
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$dist['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$dist['pureftpd']['init_script'] = 'pure-ftpd-mysql';
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$dist['mydns']['config_dir'] = '/etc';
$dist['mydns']['init_script'] = 'mydns';
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
?>
\ No newline at end of file
......@@ -52,21 +52,18 @@ echo "\n\n>> Initial configuration \n\n";
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
require_once('options.conf.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Include the distribution specific installer class library and configuration
include_once('dist/lib/'.$conf['distname'].'.lib.php');
include_once('dist/conf/'.$conf['distname'].'.conf.php');
//** Get distribution identifier
$distname = get_distname();
//** Copt the $dist created in dist/conf/foo to global var
$conf['dist'] = $dist;
//** Include the distribution specific installer class library and configuration
include_once('dist/lib/'.$distname.'.lib.php');
include_once('dist/conf/'.$distname.'.conf.php');
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
//****************************************************************************************************
......@@ -78,8 +75,8 @@ swriteln($inst->lng(' Default values are in [brackets] and can be accepted wi
swriteln($inst->lng(' Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
//** Check log file is writable (probably not root or sudo)
if(!is_writable(ISPC_LOG_FILE)){
die("ERROR: Cannot write to the log file '".ISPC_LOG_FILE."'. Are you root or sudo ?\n\n");
if(!is_writable(dirname(ISPC_LOG_FILE))){
die("ERROR: Cannot write to the directory ".dirname(ISPC_LOG_FILE).". Are you root or sudo ?\n\n");
}
//** Select the language
......@@ -92,7 +89,7 @@ $install_mode = $inst->simple_query('Installation mode', array('Standard','Exper
//** Get the hostname
$tmp_out = array();
exec('hostname -f', $tmp_out);
$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg foo.example.com ', $tmp_out[0]);
$inst->conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg foo.example.com ', $tmp_out[0]);
unset($tmp_out);
//** Get MySQL root credentials
......@@ -175,19 +172,19 @@ if($install_mode == 'Standard') {
$inst->install_crontab();
swriteln('Restarting services ...');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['mysql']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['postfix']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['saslauthd']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['amavis']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['clamav']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-authdaemon'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-imap'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-imap-ssl'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-pop'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-pop-ssl'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['apache']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['pureftpd']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['mydns']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart');
}else{
......@@ -226,29 +223,29 @@ if($install_mode == 'Standard') {
swriteln('Configuring Getmail');
$inst->configure_getmail();
system($conf['dist']['init_scripts'].'/'.$conf['dist']['postfix']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['saslauthd']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['amavis']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['clamav']['init_script'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-authdaemon'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-imap'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-imap-ssl'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-pop'].' restart');
system($conf['dist']['init_scripts'].'/'.$conf['dist']['courier']['courier-pop-ssl'].' restart');
system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
}
//** Configure Pureftpd
if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') {
swriteln('Configuring Pureftpd');
$inst->configure_pureftpd();
system($conf['dist']['init_scripts'].'/'.$conf['dist']['pureftpd']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
}
//** Configure MyDNS
if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') {
swriteln('Configuring MyDNS');
$inst->configure_mydns();
system($conf['dist']['init_scripts'].'/'.$conf['dist']['mydns']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart');
}
//** Configure Apache
......@@ -265,7 +262,7 @@ if($install_mode == 'Standard') {
//* Configure ISPConfig
swriteln('Installing Crontab');
$inst->install_crontab();
system($conf['dist']['init_scripts'].'/'.$conf['dist']['apache']['init_script'].' restart');
system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
}
} //* << $install_mode / 'Standard' or Genius
......
......@@ -56,9 +56,22 @@ error_reporting(E_ALL|E_STRICT);
$FILE = realpath('../install.php');
//** Get distribution identifier
function get_distname() {
global $conf; // TODO wtf ?
$distname = $conf['distname'];
//** Debian
if(file_exists('/etc/debian_version')) {
if(trim(file_get_contents('/etc/debian_version')) == '4.0') {
$distname = 'debian40';
}
}
//** Redhat
elseif(file_exists("/etc/redhat_release")) {
}
return $distname;
}
......
......@@ -33,7 +33,7 @@ class installer_base {
var $wb = array();
var $language = 'en';
var $db;
private $conf;
public $conf;
public function __construct()
......@@ -161,7 +161,7 @@ class installer_base {
//** writes postfix configuration files
private function process_postfix_config($configfile)
{
$config_dir = $this->conf['dist']['postfix']['config_dir'].'/';
$config_dir = $this->conf['postfix']['config_dir'].'/';
$full_file_name = $config_dir.$configfile;
//* Backup exiting file
if(is_file($full_file_name)){
......@@ -179,7 +179,7 @@ class installer_base {
public function configure_postfix($options = '')
{
$cf = $this->conf['dist']['postfix'];
$cf = $this->conf['postfix'];
$config_dir = $cf['config_dir'];
if(!is_dir($config_dir)){
......@@ -337,14 +337,14 @@ class installer_base {
$configfile = 'sasl_smtpd.conf';
if(is_file($conf["dist"]["postfix"]["config_dir"].'/sasl/smtpd.conf')) copy($conf["dist"]["postfix"]["config_dir"].'/sasl/smtpd.conf',$conf["dist"]["postfix"]["config_dir"].'/sasl/smtpd.conf~');
if(is_file($conf["dist"]["postfix"]["config_dir"].'/sasl/smtpd.conf~')) exec('chmod 400 '.$conf["dist"]["postfix"]["config_dir"].'/sasl/smtpd.conf~');
if(is_file($conf["postfix"]["config_dir"].'/sasl/smtpd.conf')) copy($conf["postfix"]["config_dir"].'/sasl/smtpd.conf',$conf["postfix"]["config_dir"].'/sasl/smtpd.conf~');
if(is_file($conf["postfix"]["config_dir"].'/sasl/smtpd.conf~')) exec('chmod 400 '.$conf["postfix"]["config_dir"].'/sasl/smtpd.conf~');
$content = rf("tpl/".$configfile.".master");
$content = str_replace('{mysql_server_ispconfig_user}',$this->conf['mysql']['ispconfig_user'],$content);
$content = str_replace('{mysql_server_ispconfig_password}',$this->conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}',$this->conf['mysql']['database'],$content);
$content = str_replace('{mysql_server_ip}',$this->conf['mysql']['ip'],$content);
wf($conf["dist"]["postfix"]["config_dir"].'/sasl/smtpd.conf',$content);
wf($conf["postfix"]["config_dir"].'/sasl/smtpd.conf',$content);
// TODO: Chmod and chown on the config file
......@@ -354,7 +354,7 @@ class installer_base {
exec('mkdir -p /var/spool/postfix/var/run/saslauthd');
// Edit the file /etc/default/saslauthd
$configfile = $conf['dist']["saslauthd"]["config"];
$configfile = $conf["saslauthd"]["config"];
if(is_file($configfile)) copy($configfile,$configfile.'~');
if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~');
$content = rf($configfile);
......@@ -363,7 +363,7 @@ class installer_base {
wf($configfile,$content);
// Edit the file /etc/init.d/saslauthd
$configfile = $conf["dist"]["init_scripts"].'/'.$conf["dist"]["saslauthd"]["init_script"];
$configfile = $conf["init_scripts"].'/'.$conf["saslauthd"]["init_script"];
$content = rf($configfile);
$content = str_replace('PIDFILE=$RUN_DIR/saslauthd.pid','PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"',$content);
wf($configfile,$content);
......@@ -373,7 +373,7 @@ class installer_base {
public function configure_pam()
{
$pam = $this->conf['dist']['pam'];
$pam = $this->conf['pam'];
//* configure pam for SMTP authentication agains the ispconfig database
$configfile = 'pamd_smtp';
if(is_file("$pam/smtp")) copy("$pam/smtp", "$pam/smtp~");
......@@ -392,7 +392,7 @@ class installer_base {
public function configure_courier()
{
$config_dir = $this->conf['dist']['courier']['config_dir'];
$config_dir = $this->conf['courier']['config_dir'];
//* authmysqlrc
$configfile = 'authmysqlrc';
if(is_file("$config_dir/$configfile")){
......@@ -410,7 +410,7 @@ class installer_base {
exec("chown daemon:daemon $config_dir/$configfile");
//* authdaemonrc
$configfile = $this->conf['dist']['courier']['config_dir'].'/authdaemonrc';
$configfile = $this->conf['courier']['config_dir'].'/authdaemonrc';
if(is_file($configfile)){
copy($configfile, $configfile.'~');
}
......@@ -427,15 +427,15 @@ class installer_base {
// amavisd user config file
$configfile = 'amavisd_user_config';
if(is_file($conf["dist"]["amavis"]["config_dir"].'/conf.d/50-user')) copy($conf["dist"]["amavis"]["config_dir"].'/conf.d/50-user',$conf["dist"]["courier"]["config_dir"].'/50-user~');
if(is_file($conf["dist"]["amavis"]["config_dir"].'/conf.d/50-user~')) exec('chmod 400 '.$conf["dist"]["amavis"]["config_dir"].'/conf.d/50-user~');
if(is_file($conf["amavis"]["config_dir"].'/conf.d/50-user')) copy($conf["amavis"]["config_dir"].'/conf.d/50-user',$conf["courier"]["config_dir"].'/50-user~');
if(is_file($conf["amavis"]["config_dir"].'/conf.d/50-user~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/conf.d/50-user~');
$content = rf("tpl/".$configfile.".master");
$content = str_replace('{mysql_server_ispconfig_user}',$this->conf['mysql']['ispconfig_user'],$content);
$content = str_replace('{mysql_server_ispconfig_password}',$this->conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}',$this->conf['mysql']['database'],$content);
$content = str_replace('{mysql_server_port}',$conf["mysql"]["port"],$content);
$content = str_replace('{mysql_server_ip}',$this->conf['mysql']['ip'],$content);
wf($conf["dist"]["amavis"]["config_dir"].'/conf.d/50-user',$content);
wf($conf["amavis"]["config_dir"].'/conf.d/50-user',$content);
// TODO: chmod and chown on the config file
......@@ -447,7 +447,7 @@ class installer_base {
);
// Make a backup copy of the main.cf file
copy($conf["dist"]["postfix"]["config_dir"].'/main.cf',$conf["dist"]["postfix"]["config_dir"].'/main.cf~2');
copy($conf["postfix"]["config_dir"].'/main.cf',$conf["postfix"]["config_dir"].'/main.cf~2');
// Executing the postconf commands
foreach($postconf_commands as $cmd) {
......@@ -456,11 +456,11 @@ class installer_base {
}
// Append the configuration for amavisd to the master.cf file
if(is_file($conf["dist"]["postfix"]["config_dir"].'/master.cf')) copy($conf["dist"]["postfix"]["config_dir"].'/master.cf',$conf["dist"]["postfix"]["config_dir"].'/master.cf~');
if(is_file($conf["postfix"]["config_dir"].'/master.cf')) copy($conf["postfix"]["config_dir"].'/master.cf',$conf["postfix"]["config_dir"].'/master.cf~');
$content = rf("tpl/master_cf_amavis.master");
// Only add the content if we had not addded it before
if(!stristr("127.0.0.1:10025 inet n - - - - smtpd",$content)) {
af($conf["dist"]["postfix"]["config_dir"].'/master.cf',$content);
af($conf["postfix"]["config_dir"].'/master.cf',$content);
}
// Add the clamav user to the amavis group
......@@ -483,7 +483,7 @@ class installer_base {
public function configure_getmail()
{
$config_dir = $this->conf['dist']['getmail']['config_dir'];
$config_dir = $this->conf['getmail']['config_dir'];
$command = "useradd -d $config_dir getmail";
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
......@@ -498,7 +498,7 @@ class installer_base {
public function configure_pureftpd()
{
$config_dir = $this->conf['dist']['pureftpd']['config_dir'];
$config_dir = $this->conf['pureftpd']['config_dir'];
//* configure pam for SMTP authentication agains the ispconfig database
$configfile = 'db/mysql.conf';
......@@ -528,17 +528,17 @@ class installer_base {
// configure pam for SMTP authentication agains the ispconfig database
$configfile = 'mydns.conf';
if(is_file($conf["dist"]["mydns"]["config_dir"].'/'.$configfile)) copy($conf["dist"]["mydns"]["config_dir"].'/'.$configfile,$conf["dist"]["mydns"]["config_dir"].'/'.$configfile.'~');
if(is_file($conf["dist"]["mydns"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["dist"]["mydns"]["config_dir"].'/'.$configfile.'~');
if(is_file($conf["mydns"]["config_dir"].'/'.$configfile)) copy($conf["mydns"]["config_dir"].'/'.$configfile,$conf["mydns"]["config_dir"].'/'.$configfile.'~');
if(is_file($conf["mydns"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["mydns"]["config_dir"].'/'.$configfile.'~');
$content = rf("tpl/".$configfile.".master");
$content = str_replace('{mysql_server_ispconfig_user}',$this->conf['mysql']['ispconfig_user'],$content);
$content = str_replace('{mysql_server_ispconfig_password}',$this->conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}',$this->conf['mysql']['database'],$content);
$content = str_replace('{mysql_server_host}',$conf["mysql"]["host"],$content);
$content = str_replace('{server_id}',$conf["server_id"],$content);
wf($conf["dist"]["mydns"]["config_dir"].'/'.$configfile,$content);
exec('chmod 600 '.$conf["dist"]["mydns"]["config_dir"].'/'.$configfile);
exec('chown root:root '.$conf["dist"]["mydns"]["config_dir"].'/'.$configfile);
wf($conf["mydns"]["config_dir"].'/'.$configfile,$content);
exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile);
exec('chown root:root '.$conf["mydns"]["config_dir"].'/'.$configfile);
}
......@@ -627,8 +627,8 @@ class installer_base {
//* Copy the ISPConfig vhost for the controlpanel
//TODO These are missing! should they be "vhost_dist_*_dir" ?
$vhost_conf_dir = $this->conf['dist']['apache']['vhost_conf_dir'];
$vhost_conf_enabled_dir = $this->conf['dist']['apache']['vhost_conf_enabled_dir'];
$vhost_conf_dir = $this->conf['apache']['vhost_conf_dir'];
$vhost_conf_enabled_dir = $this->conf['apache']['vhost_conf_enabled_dir'];
copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
//* and create the symlink
if(!is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) {
......@@ -653,7 +653,7 @@ class installer_base {
unlink('crontab.txt');
//* Getmail crontab
$cf = $this->conf['dist']['getmail'];
$cf = $this->conf['getmail'];
exec('crontab -u getmail -l > crontab.txt');
$existing_cron_jobs = file('crontab.txt');
......
......@@ -38,8 +38,10 @@ require_once('lib/install.lib.php');
// Include the base class of the installer class
require_once('lib/installer_base.lib.php');
include_once("options.conf.php");
$conf['dist'] = $dist;
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
//** Get distribution identifier
$distname = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
......@@ -68,24 +70,38 @@ echo "This application will update ISPConfig 3 on your server.\n";
// Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
$inst->db = new db();
// Database update is a bit brute force and should be rebuild later ;)
// export the current database data
if($conf["mysql"]["admin_password"] != '') {
system("mysqldump -h $conf[mysql_server_host] -u $conf[mysql_server_admin_user] -p$conf[mysql_server_admin_password] -c -t --add-drop-table --all --quick $conf[mysql_server_database] > existing_db.sql");
} else {
system("mysqldump -h $conf[mysql_server_host] -u $conf[mysql_server_admin_user] -c -t --add-drop-table --all --quick $conf[mysql_server_database] > existing_db.sql");
if( empty($conf["mysql"]["admin_password"]) ) {
$conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
}
if( !empty($conf["mysql"]["admin_password"]) ) {
system("mysqldump -h ".$conf['mysql']['host']." -u ".$conf['mysql']['admin_user']." -p".$conf['mysql']['admin_password']." -c -t --add-drop-table --all --quick ".$conf['mysql']['database']." > existing_db.sql");
}
else {
system("mysqldump -h ".$conf['mysql']['host']." -u ".$conf['mysql']['admin_user']." -c -t --add-drop-table --all --quick ".$conf['mysql']['database']." > existing_db.sql");
}
// Delete the old database
exec("/etc/init.d/mysql stop");
$inst->db = new db();
if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['mysql']['database']) ) {
$inst->error('Unable to drop MySQL database: '.$conf['mysql']['database'].'.');
}
/*exec("/etc/init.d/mysql stop");
sleep(3);
if($conf["mysql"]["database"] != '') exec("rm -rf /var/lib/mysql/".$conf["mysql"]["database"]);
exec("/etc/init.d/mysql start");
sleep(5);
sleep(5);*/
// Create the mysql database
$inst->configure_database();
......@@ -98,9 +114,9 @@ foreach($db_tables as $table) {
// load old data back into database
if($conf["mysql"]["admin_password"] != '') {
system("mysql -h $conf[mysql_server_host] -u $conf[mysql_server_admin_user] -p$conf[mysql_server_admin_password] $conf[mysql_server_database] < existing_db.sql");
system("mysql -h ".$conf['mysql']['host']." -u ".$conf['mysql']['admin_user']." -p".$conf['mysql']['admin_password']." ".$conf['mysql']['database']." < existing_db.sql");
} else {
system("mysql -h $conf[mysql_server_host] -u $conf[mysql_server_admin_user] $conf[mysql_server_database] < existing_db.sql");
system("mysql -h ".$conf['mysql']['host']." -u ".$conf['mysql']['admin_user']." ".$conf['mysql']['database']." < existing_db.sql");
}
// Configure postfix
$inst->configure_postfix('dont-create-certs');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment