forked from FreePBX/framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
apply_conf.sh
executable file
·89 lines (77 loc) · 2.38 KB
/
apply_conf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
if [ -z "$FREEPBX_CONF" ]; then
if [ -e "/etc/freepbx.conf" ]; then
FREEPBX_CONF="/etc/freepbx.conf"
elif [ -e "/etc/asterisk/freepbx.conf" ]; then
FREEPBX_CONF="/etc/asterisk/freepbx.conf"
else
FREEPBX_CONF="/etc/freepbx.conf"
fi
fi
if [ "$1" == "-h" ]
then
echo "Usage: "
echo " "$0" [config]"
echo
echo "If config file is not specified, FreePBX must be installed and"
echo "the script will bootstrap the information"
echo
exit
fi
if [ -n "$1" ]
then
AMPCONFIG=$1
if [ ! -e $AMPCONFIG ]
then
echo "Cannot find $AMPCONFIG"
exit
fi
# include config file
echo "Reading $AMPCONFIG"
else
echo "Bootstrapping Configuration Settings"
fi
# get settings from db/config file
if [ -n "$AMPCONFIG" ]; then # If told to parse out of file, go for it
. $AMPCONFIG
elif [[ -e $FREEPBX_CONF ]]; then
# get the path of this file to call the gen_amp_conf.php script which will
# generate all the amp_conf variables that can be exported
#
progdir=`dirname $0`
sv_pwd=$PWD
cd $progdir
gen_path=$PWD
cd $sv_pwd
`$gen_path/amp_conf/bin/gen_amp_conf.php`
else
echo;
echo "FreePBX config file not found!";
echo "specificy amportal.conf as argument if FreePBX is not yet installed";
exit;
fi
echo "Updating configuration..."
if [ -e "$ASTETCDIR/cdr_mysql.conf" ]; then
echo "$ASTETCDIR/cdr_mysql.conf user: [$AMPDBUSER] password: [$AMPDBPASS] hostname: [$AMPDBHOST]"
sed -i.bak "s/user\s*=.*$/user = $AMPDBUSER/" $ASTETCDIR/cdr_mysql.conf
sed -i.bak "s/password\s*=.*$/password = $AMPDBPASS/" $ASTETCDIR/cdr_mysql.conf
sed -i.bak "s/hostname\s*=.*$/hostname = $AMPDBHOST/" $ASTETCDIR/cdr_mysql.conf
fi
echo "$ASTETCDIR/manager.conf user: [$AMPMGRUSER] secret: [$AMPMGRPASS]"
sed -i.bak "s/secret\s*=.*$/secret = $AMPMGRPASS/" $ASTETCDIR/manager.conf
sed -i.bak "s/\s*\[general\].*$/TEMPCONTEXT/;s/\[.*\]/\[$AMPMGRUSER\]/;s/^TEMPCONTEXT$/\[general\]/" $ASTETCDIR/manager.conf
if [ -e "$ASTETCDIR/vm_email.conf" ]; then
echo "$ASTETCDIR/vm_email.inc"
if [ "xx$AMPWEBADDRESS" = "xx" ]; then
echo "You might need to modify /etc/asterisk/vm_email.inc manually"
else
echo "used web address: [$AMPWEBADDRESS] for path"
sed -i.bak "s!http://.*/recordings!http://$AMPWEBADDRESS/recordings!" $ASTETCDIR/vm_email.inc
fi
fi
if [ -x $AMPSBIN/amportal ]; then
echo "Adjusting File Permissions.."
$AMPSBIN/amportal chown
fi
asterisk -rx'manager reload'
echo "Done"