2 # Copyright (C) 2010 Vertical Communications
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
6 # Uncomment commented out XML line
7 fs_uncomment_xml_line() {
14 if [ -n "$attribute2" ]; then
15 if [ -n "$value2" ]; then
16 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
18 sed -i -e "/<${tag} ${attribute1}=\"""${value1}""\".*${attribute2}=.*\/>/ s|^\(.*\)<!--.*<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)${attribute2}\=\(.*\)/>.*-->\(.*\)\$|\1<${tag}\2${attribute1}=\"""${value1}""\"\3${attribute2}=\4/>\5|" $file
20 elif [ -n "$attribute1" ]; then
21 sed -i -e "/<${tag} ${attribute1}=\"""${value1}""\".*\/>/ s|^\(.*\)<!--.*<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)\/>.*-->\(.*\)\$|\1<${tag}\2${attribute1}=\"""${value1}""\"\3\/>\4|" $file
23 logger -t freeswitch "Error uncommenting tag $tag in file $1; no attributes defined"
27 # Comment previously uncommented XML line
28 fs_comment_xml_line() {
35 if [ -n "$attribute2" ]; then
36 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
37 elif [ -n "$attribute1" ]; then
38 sed -i -e "/<[^!]${tag} ${attribute1}=\"""${value1}""\".*\/>/ s|\(.*\)<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)/>\(.*\)\$|\1<!-- <${tag}\2${attribute1}=\"""${value1}""\"\3/>\4 -->|" $file
40 logger -t freeswitch "Error uncommenting tag $tag in file $1; no attributes defined"
44 # Modify second attribute in tag with two attributes (tag and one attribute
45 # specified) if tag exists and is comments modifies, if commented,
46 # uncomments and and modifies it.
54 fs_uncomment_xml_line "$file" "$tag" "$attribute1" "$value1" "$attribute2"
55 sed -i -e "/[^<!-]*<${tag} ${attribute1}=\"""${value1}""\".*${attribute2}=\""".*""\"\/>/ s|\(.*\)<${tag}\(.*\)${attribute1}=\"""${value1}""\"\(.*\)${attribute2}=\""".*""\"\(.*\)/>\(.*\)\$|\1<${tag}\2${attribute1}=\"""${value1}""\"\3${attribute2}=\"""${newvalue}""\"\4/>\5|" $file
63 if [ -n "$newvalue" ]; then
64 fs_mod_attribute2 "$file" param name "$param" value "$newvalue"
66 fs_comment_xml_line "$file" param name "$param"
75 if [ "$boolvalue" = "0" ]; then
76 fs_set_param "$file" "$param" "false"
78 fs_set_param "$file" "$param" "true"