Changeset 13208

Show
Ignore:
Timestamp:
01/17/12 15:22:36 (1 year ago)
Author:
p_lindheimer
Message:

adds rc1 migraton library

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/upgrades/2.10.0rc1/migration.php

    r13205 r13208  
    88$freepbx_conf =& freepbx_conf::create(); 
    99 
    10 //move freepbx debug log 
    11 if ($freepbx_conf->conf_setting_exists('FPBXDBUGFILE')) { 
    12   $freepbx_conf->set_conf_values(array('FPBXDBUGFILE' => $amp_conf['ASTLOGDIR'] . '/freepbx_dbug'), true); 
     10// add second repo 
     11if ($freepbx_conf->conf_setting_exists('MODULE_REPO') && $amp_conf['MODULE_REPO'] == 'http://mirror.freepbx.org') { 
     12  $freepbx_conf->set_conf_values(array('MODULE_REPO' => 'http://mirror1.freepbx.org,http://mirror2.freepbx.org'), true); 
    1313} 
    1414 
    15 $rm_command = function_exists('fpbx_which') ? fpbx_which('rm') : 'rm'; 
    16  
    17 $cdr_dir =  $amp_conf['AMPWEBROOT'] . '/admin/cdr'; 
    18 outn("Trying to remove dir $cdr_dir.."); 
    19 if (is_dir($cdr_dir) && !is_link($cdr_dir)) { 
    20   exec($rm_command . ' -rf ' . $cdr_dir, $out, $ret); 
    21   if ($ret) { 
    22     out("could not remove"); 
    23   } else { 
    24     out("ok"); 
    25   } 
    26 } else { 
    27   out("Not Required"); 
    28 } 
    29  
    30 // Need to migrate the CDR table adding the recordingfile and did field. We get the creds from cdr_mysql.conf 
    31 // since $amp_conf is not really authoritative. 
    32 // 
    33 $db_creds = parse_ini_file($amp_conf['ASTETCDIR'] . '/cdr_mysql.conf'); 
    34 if ($db_creds === false) { 
    35   out(_("Error parsing cdr_mysql.conf no migration done")); 
    36 } else { 
    37   $db_creds['hostname'] = !empty($db_creds['hostname']) ? $db_creds['hostname'] : 'localhost'; 
    38   $datasource = 'mysql://' 
    39     . $db_creds['user'] 
    40     . ':' 
    41     . $db_creds['password'] 
    42     . '@' 
    43     . $db_creds['hostname'] 
    44     . '/' 
    45     . $db_creds['dbname']; 
    46   $db_cdr = DB::connect($datasource); // attempt connection 
    47   if (DB::IsError($db_cdr)) {  
    48     out(_("ERROR connectng to CDR DB to migrate, not done!")); 
    49     freepbx_log(FPBX_LOG_ERROR,"failed to open CDR DB to add recordingfile and did fields"); 
    50   } else { 
    51     $sql = "SELECT recordingfile FROM cdr"; 
    52     $confs = $db_cdr->getRow($sql, DB_FETCHMODE_ASSOC); 
    53     outn(_("checking if recordingfile file field needed in cdr..")); 
    54     if (DB::IsError($confs)) { // no error... Already done 
    55       $sql = "ALTER TABLE cdr ADD recordingfile VARCHAR ( 255 ) NOT NULL default ''"; 
    56       $results = $db_cdr->query($sql); 
    57       if(DB::IsError($results)) { 
    58         out(_("failed")); 
    59         freepbx_log(FPBX_LOG_ERROR,"failed to add recordingfile field to cdr table during migration"); 
    60       } 
    61       out(_("added")); 
    62     } else { 
    63       out(_("already there")); 
    64     } 
    65  
    66     $sql = "SELECT did FROM cdr"; 
    67     $confs = $db_cdr->getRow($sql, DB_FETCHMODE_ASSOC); 
    68     outn(_("checking if did file field needed in cdr..")); 
    69     if (DB::IsError($confs)) { // no error... Already done 
    70       $sql = "ALTER TABLE cdr ADD did VARCHAR ( 50 ) NOT NULL default ''"; 
    71       $results = $db_cdr->query($sql); 
    72       if(DB::IsError($results)) { 
    73         out(_("failed")); 
    74         freepbx_log(FPBX_LOG_ERROR,"failed to add did field to cdr table during migration"); 
    75     } 
    76       out(_("added")); 
    77     } else { 
    78       out(_("already there")); 
    79     } 
    80   } 
    81 } 
    82 ?>