Commit 541542f7 authored by Hemlata's avatar Hemlata Committed by Yalu Zhang
Browse files

asterisk: fix some issues in config_asterisk.sh for voice mail configurations

parent 475e3033
......@@ -179,7 +179,6 @@ mailbox_get_boxnumber() {
return
fi
config_get boxnumber $1 boxnumber
if [ -n "$boxnumber" ] ; then
echo "$boxnumber"
......@@ -806,6 +805,20 @@ configure_extensions() {
echo "" >> $WORK_DIR/extensions.conf
}
configure_voicemail_incoming()
{
config_get calling_features $1 calling_features
config_get provider $1 provider
if [ -n "$calling_features" -a "$3" == "$provider" ]; then
config_get voice_mail_enable $calling_features voice_mail_enable
if [ -n "$voice_mail_enable" -a "$voice_mail_enable" == "1" ]; then
if [ -n "$2" -a "$user" == "$2" ] ; then
echo "Enabling mailbox $boxnumber for IVR $2"
echo "exten => $user,n,VoiceMail($2)" >> $tmp
fi
fi
fi
}
configure_extensions_provider() {
local enabled
local displayname
......@@ -972,11 +985,7 @@ configure_extensions_provider() {
mailbox_num="mailbox"
mailbox_num="${mailbox_num}${1: -1}"
config_get boxnumber $mailbox_num boxnumber
if [ -n "$boxnumber" ] ; then
echo "Enabling mailbox $boxnumber for IVR $1"
echo "exten => $user,n,VoiceMail($boxnumber)" >> $tmp
fi
config_foreach configure_voicemail_incoming line $boxnumber $1
if ! [ -z "$call_queue" ] ; then
echo "exten => $user,n,Macro($call_queue)" >> $tmp
......@@ -1021,7 +1030,6 @@ configure_provider_settings(){
for extension_item in ${extension_list//,/ }
do
if [ -n "$provider" -a "$2" == "$extension_item" ]; then
sed -i "s/|CONTEXT|/$provider/g" $WORK_DIR/tel_line
if [ -n "$calling_features" ]; then
config_get call_waiting_enable $calling_features call_waiting_enable
config_get anonymous_call_enable $calling_features anonymous_call_enable
......@@ -1039,9 +1047,9 @@ configure_provider_settings(){
config_get sip_provider_user $provider user
config_get sip_provider_enabled $provider enable
if [ "$sip_provider" == "-" -o -z "$sip_provider_enabled" -o "$sip_provider_enabled" == "0" -o -z "$sip_provider_user" ] ; then
sip_provider="local_extensions"
provider="local_extensions"
fi
sed -i "s/|CONTEXT|/$provider/g" $WORK_DIR/tel_line
fi
done
}
......@@ -1087,13 +1095,12 @@ configure_feature_set(){
#get the feature set frome extension
config_get featureset $1 calling_features
config_get provider $1 provider
if [ -n "$featureset" ]; then
config_get call_forward_unconditional $featureset call_forward_unconditional
config_get call_forward_on_busy $featureset call_forward_on_busy
config_get call_forward_on_no_answer $featureset call_forward_on_no_answer
config_get cbbs_enable $featureset cbbs_enable
config_get ccbs_enable $featureset ccbs_enable
config_get cbbs_type $featureset cbbs_type
config_get callreturn_enabled $featureset callreturn_enable
config_get redial_enabled $featureset redial_enable
......@@ -1106,18 +1113,23 @@ configure_feature_set(){
config_get mwi_enabled $featureset mwi_enable "0"
config_get mwi_dialtone_state $featureset mwi_dialtone_state "on"
[ -z "$do_not_disturb" ] && do_not_disturb=0
[ -z "$anonymous_call_enable" ] && anonymous_call_enable=0
[ -z "$call_waiting_enable" ] && call_waiting_enable=0
# load cbbs settings if enabled
if [ -z "$cbbs_type" -o "$cbbs_type" = "internal" ] ; then
cbbs_key=""
cbbs_maxretry="0"
cbbs_retrytime="0"
cbbs_waittime="0"
# load cbbs settings if enabled
if [ -n "$ccbs_enable" -a "$ccbs_enable" = "1" ]; then
if [ -n "$cbbs_type" -o "$cbbs_type" = "internal" ] ; then
config_get cbbs_key $featureset cbbs_key
config_get cbbs_maxretry $featureset cbbs_maxretry
config_get cbbs_retrytime $featureset cbbs_retrytime
config_get cbbs_waittime $featureset cbbs_waittime
else
# 'none' or 'external'
cbbs_key=""
cbbs_maxretry="0"
cbbs_retrytime="0"
cbbs_waittime="0"
fi
fi
# load call forwarding etc settings
......@@ -1156,13 +1168,12 @@ configure_feature_set(){
[ -z "$call_return" ] && call_return="callreturn"
[ -z "$redial" ] && redial="redial"
if [ -n "$cbbs_enable" -a "$cbbs_enable" = "1" ]; then
sed -i "s/|CBBS_KEY|/$(escape_sed_substitution $cbbs_key)/" $WORK_DIR/extensions.conf
sed -i "s/|MAX_RETRIES|/$cbbs_maxretry/" $WORK_DIR/extensions.conf
sed -i "s/|RETRYTIME|/$cbbs_retrytime/" $WORK_DIR/extensions.conf
sed -i "s/|WAITTIME|/$cbbs_waittime/" $WORK_DIR/extensions.conf
sed -i "s/|CONGESTIONTONE|/$congestiontone/" $WORK_DIR/extensions.conf
fi
tmp=$(mktemp)
if [ -n "$internal_service" -a "$internal_service" = "1" ] ; then
sed -i '/\['$provider'\]/a include => '$provider'-call_forward_on_busy' $WORK_DIR/extensions.conf
......@@ -1205,7 +1216,7 @@ configure_feature_set(){
fi
# CLIR feature access code
if [ -n "$anonymous_call_enable" -a "$anonymous_call_enable" != "" ] ; then
if [ -n "$anonymous_call_enable" -a "$anonymous_call_enable" != "0" ] ; then
sed -i "s/|CLIR_FAC_SET|//" $WORK_DIR/extensions.conf
sed -i "s/|CLIR|/$anonymous_call_enable/" $WORK_DIR/extensions.conf
sed -i "s/|CLIR_FAC_LEN|/${#anonymous_call_enable}/" $WORK_DIR/extensions.conf
......@@ -1220,7 +1231,7 @@ configure_feature_set(){
sed -i "s/|CW_ON_TONE|/cw_on/" $WORK_DIR/extensions_macro.conf
sed -i "s/|CW_OFF_TONE|/cw_off/" $WORK_DIR/extensions_macro.conf
if [ -z "$featureset" ]; then
if [ -n "$featureset" ]; then
# Configure call waiting
echo "[$provider-callwaiting]" >> $tmp
echo "exten => $cw_off,1, Macro(delete_cw,$provider)" >> $tmp
......@@ -1519,8 +1530,8 @@ configure_incomingmap_extension()
local lines_list
local extension
config_get extensions_list $1 extensions
if [ "${extensions_list}" = "" ] ; then
for item in $(db get hw.board.VoicePortOrder); do
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}&&"
......@@ -1622,11 +1633,17 @@ configure_tel_line() {
configure_voicemail() {
local extension
config_get extension voicemail extension
if [ -n "$extension" ] ; then
echo "exten => $extension,1,Answer(500)" >> $WORK_DIR/extensions_local
echo "exten => $extension,n,VoiceMailMain(@default)" >> $WORK_DIR/extensions_local
config_get featureset $1 calling_features
config_get boxnumber $1 boxnumber
if [ -n "$featureset" -a -n "$boxnumber" ]; then
config_get voice_mail_enable $featureset voice_mail_enable
if [ -n "$voice_mail_enable" -a "$voice_mail_enable" == "1" ]; then
config_get extension voicemail extension
if [ -n "$extension" ]; then
echo "exten => $extension,1,Answer(500)" >> $WORK_DIR/extensions_local
echo "exten => $extension,n,VoiceMailMain(@default)" >> $WORK_DIR/extensions_local
fi
fi
fi
}
......@@ -1893,7 +1910,7 @@ generate_asterisk_config_files() {
# Voicemai
echo "Configuring voice mail"
configure_voicemail
config_foreach configure_voicemail extension
config_foreach configure_mailbox mailbox
# Conference
......
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