[packages]: net/freeswitch: Added UCI config of extensions and incoming DIDs (to extensions only)

git-svn-id: svn://svn.openwrt.org/openwrt/packages@22157 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
cshore 2010-07-13 01:48:08 +00:00
parent eb6f5f1f01
commit 0b1143e1b7
13 changed files with 101 additions and 109 deletions

View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=freeswitch
PKG_VERSION:=1.0.6
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

View File

@ -20,12 +20,6 @@
</condition>
</extension>
<extension name="redial">
<condition field="destination_number" expression="^870$">
<action application="transfer" data="${hash(select/${domain_name}-last_dial/${caller_id_number})}"/>
</condition>
</extension>
<extension name="global" continue="true">
<condition field="${call_debug}" expression="^true$" break="never">
<action application="info"/>
@ -48,14 +42,8 @@
</extension>
-->
<extension name="call_return">
<condition field="destination_number" expression="^\*69$|^869$|^lcr$">
<action application="transfer" data="${hash(select/${domain_name}-call_return/${caller_id_number})}"/>
</condition>
</extension>
<extension name="extension-intercom">
<condition field="destination_number" expression="^8(100[0-4])$">
<condition field="destination_number" expression="^8([{FS_DIALPLAN_PHONES}])$">
<action application="set" data="dialed_extension=$1"/>
<action application="export" data="sip_auto_answer=true"/>
<action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
@ -63,12 +51,12 @@
</extension>
<!--
dial the extension (1000-1004) for 2 minutes before giving up
otherwise hang up after a successful bridge (hangup_after-bridge=true).
Record call if *2 is pressed during call.
dial the extension (filled in from UCI config) 2 minutes before giving
up, otherwise hang up after a successful bridge (hangup_after-bridge=true).
Record call if *2 is pressed during call (by called extension).
-->
<extension name="Local_Extension">
<condition field="destination_number" expression="^(100[0-4])$">
<condition field="destination_number" expression="^([{FS_DIALPLAN_PHONES}])$">
<action application="set" data="dialed_extension=$1"/>
<action application="export" data="dialed_extension=$1"/>
<!-- bind_meta_app can have these args <key> [a|b|ab] [a|b|o|s] <app> -->

View File

@ -37,7 +37,7 @@
</extension>
<extension name="public_extensions">
<condition field="destination_number" expression="^(100[0-4])$">
<condition field="destination_number" expression="^([{FS_DIALPLAN_PHONES}])$">
<action application="transfer" data="$1 XML default"/>
</condition>
</extension>

View File

@ -0,0 +1,6 @@
<extension name="did-[{FS_INCOMING_DID}]">
<condition field="destination_number" expression="[{FS_INCOMING_DID}]">
<action application="transfer" data="[{FS_EXTENSION_NUMBER}] XML default"/>
</condition>
</extension>

View File

@ -1,18 +0,0 @@
<include>
<user id="1000">
<params>
<param name="password" value="$${default_password}"/>
<param name="vm-password" value="1000"/>
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local"/>
<variable name="accountcode" value="1000"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="Extension 1000"/>
<variable name="effective_caller_id_number" value="1000"/>
<variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
<variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
<variable name="callgroup" value="techsupport"/>
</variables>
</user>
</include>

View File

@ -1,18 +0,0 @@
<include>
<user id="1001">
<params>
<param name="password" value="$${default_password}"/>
<param name="vm-password" value="1001"/>
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local"/>
<variable name="accountcode" value="1001"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="Extension 1001"/>
<variable name="effective_caller_id_number" value="1001"/>
<variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
<variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
<variable name="callgroup" value="techsupport"/>
</variables>
</user>
</include>

View File

@ -1,18 +0,0 @@
<include>
<user id="1002">
<params>
<param name="password" value="$${default_password}"/>
<param name="vm-password" value="1002"/>
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local"/>
<variable name="accountcode" value="1002"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="Extension 1002"/>
<variable name="effective_caller_id_number" value="1002"/>
<variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
<variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
<variable name="callgroup" value="techsupport"/>
</variables>
</user>
</include>

View File

@ -1,18 +0,0 @@
<include>
<user id="1003">
<params>
<param name="password" value="$${default_password}"/>
<param name="vm-password" value="1003"/>
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local"/>
<variable name="accountcode" value="1003"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="Extension 1003"/>
<variable name="effective_caller_id_number" value="1003"/>
<variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
<variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
<variable name="callgroup" value="techsupport"/>
</variables>
</user>
</include>

View File

@ -1,18 +0,0 @@
<include>
<user id="1004">
<params>
<param name="password" value="$${default_password}"/>
<param name="vm-password" value="1004"/>
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local"/>
<variable name="accountcode" value="1004"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="Extension 1004"/>
<variable name="effective_caller_id_number" value="1004"/>
<variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
<variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
<variable name="callgroup" value="techsupport"/>
</variables>
</user>
</include>

View File

