Changeset 4750

Show
Ignore:
Timestamp:
08/07/07 21:13:21 (6 years ago)
Author:
p_lindheimer
Message:

make rc1 upgrade directories, add script to remove deprecated or moved files, add ZAPTEL_DELAY

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.3/upgrades/2.3.0rc1/removefiles.php

    r4071 r4750  
    11<? 
    22 
    3 global $asterisk_conf; 
    4 out("Cleaning up leftover callback script that was distributed in core..."); 
    5 outn("callback..."); 
    6 if (file_exists($asterisk_conf['astvarlibdir']."/bin/callback") && !is_link($asterisk_conf['astvarlibdir']."/bin/callback")) { 
    7   unlink($asterisk_conf['astvarlibdir']."/bin/callback"); 
    8   out("Done"); 
    9 } else { 
    10   out("Not Required"); 
     3global $amp_conf; 
     4 
     5$outdated = array( 
     6  $amp_conf['AMPWEBROOT']."/recordings/modules/help.module", 
     7  $amp_conf['AMPWEBROOT']."/admin/bounce_op.sh", 
     8  $amp_conf['AMPWEBROOT']."/admin/logout.php", 
     9  $amp_conf['AMPWEBROOT']."/admin/images/background-grid.png", 
     10  $amp_conf['AMPWEBROOT']."/admin/images/background-triangle.png", 
     11  $amp_conf['AMPWEBROOT']."/admin/common/jquery.js", 
     12  $amp_conf['AMPWEBROOT']."/admin/common/jquery.tabs.js", 
     13  $amp_conf['AMPWEBROOT']."/admin/common/freepbx.css", 
     14  $amp_conf['AMPWEBROOT']."/admin/common/jquery.interface.js", 
     15  $amp_conf['AMPWEBROOT']."/admin/common/jquery.tabs.css", 
     16  $amp_conf['AMPBIN']."/retrieve_queues_conf_from_mysql.pl", 
     17  $amp_conf['AMPBIN']."/retrieve_zap_conf_from_mysql.pl", 
     18  $amp_conf['AMPBIN']."/retrieve_sip_conf_from_mysql.pl", 
     19  $amp_conf['AMPBIN']."/retrieve_iax_conf_from_mysql.pl", 
     20); 
     21 
     22out("Cleaning up deprecated or moved files:"); 
     23 
     24foreach ($outdated as $file) { 
     25  outn("Checking $file.."); 
     26  if (file_exists($file) && !is_link($file)) { 
     27    unlink($file) ? out("Removed") : out("Failed to Remove"); 
     28  } else { 
     29    out("Not Required"); 
     30  } 
    1131} 
    1232 
  • freepbx/branches/2.3/upgrades/2.3.0rc1/tables.php

    r4637 r4750  
    11<?php 
    22 
    3 /* Convert all the core voicemail destinations that were previously controlled 
    4  * by the global setting of busy vs. unavail to the new format that allows a 
    5  * per voicemail box choice. 
    6  */ 
    7 convert_destinations('convert_voicemail_dest'); 
    8  
    9 /* This function takes as input an old style voicemail destination: 
    10  * 
    11  *   ext-local,${VM_PREFIX}222,1 
    12  * 
    13  * and converts it to a new style voicemail destination by looking at 
    14  * the current system default. So if busy, you would get the following: 
    15  * 
    16  *   ext-local,vmb200,1 
    17  */ 
    18 function convert_voicemail_dest($dest) { 
    19   global $db; 
    20  
    21   // Get the current default VM type to make the conversion with 
    22   // 
    23   $sql = "SELECT value FROM globals WHERE variable = 'VM_DDTYPE' "; 
    24   $vm_ddtype = $db->getOne($sql); 
    25   if(DB::IsError($vm_ddtype)) { 
    26     // Should really be there but if not, just set to unavailable. 
    27     // 
    28     $vm_ddtype = 'u'; 
    29   } 
    30  
    31   if (strstr($vm_ddtype,'b') === false) { 
    32     $prefix = 'vmu'; 
    33   } else { 
    34     $prefix = 'vmb'; 
    35   } 
    36   if ( preg_match('/^\s*ext-local,\$\{VM_PREFIX\}(\d+),1/',$dest,$matches) ) { 
    37         // matches[1] => extn 
    38     return "ext-local,$prefix".$matches[1].",1"; 
    39   } else { 
    40     return $dest; 
    41   } 
    42 
    43  
    44 function convert_destinations($convert_dest) { 
    45  
    46   global $db; 
    47  
    48   if (!function_exists($convert_dest)) { 
    49     out("ERROR: no such function $convert_dest"); 
    50     return false; 
    51   } 
    52  
    53   // CORE: 
    54   // 
    55   outn("converting voicemail destinations in core module.."); 
    56   $results = array(); 
    57   $sql = "SELECT cidnum, extension, destination FROM incoming"; 
    58   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    59   if (DB::IsError($results)) { // error - table must not be there 
    60     out("Error - no incoming table"); 
    61   } else { 
    62     foreach ($results as $result) { 
    63       $old_dest  = $result['destination']; 
    64       $extension = $result['extension']; 
    65       $cidnum    = $result['cidnum']; 
    66    
    67       $new_dest = $convert_dest(trim($old_dest)); 
    68       if ($new_dest != $old_dest) { 
    69         $sql = "UPDATE incoming SET destination = '$new_dest' WHERE cidnum = '$cidnum' AND extension = '$extension' AND destination = '$old_dest'"; 
    70         $results = $db->query($sql); 
    71         if(DB::IsError($results)) { 
    72           die($results->getMessage()); 
    73         } 
    74       } 
    75     } 
    76     out("Done"); 
    77   } 
    78    
    79   // ANNOUCEMENT: 
    80   // 
    81   outn("converting voicemail destinations in announcement module.."); 
    82   $results = array(); 
    83   $sql = "SELECT announcement_id, post_dest FROM announcement"; 
    84   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    85   if (DB::IsError($results)) { // error - table must not be there 
    86     out("no announcement table"); 
    87   } else { 
    88     foreach ($results as $result) { 
    89       $old_dest  = $result['post_dest']; 
    90       $announcement_id    = $result['announcement_id']; 
    91    
    92       $new_dest = $convert_dest(trim($old_dest)); 
    93       if ($new_dest != $old_dest) { 
    94         $sql = "UPDATE announcement SET post_dest = '$new_dest' WHERE announcement_id = $announcement_id  AND post_dest = '$old_dest'"; 
    95         $results = $db->query($sql); 
    96         if(DB::IsError($results)) { 
    97           die($results->getMessage()); 
    98         } 
    99       } 
    100     } 
    101     out("Done"); 
    102   } 
    103    
    104   // CALLBACK: 
    105   // 
    106   outn("converting voicemail destinations in callback module.."); 
    107   $results = array(); 
    108   $sql = "SELECT callback_id, destination FROM callback"; 
    109   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    110   if (DB::IsError($results)) { // error - table must not be there 
    111     out("no callback table"); 
    112   } else { 
    113     foreach ($results as $result) { 
    114       $old_dest  = $result['destination']; 
    115       $callback_id    = $result['callback_id']; 
    116    
    117       $new_dest = $convert_dest(trim($old_dest)); 
    118       if ($new_dest != $old_dest) { 
    119         $sql = "UPDATE callback SET destination = '$new_dest' WHERE callback_id = $callback_id  AND destination = '$old_dest'"; 
    120         $results = $db->query($sql); 
    121         if(DB::IsError($results)) { 
    122           die($results->getMessage()); 
    123         } 
    124       } 
    125     } 
    126     out("Done"); 
    127   } 
    128    
    129   // FINDMEFOLLOW: 
    130   // 
    131   outn("converting voicemail destinations in findmefollow module.."); 
    132   $results = array(); 
    133   $sql = "SELECT grpnum, postdest FROM findmefollow"; 
    134   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    135   if (DB::IsError($results)) { // error - table must not be there 
    136     out("no findmefollow table"); 
    137   } else { 
    138     foreach ($results as $result) { 
    139       $old_dest  = $result['postdest']; 
    140       $grpnum    = $result['grpnum']; 
    141    
    142       $new_dest = $convert_dest(trim($old_dest)); 
    143       if ($new_dest != $old_dest) { 
    144         $sql = "UPDATE findmefollow SET postdest = '$new_dest' WHERE grpnum = '$grpnum'  AND postdest = '$old_dest'"; 
    145         $results = $db->query($sql); 
    146         if(DB::IsError($results)) { 
    147           die($results->getMessage()); 
    148         } 
    149       } 
    150     } 
    151     out("Done"); 
    152   } 
    153    
    154   // IVR: 
    155   // 
    156   outn("converting voicemail destinations in miscapp module.."); 
    157   $results = array(); 
    158   $sql = "SELECT ivr_id, selection, dest FROM ivr_dests"; 
    159   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    160   if (DB::IsError($results)) { // error - table must not be there 
    161     out("no ivr_dests table"); 
    162   } else { 
    163     foreach ($results as $result) { 
    164       $old_dest  = $result['dest']; 
    165       $ivr_id    = $result['ivr_id']; 
    166       $selection = $result['selection']; 
    167    
    168       $new_dest = $convert_dest(trim($old_dest)); 
    169       if ($new_dest != $old_dest) { 
    170         $sql = "UPDATE ivr_dests SET dest = '$new_dest' WHERE ivr_id = $ivr_id AND selection = '$selection' AND dest = '$old_dest'"; 
    171         $results = $db->query($sql); 
    172         if(DB::IsError($results)) { 
    173           die($results->getMessage()); 
    174         } 
    175       } 
    176     } 
    177     out("Done"); 
    178   } 
    179    
    180   // MISCAPP: 
    181   // 
    182   outn("converting voicemail destinations in miscapp module.."); 
    183   $results = array(); 
    184   $sql = "SELECT miscapps_id, dest FROM miscapps"; 
    185   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    186   if (DB::IsError($results)) { // error - table must not be there 
    187     out("no miscapp table"); 
    188   } else { 
    189     foreach ($results as $result) { 
    190       $old_dest    = $result['dest']; 
    191       $miscapps_id = $result['miscapps_id']; 
    192    
    193       $new_dest = $convert_dest(trim($old_dest)); 
    194       if ($new_dest != $old_dest) { 
    195         $sql = "UPDATE miscapps SET dest = '$new_dest' WHERE miscapps_id = $miscapps_id  AND dest = '$old_dest'"; 
    196         $results = $db->query($sql); 
    197         if(DB::IsError($results)) { 
    198           die($results->getMessage()); 
    199         } 
    200       } 
    201     } 
    202     out("Done"); 
    203   } 
    204    
    205   // PARKING: 
    206   // 
    207   outn("converting voicemail destinations in queues module.."); 
    208   $results = array(); 
    209   $sql = "SELECT id, keyword, data FROM parkinglot WHERE keyword = 'goto'"; 
    210   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    211   if (DB::IsError($results)) { // error - table must not be there 
    212     out("no parkinglot table"); 
    213   } else { 
    214     foreach ($results as $result) { 
    215       $old_dest  = $result['data']; 
    216       $id        = $result['id']; 
    217       $keyword   = $result['keyword']; 
    218    
    219       $new_dest = $convert_dest(trim($old_dest)); 
    220       if ($new_dest != $old_dest) { 
    221         $sql = "UPDATE parkinglot SET data = '$new_dest' WHERE id = '$id'  AND keyword = '$keyword' AND data = '$old_dest'"; 
    222         $results = $db->query($sql); 
    223         if(DB::IsError($results)) { 
    224           die($results->getMessage()); 
    225         } 
    226       } 
    227     } 
    228     out("Done"); 
    229   } 
    230    
    231   // QUEUES: 
    232   // 
    233   outn("converting voicemail destinations in queues module.."); 
    234   $results = array(); 
    235   $sql = "SELECT args, extension, priority FROM extensions WHERE context = 'ext-queues' AND descr = 'jump'"; 
    236   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    237   if (DB::IsError($results)) { // error - table must not be there 
    238     out("no queues table"); 
    239   } else { 
    240     foreach ($results as $result) { 
    241       $old_dest  = $result['args']; 
    242       $extension = $result['extension']; 
    243       $priority  = $result['priority']; 
    244    
    245       $new_dest = $convert_dest(trim($old_dest)); 
    246       if ($new_dest != $old_dest) { 
    247         $sql = "UPDATE extensions SET args = '$new_dest' WHERE extension = '$extension' AND priority = '$priority' AND context = 'ext-queues' AND descr = 'jump' AND args = '$old_dest'"; 
    248         $results = $db->query($sql); 
    249         if(DB::IsError($results)) { 
    250           die($results->getMessage()); 
    251         } 
    252       } 
    253     } 
    254     out("Done"); 
    255   } 
    256    
    257   // RINGGROUPS: 
    258   // 
    259   outn("converting voicemail destinations in ringgroups module.."); 
    260   $results = array(); 
    261   $sql = "SELECT grpnum, postdest FROM ringgroups"; 
    262   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    263   if (DB::IsError($results)) { // error - table must not be there 
    264     out("no ringgroups table"); 
    265   } else { 
    266     foreach ($results as $result) { 
    267       $old_dest  = $result['postdest']; 
    268       $grpnum    = $result['grpnum']; 
    269    
    270       $new_dest = $convert_dest(trim($old_dest)); 
    271       if ($new_dest != $old_dest) { 
    272         $sql = "UPDATE ringgroups SET postdest = '$new_dest' WHERE grpnum = '$grpnum'  AND postdest = '$old_dest'"; 
    273         $results = $db->query($sql); 
    274         if(DB::IsError($results)) { 
    275           die($results->getMessage()); 
    276         } 
    277       } 
    278     } 
    279     out("Done"); 
    280   } 
    281    
    282   // TIMECONDITIONS: 
    283   // 
    284   outn("converting voicemail destinations in timeconditions module.."); 
    285   $results = array(); 
    286   $sql = "SELECT timeconditions_id, truegoto, falsegoto FROM timeconditions"; 
    287   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    288   if (DB::IsError($results)) { // error - table must not be there 
    289     out("no timeconditions table"); 
    290   } else { 
    291     foreach ($results as $result) { 
    292       $old_false_dest    = $result['falsegoto']; 
    293       $old_true_dest     = $result['truegoto']; 
    294       $timeconditions_id = $result['timeconditions_id']; 
    295    
    296       $new_false_dest = $convert_dest(trim($old_false_dest)); 
    297       $new_true_dest  = $convert_dest(trim($old_true_dest)); 
    298       if (($new_true_dest != $old_true_dest) || ($new_false_dest != $old_false_dest)) { 
    299         $sql = "UPDATE timeconditions SET truegoto = '$new_true_dest', falsegoto = '$new_false_dest' WHERE timeconditions_id = $timeconditions_id  AND truegoto = '$old_true_dest' AND falsegoto ='$old_false_dest'"; 
    300         $results = $db->query($sql); 
    301         if(DB::IsError($results)) { 
    302           die($results->getMessage()); 
    303         } 
    304       } 
    305     } 
    306     out("Done"); 
    307   } 
    308    
    309   // DAYNIGHT: 
    310   // 
    311   outn("converting voicemail destinations in daynight module.."); 
    312   $results = array(); 
    313   $sql = "SELECT ext, dmode, dest FROM daynight WHERE dmode in ('day', 'night')"; 
    314   $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    315   if (DB::IsError($results)) { // error - table must not be there 
    316     out("no daynight table"); 
    317   } else { 
    318     foreach ($results as $result) { 
    319       $old_dest  = $result['dest']; 
    320       $ext    = $result['ext']; 
    321       $dmode = $result['dmode']; 
    322    
    323       $new_dest = $convert_dest(trim($old_dest)); 
    324       if ($new_dest != $old_dest) { 
    325         $sql = "UPDATE daynight SET dest = '$new_dest' WHERE ext = '$ext' AND dmode = '$dmode' AND dest = '$old_dest'"; 
    326         $results = $db->query($sql); 
    327         if(DB::IsError($results)) { 
    328           die($results->getMessage()); 
    329         } 
    330       } 
    331     } 
    332     out("Done"); 
    333   } 
    334 
    335  
    336  
    337 /* Create notifications table used by framework to put warnings, errors, etc. on the dashboard 
    338  */ 
    339 outn("creating notifications table.."); 
    340 $sql = " 
    341   CREATE TABLE IF NOT EXISTS notifications ( 
    342     module        varchar(24) NOT NULL default '', 
    343     id            varchar(24) NOT NULL default '', 
    344     `level`       int(11) NOT NULL default '0', 
    345     display_text  varchar(255) NOT NULL default '', 
    346     extended_text blob NOT NULL, 
    347     link          varchar(255) NOT NULL default '', 
    348     `reset`       tinyint(4) NOT NULL default '0', 
    349     candelete     tinyint(4) NOT NULL default '0', 
    350     `timestamp`   int(11) NOT NULL default '0', 
    351     PRIMARY KEY  (module,id) 
    352   ) 
    353   "; 
    354 $check = $db->query($sql); 
    355 if(DB::IsError($check)) { 
    356   out("ERROR: Can not create notifications table"); 
    357 
    358 out("Done"); 
    359  
    360 outn("Upgrading notifications table to add candelete.."); 
    361  
    362 $sql = "SELECT candelete FROM notifications"; 
    363 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    364 if (!DB::IsError($confs)) { // no error... Already done 
    365   out("Not Required"); 
     3// This will be used to put an optional wait in from-zaptel to handle lines with 
     4// badly behaved CID 
     5// 
     6outn("Checking for Global var ZAPTEL_DELAY.."); 
     7$nrows = $db->getOne("SELECT count(*) from globals where variable='ZAPTEL_DELAY'"); 
     8if (!$nrows) { 
     9  $db->query("insert into globals values ('ZAPTEL_DELAY', '0')"); 
     10  out("Created"); 
    36611} else { 
    367   $sql = "ALTER TABLE notifications ADD candelete TINYINT ( 4 ) NOT NULL DEFAULT '0'"; 
    368   $results = $db->query($sql); 
    369   if(DB::IsError($results)) { 
    370           die($results->getMessage()); 
    371   } 
    372   out("Done"); 
    373 
    374  
    375 outn("creating cronmanager table.."); 
    376 $sql = " CREATE TABLE IF NOT EXISTS `cronmanager` ( 
    377           `module` varchar(24) NOT NULL default '', 
    378           `id` varchar(24) NOT NULL default '', 
    379           `time` varchar(5) default NULL, 
    380           `freq` int(11) NOT NULL default '0', 
    381           `lasttime` int(11) NOT NULL default '0', 
    382           `command` varchar(255) NOT NULL default '', 
    383           PRIMARY KEY  (`module`,`id`) 
    384         ) 
    385         "; 
    386 $check = $db->query($sql); 
    387 if(DB::IsError($check)) { 
    388   out("ERROR: Can not create cronmanager table"); 
    389 
    390 out("Done"); 
    391  
    392 outn("enabling online update checking.."); 
    393 $sql = "SELECT * FROM cronmanager WHERE module = 'module_admin' AND id = 'UPDATES'"; 
    394 $result = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    395 if (DB::IsError($result)) { // error - table must not be there 
    396   out("can't update cronmanager table"); 
    397 } else { 
    398   if (count($result)) { 
    399     out("already enabled"); 
    400   } else { 
    401     $freq = 24; 
    402     $night_time = array(19,20,21,22,23,0,1,2,3,4,5); 
    403     $run_time = $night_time[rand(0,10)]; 
    404     $command = $amp_conf['AMPBIN']."/module_admin listonline"; 
    405    
    406     $sql = "INSERT INTO cronmanager  
    407             (module, id, time, freq, lasttime, command) 
    408             VALUES 
    409             ('module_admin', 'UPDATES', '$run_time', $freq, 0, '$command') 
    410           "; 
    411     $check = $db->query($sql); 
    412     if(DB::IsError($check)) { 
    413       out("ERROR: can not insert update information in cronmanager"); 
    414     } else { 
    415       out("Done"); 
    416     } 
    417   } 
     12  out("Already exists!"); 
    41813} 
    41914