From a32f329d71f43df93faadf8bdb9d67ed5eebb1a3 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 26 Oct 2010 10:05:12 -0400
Subject: [PATCH] Use yes / no for ssl query in updater instead of y / n
---
install/lib/update.lib.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php
index 874f3fd..8faff1a 100644
--- a/install/lib/update.lib.php
+++ b/install/lib/update.lib.php
@@ -58,8 +58,25 @@
// create a backup copy of the ispconfig database in the root folder
$backup_db_name = '/root/ispconfig_db_backup_'.@date('Y-m-d_h-i').'.sql';
copy('existing_db.sql',$backup_db_name);
- exec("chmod 700 $backup_db_name");
- exec("chown root:root $backup_db_name");
+ chmod($backup_db_name, 0700);
+ chown($backup_db_name, 'root');
+ chgrp($backup_db_name, 'root');
+
+ if ($conf['powerdns']['installed']) {
+ //** export the current PowerDNS database data
+ 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 --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']);
+ } else {
+ system("mysqldump -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']);
+ }
+
+ // create a backup copy of the PowerDNS database in the root folder
+ $backup_db_name = '/root/ispconfig_powerdns_db_backup_'.@date('Y-m-d_h-i').'.sql';
+ copy('existing_powerdns_db.sql',$backup_db_name);
+ chmod($backup_db_name, 0700);
+ chown($backup_db_name, 'root');
+ chgrp($backup_db_name, 'root');
+ }
}
function updateDbAndIni() {
@@ -134,6 +151,41 @@
} else {
system("mysql --default-character-set=".$conf['mysql']['charset']." --force -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' ".$conf['mysql']['database']." < existing_db.sql");
}
+
+ //** Get the database version number based on the patchfile
+ $found = true;
+ while($found == true) {
+ $next_db_version = intval($current_db_version + 1);
+ $patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
+ if(is_file($patch_filename)) {
+ $current_db_version = $next_db_version;
+ } else {
+ $found = false;
+ }
+ }
+
+ //* update the database version in server table
+ $inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']);
+
+ if ($conf['powerdns']['installed']) {
+
+ swriteln($inst->lng('Starting full PowerDNS database update.'));
+
+ //** Delete the old PowerDNS database
+ if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['powerdns']['database']) ) {
+ $inst->error('Unable to drop MySQL database: '.$conf['powerdns']['database'].'.');
+ }
+
+ //** Create the mysql database
+ $inst->configure_powerdns();
+
+ //** load old data back into the PowerDNS database
+ if( !empty($conf["mysql"]["admin_password"]) ) {
+ system("mysql --default-character-set=".$conf['mysql']['charset']." --force -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' ".$conf['powerdns']['database']." < existing_powerdns_db.sql");
+ } else {
+ system("mysql --default-character-set=".$conf['mysql']['charset']." --force -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' ".$conf['powerdns']['database']." < existing_powerdns_db.sql");
+ }
+ }
}
--
Gitblit v1.9.1