[dahdi-commits] dahdi/tools.git branch "master" updated.
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Apr 1 13:24:28 CDT 2014
branch "master" has been updated
via f2628eeedd1bf9dc41c56062c9afbe190196232f (commit)
from 1292ea90789aa20bff5a533141086f6ecf4f82df (commit)
Summary of changes:
dahdi_span_types | 61 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 45 insertions(+), 16 deletions(-)
- Log -----------------------------------------------------------------
commit f2628eeedd1bf9dc41c56062c9afbe190196232f
Author: Oron Peled <oron.peled at xorcom.com>
Date: Mon Mar 31 19:48:30 2014 +0300
improved dahdi_span_types dumpconfig
* Better defaults:
- A wildcard match:
- If '--line-mode' option is given, generate a wildcard entry.
(existing behavior).
- Otherwise, if *all spans* are of the same type (E1/T1),
generate a wildcard entry for this type.
This is the most common use-case and now it work without
any command line flags.
- Otherwise (mixed E1/T1 spans), do not generate a wildcard entry.
This isn't common case (except from our labs), but regardless
without '--line-mode' any guess could be wrong.
- Specific device matches:
- If all spans are of the same type, generate commented out
specific entries (for manual overrides).
- If spans have mixed E1/T1 types, generate specific entries
In this case, specific entries MUST NOT be commented out
otherwise, the configuration file is wrong!
* Generated header with better organization:
- Shows what is generated:
- Generating wildcard / Not generating wildcard
- Generating specific lines / Generating *commented-out* specific lines
- For each decision, show *why* it was taken.
Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks at digium.com>
diff --git a/dahdi_span_types b/dahdi_span_types
index 85204d8..4154772 100755
--- a/dahdi_span_types
+++ b/dahdi_span_types
@@ -188,28 +188,57 @@ show_spantypes() {
done
}
+list_pri_spantypes() {
+ find $DEVICES -follow -maxdepth 1 -name spantype | \
+ xargs cat | \
+ sed -n '/:[ETJ]1$/s/^.*://p' | \
+ sort -u | \
+ tr '\n' ' ' | \
+ sed -e 's/^ *//' -e 's/ *$//'
+}
+
dump_config() {
+ pri_spantypes=`list_pri_spantypes`
+ num_spantypes=`echo "$pri_spantypes" | wc -w`
+ gen_default=''
echo '#'
echo "# Autogenerated by $0 on `date`"
echo "# Map PRI DAHDI devices to span types for E1/T1/J1"
+ echo "#"
+
+ echo "# Summary:"
if [ "$DEFAULT_LINE_MODE" != '' ]; then
- echo "# Was run with '--line-mode=$DEFAULT_LINE_MODE' -- so will:"
- echo "# * Generate default wildcard entry"
- echo "# * Generate commented-out device list (for overrides)"
+ gen_default="$DEFAULT_LINE_MODE"
+ echo "# * Generating wildcard match of $gen_default."
+ echo "# - Was run with '--line-mode=$DEFAULT_LINE_MODE'"
+ elif [ "$num_spantypes" -eq 1 ]; then
+ gen_default="$pri_spantypes"
+ echo "# * Generating wildcard match of $gen_default."
+ echo "# - Spans were $pri_spantypes"
+ else
+ echo "# * Not generating wildcard match."
+ echo "# - Was run without '--line-mode' option and span were of mixed types [$pri_spantypes]"
+ fi
+ echo "#"
+ if [ "$num_spantypes" -eq 1 ]; then
+ echo "# * Generating a list of commented out configurations for spans."
+ echo "# - Spans were $pri_spantypes"
+ echo "# - Uncomment for specific overrides"
+ else
+ echo "# * Generating a list of specific span configurations."
+ echo "# - Spans were of mixed types: $pri_spantypes"
fi
+ echo "#"
echo ''
- fmt="%-65s %s\n"
- printf "$fmt" '# @location/hardware_id' 'span_type'
- if [ "$DEFAULT_LINE_MODE" != '' ]; then
- echo ""
- echo "# Wildcard line-mode $DEFAULT_LINE_MODE".
- printf "$fmt" "*" "*:$DEFAULT_LINE_MODE"
- echo ""
- echo "# A list of commented out configurations for spans."
- echo "# Each item may be un-commented to provide an override."
+ fmt="%-65s %s"
+ printf "$fmt\n" '# @location/hardware_id' 'span_type'
+
+ if [ "$gen_default" != '' ]; then
+ printf "$fmt\t\t# Wildcard line-mode" "*" "*:$gen_default"
echo ""
fi
+ echo ""
for device in $DEVICES
do
devpath=`cd "$device" && pwd -P`
@@ -226,10 +255,10 @@ dump_config() {
cat "$device/spantype" | while read st; do
case "$st" in
*:[ETJ]1)
- if [ "$DEFAULT_LINE_MODE" != '' ]; then
- printf "#$fmt" "$id" "$st"
+ if [ "$num_spantypes" -eq 1 ]; then
+ printf "#$fmt\n" "$id" "$st"
else
- printf "$fmt" "$id" "$st"
+ printf "$fmt\n" "$id" "$st"
fi
;;
*)
@@ -237,7 +266,7 @@ dump_config() {
;;
esac
done | sort -n
- #echo ''
+ echo ''
done
}
-----------------------------------------------------------------------
--
dahdi/tools.git
More information about the dahdi-commits
mailing list