@ -0,0 +1,18 @@
<include>
<user id="[{FS_EXTENSION_ID}]">
<params>
<param name="password" value="[{FS_EXTENSION_PASSWORD}]"/>
<param name="vm-password" value="[{FS_EXTENSION_VM_PASSWORD}]"/>
</params>
<variables>
<variable name="toll_allow" value="[{FS_EXTENSION_TOLL_ALLOW}]"/>
<variable name="accountcode" value="[{FS_EXTENSION_ACCOUNT_CODE}]"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="[{FS_EXTENSION_EFFECTIVE_CALLERID_NAME}]"/>
<variable name="effective_caller_id_number" value="[{FS_EXTENSION_EFFECTIVE_CALLERID_NUMBER}]"/>
<variable name="outbound_caller_id_name" value="[{FS_EXTENSION_OUTBOUND_CALLERID_NAME}]"/>
<variable name="outbound_caller_id_number" value="[{FS_EXTENSION_OUTBOUND_CALLERID_NUMBER}]"/>
<variable name="callgroup" value="[{FS_EXTENSION_CALLGROUP}]"/>
</variables>
</user>
</include>

View File

@ -0,0 +1,69 @@
#!/bin/sh
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
fs_escape_slash() {
local inval="$1"
[ -z "$inval" ] && return 0
echo "$inval" | sed -e 's/([/\\$\^\[\]])/\\\1/g'
}
fs_ext_entry() {
local cfg="$1"
local number
local userid
local password
local vm_password
local toll_allow
local account_code
local effective_callerid_name
local effective_callerid_number
local outbound_callerid_name
local outbound_callerid_number
local did
local callgroup
config_get number "$cfg" number
[ "$number" = "default" ] && return 1
config_get userid "$cfg" userid "$number"
config_get password "$cfg" password '$${default_password}'
config_get vm_password "$cfg" vm_password "$number"
config_get toll_allow "$cfg" toll_allow 'domestic,international,local'
config_get account_code "$cfg" account_code "$number"
config_get effective_callerid_name "$cfg" effective_callerid_name "Extension $number"
config_get effective_callerid_number "$cfg" effective_callerid_number "$number"
config_get outbound_callerid_name "$cfg" outbound_callerid_name '$${outbound_caller_name}'
config_get outbound_callerid_number "$cfg" outbound_callerid_number '$${outbound_caller_id}'
config_get did "$cfg" did
config_get callgroup "$cfg" callgroup "everyone"
sed -e "s/\[{FS_EXTENSION_ID}\]/$(fs_escape_slash $userid)/
s/\[{FS_EXTENSION_PASSWORD}\]/$(fs_escape_slash $password)/
s/\[{FS_EXTENSION_VM_PASSWORD}\]/$(fs_escape_slash $vm_password)/
s/\[{FS_EXTENSION_TOLL_ALLOW}\]/$(fs_escape_slash $toll_allow)/
s/\[{FS_EXTENSION_ACCOUNT_CODE}\]/$(fs_escape_slash $account_code)/
s/\[{FS_EXTENSION_EFFECTIVE_CALLERID_NAME}\]/$(fs_escape_slash $effective_callerid_name)/
s/\[{FS_EXTENSION_EFFECTIVE_CALLERID_NUMBER}\]/$(fs_escape_slash $effective_callerid_number)/
s/\[{FS_EXTENSION_OUTBOUND_CALLERID_NAME}\]/$(fs_escape_slash $outbound_callerid_name)/
s/\[{FS_EXTENSION_OUTBOUND_CALLERID_NUMBER}\]/$(fs_escape_slash $outbound_callerid_number)/
s/\[{FS_EXTENSION_CALLGROUP}\]/$(fs_escape_slash $callgroup)/
" /etc/freeswitch/directory/default/extension.xml.template >/etc/freeswitch/directory/default/ext-"$number".xml
[ -n "$did" ] && {
sed -e "s/\[{FS_INCOMING_DID}\]/$did/
s/\[{FS_EXTENSION_NUMBER}\]/$number/
" /etc/freeswitch/dialplan/public/did.xml.template >/etc/freeswitch/dialplan/public/20-did-"$did".xml
}
append ext_number_list "$number" '|'
}
fs_extensions_all() {
local ext_number_list=""
rm -f /etc/freeswitch/directory/default/ext-*.xml
rm -f /etc/freeswitch/dialplan/public/20-did-*.xml
config_foreach fs_ext_entry "extension"
sed -e "s/\[{FS_DIALPLAN_PHONES}\]/$ext_number_list/" /etc/freeswitch/dialplan/public.xml.template >/etc/freeswitch/dialplan/public.xml
sed -e "s/\[{FS_DIALPLAN_PHONES}\]/$ext_number_list/" /etc/freeswitch/dialplan/default.xml.template >/etc/freeswitch/dialplan/default.xml
}

View File

@ -12,4 +12,5 @@ fs_init_xml() {
fs_profile_external_top "external_top" "/etc/freeswitch/sip_profiles/external.xml"
fs_profile_gateway "external_example" "/etc/freeswitch/sip_profiles/external/example.xml"
fs_profile_gateway "internal_example" "/etc/freeswitch/sip_profiles/internal/example.xml"
fs_extensions_all
}