root/freepbx/branches/2.10/apply_conf.sh

Revision 13119, 2.3 kB (checked in by mbrevda, 1 year ago)

upstream updates

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/bash
2
3 if [ -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
11 fi
12
13 if [ "$1" == "-h" ]
14 then
15   echo "Usage: "
16   echo "   "$0" [config]"
17   echo
18   echo "If config file is not specified, FreePBX must be installed and"
19   echo "the script will bootstrap the information"
20   echo
21   exit
22 fi
23
24 if [ -n "$1" ]
25 then
26   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"
34 else
35   echo "Bootstrapping Configuration Settings"
36 fi
37
38 # get settings from db/config file
39 if [ -n "$AMPCONFIG" ]; then # If told to parse out of file, go for it
40   . $AMPCONFIG
41 elif [[ -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`
52 else
53   echo;
54   echo "FreePBX config file not found!";
55   echo "specificy amportal.conf as argument if FreePBX is not yet installed";
56   exit;
57 fi
58
59 echo "Updating configuration..."
60
61 echo "$ASTETCDIR/cdr_mysql.conf user: [$AMPDBUSER] password: [$AMPDBPASS] hostname: [$AMPDBHOST]"
62 sed -i.bak "s/user\s*=.*$/user = $AMPDBUSER/" $ASTETCDIR/cdr_mysql.conf
63 sed -i.bak "s/password\s*=.*$/password = $AMPDBPASS/" $ASTETCDIR/cdr_mysql.conf
64 sed -i.bak "s/hostname\s*=.*$/hostname = $AMPDBHOST/" $ASTETCDIR/cdr_mysql.conf
65
66 echo "$ASTETCDIR/manager.conf user: [$AMPMGRUSER] secret: [$AMPMGRPASS]"
67 sed -i.bak "s/secret\s*=.*$/secret = $AMPMGRPASS/" $ASTETCDIR/manager.conf
68 sed -i.bak "s/\s*\[general\].*$/TEMPCONTEXT/;s/\[.*\]/\[$AMPMGRUSER\]/;s/^TEMPCONTEXT$/\[general\]/" $ASTETCDIR/manager.conf
69
70 echo "$ASTETCDIR/vm_email.inc"
71 if [ "xx$AMPWEBADDRESS" = "xx" ]; then
72   echo "You might need to modify /etc/asterisk/vm_email.inc manually"
73 else
74   echo "used web address: [$AMPWEBADDRESS] for path"
75   sed -i.bak "s!http://.*/recordings!http://$AMPWEBADDRESS/recordings!" $ASTETCDIR/vm_email.inc
76 fi
77
78
79 if [ -x $AMPSBIN/amportal ]; then
80   echo "Adjusting File Permissions.."
81   $AMPSBIN/amportal chown
82 fi
83
84 asterisk -rx'manager reload'
85 echo "Done"
Note: See TracBrowser for help on using the browser.