dahdi-linux/dahdi_map
Oron Peled 79fff3e278 basic user-space for pinned-spans
handle_device is the basic script intended to be called from udev.

It will call span_types on the span to apply optional
/etc/dahdi/spantype.conf onfiguration settings that need to be applied
before assignment (currently "pri" port types: E1/T1/J1).

Next it assigns span numbers to spans: if configured in
/etc/dahdi/pinned-spans.conf - use those settings. If not: by the order
of loading.

span_types and span_assignments can also be used to report the settings
they are used to configure.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-05-24 16:58:15 -05:00

40 lines
1021 B
Bash
Executable File

#! /bin/sh
#
# Show a map of dahdi devices with the following fields:
# - spanno (or '-' if not assigned yet)
# - (vendor assigned) name
# - local spanno
# - hardware_id (or empty if none)
# - location (prefixed by '@')
devbase="/sys/bus/dahdi_devices/devices"
[ -d "$devbase" ] || {
echo >&2 "$0: Missing '$devbase' (Old driver?)"
exit 1
}
fmt="%-4s %-17s %-3s %-12s %s\n"
printf "$fmt" 'SPAN' 'NAME' '#' 'HARDWARE_ID' 'LOCATION'
DEVICES=`echo $devbase/*`
for device in $DEVICES
do
hw_id=`cat "$device/hardware_id"`
location=`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
for local_spanno in `cut -d: -f1 "$device/spantype"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
if [ "$span" != '' ]; then
spanno=`echo $span | sed 's/^.*-//'`
name=`cat 2>/dev/null "$device/$span/name"`
else
spanno='-'
fi
printf "$fmt" "$spanno" "$name" "($local_spanno)" "[$hw_id]" "@$location"
done | sort -n
done