31 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit', -1);
32 error_reporting(E_ALL);
34 if (php_sapi_name() !=
'cli') {
35 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
38 if (count($argv) < 1) {
39 echo
"USAGE : php scripts/upgrade_of_funnelback_binary_to_9_1.php <SYSTEM_ROOT>\n";
43 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
44 if (empty($SYSTEM_ROOT)) {
45 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
49 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
50 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
54 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
55 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
58 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
59 echo
"ERROR: Failed logging in as root user\n";
63 $fbm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
64 $collections = $fbm->getCollections();
66 foreach($collections as $index => $collection ) {
67 $file_paths = Array();
69 printCollection($index, $collection[
'name']);
70 $data_path = $fbm->getCollectionDataPath($index).
'/conf/';
71 $file_paths[
'contextual_navigation.cfg'] =
'fluster.cfg';
72 $file_paths[
'query_expansion.cfg'] =
'synonyms.cfg';
73 $file_paths[
'best_bets.cfg'] =
'featured_pages.cfg';
75 foreach ($file_paths as $new_path => $file_path) {
76 if(file_exists($data_path.$file_path)) {
77 if(!copy($data_path.$file_path, $data_path.$new_path)) {
78 bam($data_path.$file_path);
85 printUpdateStatus(
'OK');
87 printUpdateStatus(
'FAILED');
104 function printCollection($id, $name)
106 $str =
'[ #'.$id.
' ]'.$name;
107 if (strlen($str) > 66) {
108 $str = substr($str, 0, 66).
'...';
110 printf (
'%s%'.(70 - strlen($str)).
's', $str,
'');
123 function printUpdateStatus($status)
125 echo
"[ $status ]\n";