[packages]: net/freeswitch: Added initial uci configuration capability.

git-svn-id: svn://svn.openwrt.org/openwrt/packages@22084 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
cshore
2010-07-07 11:18:11 +00:00
parent b58ccc42eb
commit 12a8a6f381
39 changed files with 3857 additions and 5 deletions

View File

@ -0,0 +1,81 @@
#!/bin/sh
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# Uncomment commented out XML line
fs_uncomment_xml_line() {
local file="$1"
local tag="$2"
local attribute1="$3"
local value1="$4"
local attribute2="$5"
local value2="$6"
if [ -n "$attribute2" ]; then
if [ -n "$value2" ]; then
sed -i -e "/<${tag} ${attribute1}=\"""${value1}""\".*${attribute2}=\"""${value2}""\".*\/>/ s|^\(.*\)<!--.*<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)${attribute2}\=\"""${value2}""\"\(.*\)/>.*-->\(.*\)\$|\1<${tag}\2${attribute1}=\"${value1}\"\3${attribute2}=\"${value2}\"\4/>\5|" $file
else
sed -i -e "/<${tag} ${attribute1}=\"""${value1}""\".*${attribute2}=.*\/>/ s|^\(.*\)<!--.*<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)${attribute2}\=\(.*\)/>.*-->\(.*\)\$|\1<${tag}\2${attribute1}=\"""${value1}""\"\3${attribute2}=\4/>\5|" $file
fi
elif [ -n "$attribute1" ]; then
sed -i -e "/<${tag} ${attribute1}=\"""${value1}""\".*\/>/ s|^\(.*\)<!--.*<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)\/>.*-->\(.*\)\$|\1<${tag}\2${attribute1}=\"""${value1}""\"\3\/>\4|" $file
else
logger -t freeswitch "Error uncommenting tag $tag in file $1; no attributes defined"
fi
}
# Comment previously uncommented XML line
fs_comment_xml_line() {
local file="$1"
local tag="$2"
local attribute1="$3"
local value1="$4"
local attribute2="$5"
local value2="$6"
if [ -n "$attribute2" ]; then
sed -i -e "/<[^!]${tag} ${attribute1}=\"""${value1}""\".*${attribute2}=\"""${value2}""\"\/>/ s|\(.*\)<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)${attribute2}=\"""${value2}""\"\(.*\)/>(.*\)\$|<!-- \1<${tag}\2${attribute1}=\"${value1}\"\3${attribute2}=\"""${value2}""\"\4/>\5 -->|" $file
elif [ -n "$attribute1" ]; then
sed -i -e "/<[^!]${tag} ${attribute1}=\"""${value1}""\".*\/>/ s|\(.*\)<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)/>\(.*\)\$|\1<!-- <${tag}\2${attribute1}=\"""${value1}""\"\3/>\4 -->|" $file
else
logger -t freeswitch "Error uncommenting tag $tag in file $1; no attributes defined"
fi
}
# Modify second attribute in tag with two attributes (tag and one attribute
# specified) if tag exists and is comments modifies, if commented,
# uncomments and and modifies it.
fs_mod_attribute2() {
local file="$1"
local tag="$2"
local attribute1="$3"
local value1="$4"
local attribute2="$5"
local newvalue="$6"
fs_uncomment_xml_line "$file" "$tag" "$attribute1" "$value1" "$attribute2"
sed -i -e "/[^<!-]*<${tag} ${attribute1}=\"""${value1}""\".*${attribute2}=\""".*""\"\/>/ s|\(.*\)<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)${attribute2}=\""".*""\"\(.*\)/>\(.*\)\$|\1<${tag}\2${attribute1}=\"""${value1}""\"\3${attribute2}=\"""${newvalue}""\"\4/>\5|" $file
}
fs_set_param() {
local file="$1"
local param="$2"
local newvalue="$3"
if [ -n "$newvalue" ]; then
fs_mod_attribute2 "$file" param name "$param" value "$newvalue"
else
fs_comment_xml_line "$file" param name "$param"
fi
}
fs_set_param_bool() {
local file="$1"
local param="$2"
local boolvalue="$3"
if [ "$boolvalue" = "0" ]; then
fs_set_param "$file" "$param" "false"
else
fs_set_param "$file" "$param" "true"
fi
}

View File

@ -0,0 +1,59 @@
#!/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_parse_param_action() {
local cfg="$1"
local param_file="$2"
local param="$3"
local param_type="$4"
local default="$5"
local value
if [ -z "$default" ]; then
config_get value "$cfg" "$(echo $param|tr - _ )"
else
config_get value "$cfg" "$(echo $param|tr - _ )" "$default"
fi
if [ "$param_type" = "bool" ]; then
if [ "$value" = "0" ] || [ "$value" = "false" ] || [ "$value" = "no" ]; then
value="false"
elif [ "$value" = "1" ] || [ "$value" = "true" ] || [ "$value" = "yes" ]; then
value="true"
fi
fi
fs_set_param "$param_file" "$param" "$value"
}
fs_to_xml_param_list() {
local cfg="$1"
local param_list="$2"
local param_file="$3"
local i=0
local param
local default
local list_item
local param_type
echo "$param_list" | {
local list_item
read -t 1 list_item
while [ "$list_item" != '[FS-EOF]' ]; do
if [ $i -eq 0 ]; then
param="$list_item"
i=1
elif [ $i -eq 1 ]; then
param_type="$list_item"
i=2
else
default="$list_item"
fs_parse_param_action "$cfg" "$param_file" "$param" "$param_type" "$default"
i=0
fi
read -t 1 list_item
done
}
}

View File

