Changeset 48

Show
Ignore:
Timestamp:
06/28/07 21:18:27 (1 year ago)
Author:
root
Message:

Added optional amportal.conf parsing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/op_server.cfg

    r46 r48  
    11[general] 
     2; If you want to use freepbx/trixbox conf file, set this to 1 
     3use_amportal_conf=0; 
     4 
    25; host or ip address of asterisk 
    36manager_host=192.168.0.1 
  • trunk/op_server.pl

    r47 r48  
    399399} 
    400400 
     401sub parse_amportal_config { 
     402    my $filename = shift; 
     403    my %ampconf; 
     404 
     405    open( AMPCONF, $filename ) || die "Cannot open $filename"; 
     406 
     407    while (<AMPCONF>) { 
     408        if ( $_ =~ /^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/ ) { 
     409            $ampconf{$1} = $2; 
     410        } 
     411    } 
     412 
     413    close(AMPCONF); 
     414    return %ampconf; 
     415} 
     416 
    401417sub read_server_config() { 
    402418    my $context = ""; 
     
    467483        } 
    468484        close(CONFIG); 
     485    } 
     486 
     487    if ( defined( $config->{GENERAL}{use_amportal_conf} ) ) { 
     488        if ( $config->{GENERAL}{use_amportal_conf} == 1 ) { 
     489            my $freepbx_config = "/etc/amportal.conf"; 
     490            my %ampconf; 
     491 
     492            if ( -e $freepbx_config ) { 
     493                %ampconf                              = parse_amportal_config($freepbx_config); 
     494                $config->{"GENERAL"}{"web_hostname"}  = $ampconf{"AMPWEBADDRESS"}; 
     495                $config->{"GENERAL"}{"security_code"} = $ampconf{"FOPPASSWORD"}; 
     496                $config->{"GENERAL"}{"flash_dir"}     = $ampconf{"FOPWEBROOT"}; 
     497                $manager_user[0]                      = $ampconf{"AMPMGRUSER"}; 
     498                $manager_secret[0]                    = $ampconf{"AMPMGRPASS"}; 
     499            } 
     500        } 
    469501    } 
    470502 
     
    522554 
    523555    $clid_format = $config->{GENERAL}{clid_format}; 
    524  
     556    if ( !defined($flash_dir) ) { $flash_dir = '/var/www/html' } 
    525557    $flash_file = $flash_dir . "/variables.txt"; 
    526558    push @all_flash_files, $flash_file;