[dahdi-commits] dahdi/tools.git branch "next" created.
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Jun 26 09:03:32 CDT 2017
branch "next" has been created
at 9631938e90f3ddf180b1f8bbe9aa3ff3728cca0b (commit)
- Log -----------------------------------------------------------------
commit 9631938e90f3ddf180b1f8bbe9aa3ff3728cca0b
Author: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Date: Mon Jun 12 15:54:43 2017 +0300
dahdi_span_types: compare
This adds an extra subcommand: compare: shows span that have been
configured (in /etc/dahdi/span_types.conf) to a different value than
the one currently active on the system.
Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
diff --git a/dahdi-bash-completion b/dahdi-bash-completion
index d98074a..b93059a 100644
--- a/dahdi-bash-completion
+++ b/dahdi-bash-completion
@@ -48,7 +48,7 @@ __dahdi_span_types() {
has_cmd=0
for (( i=0; i < COMP_CWORD; i++)); do
case "${COMP_WORDS[$i]}" in
- dumpconfig | list | set)
+ dumpconfig | list | set | compare)
has_cmd=1
break
;;
@@ -69,7 +69,7 @@ __dahdi_span_types() {
grep -l '[EJT]1' /sys/devices/pci0000:00/0000:00:10.4/usb1/1-1/xbus-00/*/spantype 2>/dev/null | sed -e 's|/spantype||') )
else
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
- 'dumpconfig list set' -- $cur) )
+ 'dumpconfig list set compare' -- $cur) )
fi
;;
esac
diff --git a/dahdi_span_types b/dahdi_span_types
index 4154772..5fce110 100755
--- a/dahdi_span_types
+++ b/dahdi_span_types
@@ -69,6 +69,7 @@ usage() {
echo >&2 "Usage: $0 [options] action [devpath ...]"
echo >&2 " action:"
echo >&2 " set - set spans to E1/T1 according to /etc/dahdi/span-types.conf"
+ echo >&2 " compare - show config values that differ from system"
echo >&2 " list - human-readable list of all spans"
echo >&2 " dumpconfig - dump current state in /etc/dahdi/span-types.conf format"
echo >&2 ""
@@ -88,6 +89,8 @@ if [ $? != 0 ]; then
usage
fi
+compare=false
+
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
@@ -321,13 +324,26 @@ handle_span() {
echo >&2 "Set $devname span $spanno = $val"
fi
if [ "$dry_run" != 'true' ]; then
- echo "$spanno:$val" > "$attr_file"
+ if [ "$compare" = 'true' ]; then
+ config="$spanno:$val"
+ system=`grep "$spanno:" "$attr_file"`
+ if [ "$config" != "$system" ]; then
+
+ active_val=`echo $system | cut -d: -f2`
+ echo "$devname $spanno $val $active_val" >>"$compare_results_file"
+ fi
+ else
+ echo "$spanno:$val" > "$attr_file"
+ fi
fi
fi
done
}
set_all_devices() {
+ span_differs='false'
+ SPANS_DIFFER='false'
+
if [ ! -f "$DAHDISPANTYPESCONF" ]; then
echo >&2 "$0: Missing configuration '$DAHDISPANTYPESCONF'"
exit 1
@@ -348,6 +364,16 @@ set_all_devices() {
esac
done
done
+ if [ "$compare" = 'true' ]; then
+ if [ -s "$compare_results_file" ]; then
+ echo "# Device Unit Config Active"
+ cat "$compare_results_file"
+ rm -f "$compare_results_file"
+ exit 5
+ fi
+ rm -f "$compare_results_file"
+ exit 0
+ fi
}
case "$action" in
@@ -360,6 +386,11 @@ dumpconfig)
set)
set_all_devices
;;
+compare)
+ compare=true
+ compare_results_file=`mktemp`
+ set_all_devices
+ ;;
*)
usage
;;
diff --git a/doc/dahdi_span_types.8 b/doc/dahdi_span_types.8
index 4aba1a9..2bdd9ed 100644
--- a/doc/dahdi_span_types.8
+++ b/doc/dahdi_span_types.8
@@ -4,7 +4,7 @@
dahdi_span_types \- set line modes of DAHDI spans before assignment
.SH SYNOPSIS
-.B dahdi_span_types [\fIoptions\fB] <list|dumpconfig|set> \fB[\fIdevpath \fB...]
+.B dahdi_span_types [\fIoptions\fB] <list|dumpconfig|compare|set> \fB[\fIdevpath \fB...]
.SH DESCRIPTION
The span type (the line mode: E1/T1/J1) must be set to a span before
@@ -58,6 +58,16 @@ device(s) specified in the command line (or all devices, if none
specified).
.RE
+.B compare
+.RS
+Compare the settings on the system to those in the configuration file.
+For each line that applies to a device on the system, print it if the
+value to be set and the active value on the system differ.
+
+The exit status is 0 if there is no difference and non-zero if a
+difference was detected.
+.RE
+
.B list
.RS
List line modes for all spans in the system which may be set with
commit 55679791b5de18a074c57999e5097af50cdd7ae3
Author: Tzafrir Cohen <tzafrir at debian.org>
Date: Wed Jan 25 17:55:30 2017 +0200
xpp_fxloader: Also look for udevadm in /bin
* udevadm is being moved to /bin. /sbin/udevadm will remain as a
compatibility symlink.
* xpp_fxloader should also look for /bin/udevadm in addition to
/sbin/udevadm and /sbin/udevsettle
* Reverse the order: look for newer ones first.
Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
diff --git a/xpp/astribank_hook b/xpp/astribank_hook
index fdfa82a..3b5a6fb 100755
--- a/xpp/astribank_hook
+++ b/xpp/astribank_hook
@@ -94,22 +94,27 @@ wait_for_udev() {
UDEV_SETTLE_MAX_TIME=10
echo "Waiting for udev to settle down..."
- if [ -x /sbin/udevsettle ]; then
- # Old system, stand-alone udevsettle command
- /sbin/udevsettle --timeout="$UDEV_SETTLE_MAX_TIME"
+ udevsettle_cmd=
+ if [ -x /bin/udevadm ]; then
+ udevsettle_cmd="/bin/udevadm settle"
elif [ -x /sbin/udevadm ]; then
- # Assume modern system, udevadm has settle parameter
- if ! /sbin/udevadm settle --timeout="$UDEV_SETTLE_MAX_TIME"
- then
- echo "udevadm failed ($?)."
- echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
- sleep "$UDEV_SETTLE_MAX_TIME"
- fi
+ udevsettle_cmd="/sbin/udevadm settle"
+ elif [ -x /sbin/udevsettle ]; then
+ udevsettle_cmd="/sbin/udevsettle"
else
echo "No udevsettle/udevadm."
echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
sleep "$UDEV_SETTLE_MAX_TIME"
+ return
+ fi
+
+ if ! $udevsettle_cmd --timeout="$UDEV_SETTLE_MAX_TIME"
+ then
+ echo "udevadm failed ($?)."
+ echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
+ sleep "$UDEV_SETTLE_MAX_TIME"
fi
+
sleep 1 # Wait a bit more (races)
}
-----------------------------------------------------------------------
--
dahdi/tools.git
More information about the dahdi-commits
mailing list