Changeset 2700

Show
Ignore:
Timestamp:
10/15/06 11:03:42 (2 years ago)
Author:
gregmac
Message:

install_amp uses asterisk -V to determine version;
Fixed bug and implemented changes described in #1179

Files:

Legend:

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

    r2684 r2700  
    269269} 
    270270 
    271 // setting engine and version 
    272 $engine = "asterisk"; 
    273 //Need a way to know exact asterisk path 
    274 list ( , $version) = explode(' ',  exec("/usr/sbin/asterisk -V"), 2); 
     271 
     272// Write out engine information 
     273 
     274switch ($amp_conf['AMPENGINE']) { 
     275        case 'asterisk': 
     276        default: 
     277                //  ***  Write to ASTETCDIR/version 
     278                outn('Writing '.$amp_conf['ASTETCDIR'].'/version..'); 
     279                $tmpoutput = ''; 
     280                $tmpout = exec("asterisk -V", $tmpoutput, $exitcode); 
     281                if ($exitcode != 0) { 
     282                        fatal("Error executing asterisk: be sure Asterisk is installed and in the path"); 
     283                } 
     284                if (!$fd = fopen($amp_conf['ASTETCDIR'].'/version','w')) { 
     285                        fatal('Cannot open '.$amp_conf['ASTETCDIR'].'/version for writing'); 
     286                } 
     287                fwrite($fd, $tmpout); 
     288                fclose($fd); 
     289                // change to read-only 
     290                chmod($amp_conf['ASTETCDIR'].'/version',0444); 
     291                out('OK'); 
     292        break; 
     293
     294 
     295$engineinfo = engine_getinfo(); 
     296// was setting these variables before, assume we still need them 
     297$engine = $engineinfo['engine']; 
     298$version = $engineinfo['version']; 
     299 
    275300 
    276301// run all of the *_get_config and _hookGet_config functions, which will populate the appropriate objects 
  • freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php

    r2695 r2700  
    270270        switch ($amp_conf['AMPENGINE']) { 
    271271                case 'asterisk': 
    272                         $verinfo = exec('asterisk -V'); 
     272                        $verinfo = file_get_contents($amp_conf['ASTETCDIR'].'/version'); 
    273273                        if (preg_match('/^Asterisk (\d+(\.\d+)*)(-?(.*))$/', $verinfo, $matches)) { 
    274274                                return array('engine'=>'asterisk', 'version' => $matches[1], 'additional' => $matches[4]); 
  • freepbx/trunk/install_amp

    r2642 r2700  
    11#!/usr/bin/php -q 
    22<?php 
     3 
     4define("AMP_CONF", "/etc/amportal.conf"); 
     5 
     6define("ASTERISK_CONF", "/etc/asterisk/asterisk.conf"); 
     7 
     8define("UPGRADE_DIR", dirname(__FILE__)."/upgrades"); 
     9 
    310 
    411// define versions. latest version must be last 
     
    3542        ); 
    3643 
    37 define("AMP_CONF", "/etc/amportal.conf"); 
    38  
    39 define("ASTERISK_CONF", "/etc/asterisk/asterisk.conf"); 
    40  
    41 define("UPGRADE_DIR", dirname(__FILE__)."/upgrades"); 
     44define("REQ_ASTERISK_VERSION", "1.2"); 
    4245 
    4346/********************************************************************************************************************/ 
     
    782785write_amportal_conf(AMP_CONF, $amp_conf); 
    783786 
    784 // **** Check for func_callerid.so - this is only in asterisk 1.2 
    785  
    786 outn("Checking for Asterisk 1.2.."); 
    787 if (!file_exists($amp_conf["ASTMODDIR"]."/func_callerid.so")) { 
    788         fatal("Asterisk 1.2 is required for this version of freePBX"); 
    789 
    790 out("OK"); 
     787 
     788// **** Write asterisk version to ASTETCDIR/version 
     789 
     790$tmpoutput = ''; 
     791$tmpout = exec("asterisk -V", $tmpoutput, $exitcode); 
     792if ($exitcode != 0) { 
     793        fatal("Error executing asterisk: be sure Asterisk is installed and in the path"); 
     794
     795if (!$fd = fopen($amp_conf['ASTETCDIR'].'/version','w')) { 
     796        fatal('Cannot open '.$amp_conf['ASTETCDIR'].'/version for writing'); 
     797
     798fwrite($fd, $tmpout); 
     799fclose($fd); 
     800// change to read-only 
     801chmod($amp_conf['ASTETCDIR'].'/version',0444); 
     802 
     803 
     804// normally this would be the contents of ASTETCDIR/version, but this is for simplicity, as we just read it above 
     805$verinfo = $tmpout; 
     806 
     807// **** Check asterisk verison 
     808 
     809outn("Checking for Asterisk ".REQ_ASTERISK_VERSION.".."); 
     810if (preg_match('/^Asterisk (\d+(\.\d+)*)(-?(.*))$/', $verinfo, $matches)) { 
     811        if (version_compare($matches[1], REQ_ASTERISK_VERSION) < 0) { 
     812                fatal("Asterisk 1.2 is required for this version of freePBX"); 
     813        } 
     814        out("OK"); 
     815} else { 
     816        fatal("Could not determine asterisk version (got: \"".$verinfo."\" please report this)"); 
     817
    791818 
    792819// **** Make sure selinux isn't enabled 
    793820 
    794821outn("Checking for selinux.."); 
     822$tmpoutput = ''; 
    795823$tmpout = exec("selinuxenabled 2>&1", $tmpoutput, $sereturn); 
    796824if ($sereturn == 0) { 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads