From: <abe...@us...> - 2014-03-12 21:08:22
|
Revision: 6457 http://sourceforge.net/p/astlinux/code/6457 Author: abelbeck Date: 2014-03-12 21:08:18 +0000 (Wed, 12 Mar 2014) Log Message: ----------- phoneprov-tools, add support for multiple dialplanN_file and dialplanN_context and [dialplanN] contexts in templates Modified Paths: -------------- branches/1.0/package/phoneprov-tools/phoneprov-build branches/1.0/package/phoneprov-tools/phoneprov-massdeployment Modified: branches/1.0/package/phoneprov-tools/phoneprov-build =================================================================== --- branches/1.0/package/phoneprov-tools/phoneprov-build 2014-03-12 20:54:32 UTC (rev 6456) +++ branches/1.0/package/phoneprov-tools/phoneprov-build 2014-03-12 21:08:18 UTC (rev 6457) @@ -175,6 +175,9 @@ DIALPLAN_DIR="/mnt/kd/asterisk/includes" SIP_DIR="/mnt/kd/asterisk/includes" +DIALPLANS=(dialplan dialplan2 dialplan3 dialplan4 dialplan5 dialplan6) +EXTENS=(exten exten2 exten3 exten4 exten5 exten6) + case $if_name in INTIF) sip_server_if="$INTIF" @@ -273,11 +276,13 @@ if [ -z "$dialplan_path" ]; then dialplan_path="$DIALPLAN_DIR" fi -dialplan_file="$(extract_var dialplan_file)" -if [ -z "$dialplan_file" ]; then - dialplan_file="astlinux-phoneprov-exten.conf" -fi -dialplan_context="$(extract_var dialplan_context)" +for d in ${!DIALPLANS[*]}; do + dialplan_file[$d]="$(extract_var ${DIALPLANS[$d]}_file)" + if [ -z "${dialplan_file[$d]}" ]; then + dialplan_file[$d]="astlinux-phoneprov-${EXTENS[$d]}.conf" + fi + dialplan_context[$d]="$(extract_var ${DIALPLANS[$d]}_context)" +done sip_path="$(extract_var sip_path)" if [ -z "$sip_path" ]; then sip_path="$SIP_DIR" @@ -290,22 +295,25 @@ # Special case to initialize dialplan and sip output files if [ "$ext" = "init" -o "$ext" = "init-dialplan" -o "$ext" = "init-sip" ]; then if [ "$ext" = "init" -o "$ext" = "init-dialplan" ]; then - if is_context "dialplan" "$TEMPLATE_DIR/$template.conf"; then - exit_no_overwrite "$dialplan_path/$dialplan_file" - if [ ! -d "$dialplan_path" ]; then - mkdir -p "$dialplan_path" - fi - echo "; + for d in ${!DIALPLANS[*]}; do + if is_context "${DIALPLANS[$d]}" "$TEMPLATE_DIR/$template.conf"; then + exit_no_overwrite "$dialplan_path/${dialplan_file[$d]}" + if [ ! -d "$dialplan_path" ]; then + mkdir -p "$dialplan_path" + fi + echo "; ; #################################################### ; ### AstLinux auto-provisioned IP-Phone dialplan #### ; #################################################### ; ; Include in your extensions.conf file by using: -; #include $dialplan_path/$dialplan_file -${dialplan_context:+ -[$dialplan_context]} -" > "$dialplan_path/$dialplan_file" - fi +; #include $dialplan_path/${dialplan_file[$d]} +" > "$dialplan_path/${dialplan_file[$d]}" + if [ -n "${dialplan_context[$d]}" ]; then + echo "[${dialplan_context[$d]}]" >> "$dialplan_path/${dialplan_file[$d]}" + fi + fi + done fi if [ "$ext" = "init" -o "$ext" = "init-sip" ]; then if is_context "sip" "$TEMPLATE_DIR/$template.conf"; then @@ -353,29 +361,23 @@ # main -is_context_dialplan=0 -if is_context "dialplan" "$TEMPLATE_DIR/$template.conf"; then - is_context_dialplan=1 -fi -is_context_sip=0 -if is_context "sip" "$TEMPLATE_DIR/$template.conf"; then - is_context_sip=1 -fi is_context_phoneprov=0 if is_context "phoneprov" "$TEMPLATE_DIR/$template.conf"; then exit_no_overwrite "$prov_path/$prov_file" is_context_phoneprov=1 fi -if [ $is_context_dialplan -eq 1 ]; then - if [ ! -d "$dialplan_path" ]; then - mkdir -p "$dialplan_path" +for d in ${!DIALPLANS[*]}; do + if is_context "${DIALPLANS[$d]}" "$TEMPLATE_DIR/$template.conf"; then + if [ ! -d "$dialplan_path" ]; then + mkdir -p "$dialplan_path" + fi + extract_context "${DIALPLANS[$d]}" "$TEMPLATE_DIR/$template.conf" | \ + merge_variables | merge_indexed_variables >> "$dialplan_path/${dialplan_file[$d]}" fi - extract_context "dialplan" "$TEMPLATE_DIR/$template.conf" | \ - merge_variables | merge_indexed_variables >> "$dialplan_path/$dialplan_file" -fi +done -if [ $is_context_sip -eq 1 ]; then +if is_context "sip" "$TEMPLATE_DIR/$template.conf"; then if [ ! -d "$sip_path" ]; then mkdir -p "$sip_path" fi Modified: branches/1.0/package/phoneprov-tools/phoneprov-massdeployment =================================================================== --- branches/1.0/package/phoneprov-tools/phoneprov-massdeployment 2014-03-12 20:54:32 UTC (rev 6456) +++ branches/1.0/package/phoneprov-tools/phoneprov-massdeployment 2014-03-12 21:08:18 UTC (rev 6457) @@ -48,14 +48,6 @@ cat "$file" | sed -e 's/^#.*//' -e 's/\t/ /g' -e 's/ *$//' -e '/^$/d' } -init_args() { - local args="$1" template - - template="$(echo "$args" | awk -F' ' '{ print $1; }')" - - echo "$template 00:00:00:00:00:00 init" -} - gen_pass() { local data="$1" template mac_addr ext_cid ext pass @@ -160,23 +152,39 @@ echo "Generating Phone Provisioning files:" -if [ $partial -eq 1 ]; then - first=0 -else +if [ $partial -eq 0 ]; then first=1 + template_list=" " + IFS=$'\n' + extract_file "$in_file" | while read data; do + unset IFS + template="$(echo "$data" | awk -F' ' '{ print $1; }')" + if ! echo "$template_list" | grep -q " $template "; then + if [ $first -eq 1 ]; then + init="init" + else + init="init-dialplan" + fi + phoneprov-build $options $template 00:00:00:00:00:00 $init + result=$? + if [ $result -ne 0 ]; then + error_info $result + exit $result + fi + template_list="$template_list$template " + first=0 + fi + done + result=$? + unset IFS + if [ $result -ne 0 ]; then + exit $result + fi fi + IFS=$'\n' extract_file "$in_file" | while read data; do unset IFS - if [ $first -eq 1 ]; then - phoneprov-build $options $(init_args $data) - result=$? - if [ $result -ne 0 ]; then - error_info $result - exit $result - fi - first=0 - fi phoneprov-build $options $data result=$? if [ $result -ne 0 ]; then This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |