Changeset 4273

Show
Ignore:
Timestamp:
06/30/07 12:12:43 (1 year ago)
Author:
p_lindheimer
Message:

#2020: change from symlink to copy of agi-bin from modules to address error that occurs on some systems. If you do not want to copy over a modified version, you must change it to remove write access

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.3/amp_conf/bin/retrieve_conf

    r4148 r4273  
    196196// **** Create symlinks array 
    197197$symlink_dirs = array(); 
    198 $symlink_dirs['agi-bin'] = (isset($amp_conf['ASTAGIDIR']) ? $amp_conf['ASTAGIDIR'] : '/var/lib/asterisk/agi-bin'); 
    199198$symlink_dirs['sounds'] = (isset($amp_conf['ASTVARLIBDIR']) ? $amp_conf['ASTVARLIBDIR'] : '/var/lib/asterisk').'/sounds'; 
    200199$symlink_dirs['bin'] = (isset($amp_conf['AMPBIN']) ? $amp_conf['AMPBIN'] : '/var/lib/asterisk/bin'); 
    201200$symlink_dirs['etc'] = (isset($amp_conf['ASTETCDIR']) ? $amp_conf['ASTETCDIR'] : '/etc/asterisk'); 
    202201$symlink_dirs['images'] = (isset($amp_conf['AMPWEBROOT']) ? addslash($amp_conf['AMPWEBROOT'])."admin/images" : '/var/www/html/admin/images'); 
     202 
     203$cp_dirs = array(); 
     204$cp_dirs['agi-bin'] = (isset($amp_conf['ASTAGIDIR']) ? $amp_conf['ASTAGIDIR'] : '/var/lib/asterisk/agi-bin'); 
    203205 
    204206switch ($db_engine) 
     
    307309                        // create symlinks for files in appropriate sub directories 
    308310                        symlink_subdirs( $amp_conf['AMPWEBROOT'].'/admin/modules/'.$key ); 
     311                        cp_subdirs( $amp_conf['AMPWEBROOT'].'/admin/modules/'.$key ); 
    309312                } 
    310313        } 
     
    430433} 
    431434 
     435function cp_subdirs($moduledir) { 
     436        global $cp_dirs; 
     437 
     438        foreach ($cp_dirs as $subdir => $targetdir) { 
     439                $dir = addslash($moduledir).$subdir; 
     440                if (is_dir($dir)) { 
     441                        $d = opendir($dir); 
     442                        while ($file = readdir($d)) { 
     443                                if ($file[0] != '.') { 
     444                                        $sourcefile = addslash($dir).$file; 
     445                                        $targetfile = addslash($targetdir).$file; 
     446 
     447                                        if (file_exists($targetfile)) { 
     448                                                set_error_handler("report_errors"); 
     449                                                if (is_link($targetfile)) { 
     450                                                        if (unlink($targetfile)) { 
     451                                                                freepbx_log('retrieve-conf', 'devel-debug', "$targetfile was symbolic link, unlink successful"); 
     452                                                        } else { 
     453                                                                restore_error_handler(); 
     454                                                                freepbx_log('retrieve-conf', 'error', "$targetfile is a symblolic link, failed to unlink!"); 
     455                                                                break; 
     456                                                        } 
     457                                                } 
     458                                        } 
     459                                        // OK, now either the file is a regular file or isn't there, so proceed 
     460                                        // 
     461                                        set_error_handler("report_errors"); 
     462                                        if (copy($sourcefile,$targetfile)) { 
     463                                                freepbx_log('retrieve-conf', 'devel-debug', "$targetfile successfully copied"); 
     464                                        } else { 
     465                                                freepbx_log('retrieve-conf', 'error', "$targetfile failed to copy from module directory"); 
     466                                        } 
     467                                        restore_error_handler(); 
     468                                } 
     469                        } 
     470                        closedir($d); 
     471                } 
     472        } 
     473} 
     474 
     475function report_errors($errno, $errstr, $errfile, $errline) { 
     476        freepbx_log('retrieve-conf', 'error', "php reported: '".mysql_real_escape_string($errstr)."' after copy or unlink attempt!"); 
     477} 
     478 
     479 
    432480 
    433481// run legacy retrieve scripts 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads