Commit 5452d58f authored by Yalu Zhang's avatar Yalu Zhang
Browse files

asterisk: Fix a bug in config_asterisk.sh that wrongly handles IncomingMap

If there are more than one incoming_map section which for the same line (SIP client),
only the first incoming_map section takes effect. This is a bug.

Now more incoming_map sections can be configured to the same line.
parent da26f984
......@@ -819,28 +819,25 @@ configure_voicemail_incoming()
fi
fi
}
configure_extensions_provider() {
local enabled
local displayname
local user
local custom_outgoing
local incoming_lines
local direct_dial
local congestiontone
local internal_service
local mailbox
local minimumnumberofdigits
local prefixenable
local prefixrange
local prefixmaxdigits
local maxnumdigits
local counter
local prefixnumber
local prefixfound
local max_count_prefix
prefixfound=0
counter=1
local minimumnumberofdigits
local prefixenable
local prefixrange
local prefixmaxdigits
local maxnumdigits
local counter=1
local prefixnumber
local prefixfound=0
local max_count_prefix
#setting total number of prefix entries possible
max_count_prefix=50
......@@ -976,7 +973,9 @@ configure_extensions_provider() {
echo "exten => $user,n,GotoIf($[\"\${DIALSTATUS}\"=\"NOANSWER\"]?noanswer:endcall)" >> $tmp
echo "exten => $user,n(noanswer),GoSub(sub-callhandler-noanswer,s,1(\${CHANNEL(endpoint)}))" >> $tmp
#configure incomingmap details are present to set line
line_list=
config_foreach configure_incomingmap incoming_map $1
sed -i "s/|LINENO|/$(escape_sed_substitution $line_list)/" $tmp
#default setting when incoming map is not configured
sed -i "s/|TIMEOUT|/20/" $tmp
......@@ -1526,58 +1525,67 @@ configure_outgoingmap()
fi
fi
fi
}
configure_incomingmap_extension()
{
local extensions_list
local lines_list
local extension
config_get extensions_list $1 extensions
if [ "${extensions_list}" = "" ] ; then
for item in $(db get hw.board.VoicePortOrder); do
item_len=${#item}
value=${item:$((item_len-1))}
lineslist=${lineslist}"TELCHAN\/${value}&&"
local group=$1
local extensions_list
local extension_num
config_get extensions_list $group extensions
if [ -z "$extensions_list" ] ; then
# get all extensions, e.g. hw.board.VoicePortOrder=brcm0 brcm1 brcm2 brcm3
for item in $(db get hw.board.VoicePortOrder); do
extension_num="${item: -1}"
if [ -z "$line_list" ]; then
line_list="TELCHAN\/$extension_num"
else
line_list="$line_list""&&TELCHAN\/$extension_num"
fi
done
sed -i "s/|LINENO|/$(escape_sed_substitution $lineslist)/" $tmp
fi
for extension in ${extensions_list//,/ }
do
local extensionval="${extension: -1}"
lines_list=${lines_list}"TELCHAN\/${extensionval}&&"
done
#Replace the line information in the extensions_incoming
sed -i "s/|LINENO|/$(escape_sed_substitution $lines_list)/" $tmp
else
for extension in ${extensions_list//,/ }; do
extension_num="${extension: -1}"
if [ -z "$line_list" ]; then
line_list="TELCHAN\/$extension_num"
else
line_list="$line_list""&&TELCHAN\/$extension_num"
fi
done
fi
}
configure_incomingmap()
{
local incomingmapname
local extension
local incomingmapname=$1
local provide_target=$2
local group
local line
local enable
local provider
incomingmapname=$1
config_get line $incomingmapname line #line0 and line1
config_get line $incomingmapname line #line0, line1 and etc.
config_get enable $incomingmapname enable
config_get extension $incomingmapname extension #group1 / group2
config_get group $incomingmapname extension #group1, group2 and etc. since incoming_map.extension is always a group instead
if [ -n "$line" ]; then
config_get lineenable $line enable
fi
#If Incomingmap is enabled
if [ -n "$enable" -a "$enable" = "1" ]; then
if [ -n "$line" -a "$lineenable" == "1" ] ; then
config_get provider $line provider #sip0 or sip1
if [ -z "$provider" -a -z "$extension" ]; then
if [ -z "$provider" -a -z "$group" ]; then
return
fi
#if the SIP provider match proceed
if [ "$provider" == "$2" ]; then
configure_incomingmap_extension $extension
if [ "$provider" == "$provide_target" ]; then
configure_incomingmap_extension $group
fi
fi
fi
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment