Show
Ignore:
Timestamp:
01/17/11 20:46:44 (1 year ago)
Author:
p_lindheimer
Message:

update to use conf file if specified and otherwise bootstrap

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/apply_conf.sh

    r5122 r11006  
    11#!/bin/bash 
     2 
     3if [ -z "$FREEPBX_CONF" ]; then 
     4  if [ -e "/etc/freepbx.conf" ]; then 
     5    FREEPBX_CONF="/etc/freepbx.conf" 
     6  elif [ -e "/etc/asterisk/freepbx.conf" ]; then 
     7    FREEPBX_CONF="/etc/asterisk/freepbx.conf" 
     8  else 
     9    FREEPBX_CONF="/etc/freepbx.conf" 
     10  fi 
     11fi 
    212 
    313if [ "$1" == "-h" ] 
     
    616  echo "   "$0" [config]" 
    717  echo 
    8   echo "If config file is not specified, default is /etc/amportal.conf" 
     18  echo "If config file is not specified, FreePBX must be installed and" 
     19  echo "the script will bootstrap the information" 
    920  echo 
    1021  exit 
     
    1425then 
    1526  AMPCONFIG=$1 
     27  if [ ! -e $AMPCONFIG ] 
     28  then 
     29    echo "Cannot find $AMPCONFIG" 
     30    exit 
     31  fi 
     32  # include config file 
     33  echo "Reading $AMPCONFIG" 
    1634else 
    17   AMPCONFIG=/etc/amportal.conf 
     35  echo "Bootstrapping Configuration Settings" 
    1836fi 
    1937 
    20 if [ ! -e $AMPCONFIG ] 
    21 then 
    22   echo "Cannot find $AMPCONFIG" 
    23   exit 
     38# get settings from db/config file 
     39if [ -n "$AMPCONFIG" ]; then # If told to parse out of file, go for it 
     40  . $AMPCONFIG 
     41elif [[ -e $FREEPBX_CONF ]]; then 
     42 
     43  # get the path of this file to call the gen_amp_conf.php script which will 
     44  # generate all the amp_conf variables that can be exported 
     45  # 
     46  progdir=`dirname $0` 
     47  sv_pwd=$PWD 
     48        cd $progdir 
     49        gen_path=$PWD 
     50        cd $sv_pwd 
     51  `$gen_path/amp_conf/bin/gen_amp_conf.php` 
     52else  
     53  echo; 
     54  echo "FreePBX config file not found!"; 
     55  echo "specificy amportal.conf as argument if FreePBX is not yet installed"; 
     56  exit; 
    2457fi 
    25  
    26 # include config file 
    27 echo "Reading $AMPCONFIG" 
    28 source $AMPCONFIG 
    2958 
    3059echo "Updating configuration..." 
     
    4776 
    4877 
    49 if [ -x /usr/sbin/amportal ]; then  
     78if [ -x $AMPSBIN/amportal ]; then  
    5079  echo "Adjusting File Permissions.." 
    51   /usr/sbin/amportal chown 
     80  $AMPSBIN/amportal chown 
    5281fi 
    5382