Update the configure script as well.
[dahdi/tools.git] / dahdi_map
1 #! /bin/sh
2 #
3 # Show a map of dahdi devices with the following fields:
4 #  - spanno (or '-' if not assigned yet)
5 #  - (vendor assigned) name
6 #  - local spanno
7 #  - hardware_id (or empty if none)
8 #  - location (prefixed by '@')
9
10 devbase="/sys/bus/dahdi_devices/devices"
11
12 [ -d "$devbase" ] || {
13         echo >&2 "$0: Missing '$devbase' (Old driver?)"
14         exit 1
15 }
16
17 fmt="%-4s %-17s %-3s     %-12s %s\n"
18
19 printf "$fmt" 'SPAN' 'NAME' '#' 'HARDWARE_ID' 'LOCATION'
20
21 DEVICES=`echo $devbase/*`
22
23 for device in $DEVICES
24 do
25         hw_id=`cat "$device/hardware_id"`
26         location=`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
27         for local_spanno in `cut -d: -f1 "$device/spantype"`
28         do
29                 span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
30                         sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
31                 if [ "$span" != '' ]; then
32                         spanno=`echo $span | sed 's/^.*-//'`
33                         name=`cat 2>/dev/null "$device/$span/name"`
34                 else
35                         spanno='-'
36                 fi
37                 printf "$fmt" "$spanno" "$name" "($local_spanno)" "[$hw_id]" "@$location"
38         done | sort -n
39 done