+if ($aResult['init-updates']) {
+ $sSetup = CONST_InstallPath.'/utils/setup.php';
+ $iRet = -1;
+ passthru($sSetup.' --create-functions --enable-diff-updates', $iRet);
+ if ($iRet != 0) {
+ fail('Error running setup script');
+ }
+
+ $sDatabaseDate = getDatabaseDate($oDB);
+ if ($sDatabaseDate === false) {
+ fail("Cannot determine date of database.");
+ }
+ $sWindBack = strftime('%Y-%m-%dT%H:%M:%SZ',
+ strtotime($sDatabaseDate) - (3*60*60));
+
+ // get the appropriate state id
+ $aOutput = 0;
+ exec(CONST_Pyosmium_Binary.' -D '.$sWindBack.' --server '.CONST_Replication_Url,
+ $aOutput, $iRet);
+ if ($iRet != 0) {
+ fail('Error running pyosmium tools');
+ }
+
+ pg_query($oDB->connection, 'TRUNCATE import_status');
+ $sSQL = "INSERT INTO import_status (lastimportdate, sequence_id, indexed) VALUES('";
+ $sSQL .= $sDatabaseDate."',".$aOutput[0].", true)";
+ if (!pg_query($oDB->connection, $sSQL)) {
+ fail("Could not enter sequence into database.");
+ }
+
+ echo "Done. Database updates will start at sequence $aOutput[0] ($sWindBack)\n";
+}