if (!isset($form->dbcluster)) {
$form->dbcluster = '';
}
+ if (!isset($form->pathtopgdump)) {
+ $form->pathtopgdump = '';
+ }
+ if (!isset($form->pathtopsql)) {
+ $form->pathtopsql = '';
+ }
?>
<form name="migratefrom" action="utfdbmigrate.php" method="POST">
<input name="migrate" type="hidden" value="1" />
<input name="sesskey" type="hidden" value="<?php echo sesskey() ?>" />
<?php if (isset($err["dbconnect"])) formerr($err["dbconnect"]); ?>
-<table cellpadding="9" cellspacing="0" >
+<?php if (isset($err["pathtopgdump"])) formerr($err["pathtopgdump"]); ?>
+<?php if (isset($err["pathtopsql"])) formerr($err["pathtopsql"]); ?>
+<table cellpadding="9" cellspacing="0" width="500">
<tr valign="top">
<td align="right"><?php print_string("dbhost", "install") ?>:</td>
<td><input type="text" name="dbhost" value="<?php p($form->dbhost) ?>" />
<tr valign="top">
<td align="right"><?php print_string("pgcluster", "admin") ?>:</td>
<td><input type="text" name="dbcluster" value="<?php p($form->dbcluster) ?>" />
- <br />
- <?php print_string("pgclusterdescription", "admin") ?>
- </td>
+ <td><?php print_string("pgclusterdescription", "admin") ?></td>
+</tr>
+<tr valign="top">
+ <td align="right" nowrap="nowrap"><?php print_string("pathtopgdump","admin") ?>:</td>
+ <td><input type="text" name="pathtopgdump" value="<?php p($form->pathtopgdump) ?>" />
+ <td><?php print_string("pathtopgdumpdesc","admin"); ?></td>
+</tr>
+<tr valign="top">
+ <td align="right" nowrap="nowrap"><?php print_string("pathtopsql","admin") ?>:</td>
+ <td><input type="text" name="pathtopsql" value="<?php p($form->pathtopsql) ?>" />
+ <td><?php print_string("pathtopsqldesc","admin"); ?></td>
</tr>
</table>
<center>
} else {
$cluster = '';
}
- $cmd = "PGPASSWORD={$CFG->dbpass} PGCLIENTENCODING='UNICODE' PGDATABASE={$CFG->dbname} pg_dump -Fp -O -x -U {$CFG->dbuser}$cluster";
+ $pgdump = 'pg_dump';
+ if (!empty($_SESSION['newpostgresdb']->pathtopgdump)) {
+ $pgdump = $_SESSION['newpostgresdb']->pathtopgdump;
+ }
+ $psql = 'psql';
+ if (!empty($_SESSION['newpostgresdb']->pathtopsql)) {
+ $pgsql = $_SESSION['newpostgresdb']->pathtopsql;
+ }
+
+ $cmd = "PGPASSWORD={$CFG->dbpass} PGCLIENTENCODING='UNICODE' PGDATABASE={$CFG->dbname} $pgdump -Fp -O -x -U {$CFG->dbuser}$cluster";
if ($CFG->dbhost) {
$host = split(":", $CFG->dbhost);
if ($host[0]) $cmd .= " -h {$host[0]}";
$cmds[] = $cmd;
$cmds[] = 'grep -v "COMMENT ON SCHEMA"';
$cmds[] = 'iconv -f UTF-8 -t UTF-8 -c';
- $cmd = "PGPASSWORD={$_SESSION['newpostgresdb']->dbpass} PGDATABASE={$_SESSION['newpostgresdb']->dbname} psql -q -U {$_SESSION['newpostgresdb']->dbuser} -v ON_ERROR_STOP=1$cluster";
+ $cmd = "PGPASSWORD={$_SESSION['newpostgresdb']->dbpass} PGDATABASE={$_SESSION['newpostgresdb']->dbname} $psql -q -U {$_SESSION['newpostgresdb']->dbuser} -v ON_ERROR_STOP=1$cluster";
if ($_SESSION['newpostgresdb']->dbhost) {
$host = split(":", $_SESSION['newpostgresdb']->dbhost);
if ($host[0]) $cmd .= " -h {$host[0]}";
$cmds[] = $cmd;
foreach ($cmds as $key => $cmd) {
$files[] = tempnam($CFG->dataroot, 'utf8_');
- exec($cmd . ($key?" < {$files[$key-1]}":'') . " 2>&1 > {$files[$key]}", $output, $return_var);
+ $cmd = $cmd . ($key?" < {$files[$key-1]}":'') . " 2>&1 > {$files[$key]}";
+ if (stripos(PHP_OS, 'darwin') !== false && stripos($cmd,'iconv') !== false) {
+ // I know this looks DREADFULLY hackish, but the iconv in mac os x seems to have a return code of 1 for warnings
+ // and I cannot figure out why, it's a very different version of iconv to most *nix versions, even seems to be a
+ // different gnu project.
+ // If someone can figure out a better way to do this, FEEL FREE :)
+ // - Penny
+ $cmd .= ' || true';
+ }
+ exec($cmd, $output, $return_var);
if ($key) {
unlink($files[$key-1]);
}
return;
}
+ if (!empty($form->pathtopgdump) && !is_executable($form->pathtopgdump)) {
+ $err['pathtopgdump'] = get_string('pathtopgdumpinvalid','admin');
+ return;
+ }
+
+ if (!empty($form->pathtopsql) && !is_executable($form->pathtopsql)) {
+ $err['pathtopsql'] = get_string('pathtopsqlinvalid','admin');
+ return;
+ }
+
return;
}
$string['pathdvips'] = 'Path of <i>dvips</i> binary';
$string['pathconvert'] = 'Path of <i>convert</i> binary';
$string['pathlatex'] = 'Path of <i>latex</i> binary';
+$string['pathtopgdump'] = 'Path to pg_dump';
+$string['pathtopgdumpdesc'] = 'This is only necessary to enter if you have more than one pg_dump on your system (for example if you have more than one version of postgresql installed)';
+$string['pathtopgdumpinvalid'] = 'Invalid path to pg_dump - either wrong path or not executable';
+$string['pathtopsql'] = 'Path to psql';
+$string['pathtopsqldesc'] = 'This is only necessary to enter if you have more than one psql on your system (for example if you have more than one version of postgresql installed)';
+$string['pathtopsqlinvalid'] = 'Invalid path to psql - either wrong path or not executable';
$string['pleaseregister'] = 'Please register your site to remove this button';
$string['pgcluster'] = 'PostgreSQL Cluster';
-$string['pgclusterdescription'] = '<pre>PostgreSQL version/cluster parameter
-for command line operations.
-If you only have one postgresql
-on your system or you are not
-sure what this is, leave this blank.</pre>';
+$string['pgclusterdescription'] = 'PostgreSQL version/cluster parameter for command line operations. If you only have one postgresql on your system or you are not sure what this is, leave this blank.';
$string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.';
$string['sitelangchanged'] = 'Site language setting changed successfully';
$string['sitemaintenance'] = 'The site is undergoing maintenance and is currently not available';