@ -0,0 +1,437 @@
#!/bin/sh
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# . /etc/functions.sh
# . /usr/lib/freeswitch/uci/common/param_from_config.sh
fs_profile_gateway() {
local cfg="$1"
local param_file="$2"
local param_list="username
string
password
password
realm
string
from-user
string
from-domain
string
extension
string
proxy
string
register-proxy
string
expire-seconds
integer
register
bool
register-transport
string
retry-seconds
integer
caller-id-in-from
bool
contact-params
string
extension-in-contact
string
ping
integer
[FS-EOF]
"
fs_to_xml_param_list "$cfg" "$param_list" "$param_file"
}
fs_profile_internal_top() {
local cfg="$1"
local param_file="$2"
local param_list="media-option
string
user-agent-string
string
debug
integer
0
shutdown-on-fail
bool
sip-trace
string
no
log-auth-failures
bool
true
context
string
public
rfc2833-pt
integer
101
sip-port
integer
\$\${internal_sip_port}
dialplan
string
XML
dtmf-duration
integer
2000
inbound-codec-prefs
string
\$\${global_codec_prefs}
outbound-codec-prefs
string
\$\${global_codec_prefs}
rtp-timer-name
string
soft
rtp-ip
string
\$\${local_ip_v4}
sip-ip
string
\$\${local_ip_v4}
hold-music
string
\$\${hold_music}
apply-nat-acl
string
nat.auto
extended-info-parsing
bool
aggressive-nat-detection
bool
enable-100rel
bool
enable-compact-headers
bool
enable-timer
bool
minimum-session-expires
integer
apply-inbound-acl
string
domains
local-network-acl
string
localnet.auto
apply-register-acl
string
dtmf-type
string
info
send-message-query-on-register
bool
record-path
string
\$\${recordings_dir}
record-template
string
\${caller_id_number}.\${target_domain}.\${strftime(%Y-%m-%d-%H-%M-%S)}.wav
manage-presence
bool
true
manage-shared-appearance
bool
dbname
string
presence-hosts
string
bitpacking
string
max-proceeding
integer
session-timeout
integer
multiple-registrations
string
inbound-codec-negotiation
string
generous
bind-params
string
unregister-on-options-fail
bool
tls
bool
\$\${internal_ssl_enable}
tls-bind-params
string
transport=tls
tls-sip-port
integer
\$\${internal_tls_port}
tls-cert-dir
string
\$\${internal_ssl_dir}
tls-version
string
\$\${sip_tls_version}
rtp-autoflush-during-bridge
bool
rtp-rewrite-timestamps
bool
pass-rfc2833
bool
odbc-dsn
string
inbound-bypass-media
bool
inbound-proxy-media
bool
inbound-late-negotiation
bool
accept-blind-reg
bool
accept-blind-auth
bool
suppress-cng
bool
nonce-ttl
integer
60
disable-transcoding
bool
manual-redirect
bool
disable-transfer
bool
disable-register
bool
NDLB-broken-auth-hash
bool
NDLB-received-in-nat-reg-contact
bool
auth-calls
bool
\$\${internal_auth_calls}
inbound-reg-force-match-username
bool
true
auth-all-package
bool
false
ext-rtp-ip
string
auto-nat
ext-sip-ip
string
auto-nat
rtp-timeout-sec
integer
300
rtp-hold-timeout-sec
integer
1800
vad
string
alias
string
force-register-domain
string
\$\${domain}
force-subscription-domain
string
\$\${domain}
force-register-db-domain
string
\$\${domain}
force-subscription-expires
integer
enable-3pcc
string
NDLB-force-rport
bool
challenge-realm
string
auto_from
disable-rtp-auto-adjust
bool
inbound-use-callid-as-uuid
bool
outbound-use-callid-as-uuid
bool
pass-callee-id
bool
auto-rtp-bugs
string
disable-srv
bool
disable-naptr
bool
[FS-EOF]
"
fs_to_xml_param_list "$cfg" "$param_list" "$param_file"
}
fs_profile_external_top() {
local cfg="$1"
local param_file="$2"
local param_list="debug
integer
0
shutdown-on-fail
bool
sip-trace
string
no
context
string
public
rfc2833-pt
integer
101
sip-port
integer
\$\${external_sip_port}
dialplan
string
XML
inbound-codec-prefs
string
\$\${global_codec_prefs}
outbound-codec-prefs
string
\$\${outbound_codec_prefs}
rtp-timer-name
string
soft
dtmf-duration
integer
2000
rtp-ip
string
\$\${local_ip_v4}
sip-ip
string
\$\${local_ip_v4}
ext-rtp-ip
string
auto-nat
ext-sip-ip
string
auto-nat
hold-music
string
\$\${hold_music}
aggressive-nat-detection
bool
enable-100rel
bool
local-network-acl
string
localnet.auto
manage-presence
bool
false
dbname
string
presence-hosts
string
tls
bool
\$\${external_ssl_enable}
tls-bind-params
string
transport=tls
tls-sip-port
integer
\$\${external_tls_port}
tls-cert-dir
string
\$\${external_ssl_dir}
tls-version
string
\$\${sip_tls_version}
nonce-ttl
integer
60
auth-calls
bool
false
inbound-codec-negotiation
string
generous
rtp-timeout-sec
integer
300
rtp-hold-timeout-sec
integer
1800
[FS-EOF]
"
fs_to_xml_param_list "$cfg" "$param_list" "$param_file"
}

View File

@ -0,0 +1,15 @@
#!/bin/sh
# Copyright (C) 2010 Vertical Communications
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# Note that the fs_profile_* functions require the FS XML files contains
# commented out sections for the parameters that are not currently in use, but
# which are to be available to the UCI FS config
fs_init_xml() {
config_load freeswitch
fs_profile_internal_top "internal_top" "/etc/freeswitch/sip_profiles/internal.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"
}