00af777a97
A newer version of the scripts fully adapted to pinned spans: * handle_device does not run dahdi_cfg. * A separate UDEV rule script for that: span_config. Should also work for the non-pinned case. * span_assignments, span_types: add actions 'auto' (manually enable all) and 'dumpconfig' (dump current status in the format of configuration file). * Fixed name of span_types and span_assignments (no '-'). * spantype.conf renamed span-types.conf: configuration files do have a dash. * Those two are useful programs, insstalled to /usr/sbin. Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
64 lines
1.6 KiB
Bash
Executable File
64 lines
1.6 KiB
Bash
Executable File
#! /bin/sh
|
|
#
|
|
# /usr/share/dahdi/handle_device
|
|
#
|
|
# Called by UDEV when a dahdi device is added/removed
|
|
#
|
|
|
|
me=`basename $0`
|
|
dir=`dirname $0`
|
|
LOGGER="logger -i -t '$me'"
|
|
NAME=`basename "$DEVPATH" | tr -c 'A-Za-z0-9-' '_'`
|
|
|
|
# Always redirect stderr somewhere, otherwise the shell script will die
|
|
# when it tries to do I/O related stuff on closed file descriptor.
|
|
# Our default is to throw it down the bit-bucket.
|
|
exec 2> /dev/null
|
|
# If you wish to trace this script:
|
|
#exec 2> "/tmp/${me}.$NAME" 1>&2
|
|
#exec 2> /dev/console
|
|
|
|
# Our directory in the beginning, so we can use local lab setup
|
|
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
|
|
|
set -e
|
|
|
|
#echo >&2 "$0($ACTION): DEBUG($# args): '$*'"
|
|
|
|
# Check if we can safely do our job
|
|
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
|
echo "Old driver (no auto_assign_spans parameter). Skip $DEVPATH" | $LOGGER
|
|
exit 0
|
|
fi
|
|
if [ `cat /sys/module/dahdi/parameters/auto_assign_spans` -eq 1 ]; then
|
|
echo "auto_assign_spans=1. Skip $DEVPATH" | $LOGGER
|
|
exit 0
|
|
fi
|
|
|
|
# Can we pass a different value so we can use
|
|
# alternate (testing) configuration?
|
|
# Meanwhile, make it hard-coded.
|
|
DAHDICONFDIR='/etc/dahdi'
|
|
export DAHDICONFDIR
|
|
|
|
case "$ACTION" in
|
|
add)
|
|
echo "$ACTION: $DEVPATH" | $LOGGER
|
|
# Can have alternate dahdi configuration directory for debugging
|
|
# export DAHDICONFDIR="/tmp/xortel/dahdi"
|
|
|
|
# Don't block udev for too long
|
|
(
|
|
span_types set "/sys$DEVPATH"
|
|
span_assignments add "/sys$DEVPATH"
|
|
) 2>&1 < /dev/null | $LOGGER &
|
|
;;
|
|
remove)
|
|
# Nothing to do yet...
|
|
echo "$ACTION: $DEVPATH" | $LOGGER
|
|
;;
|
|
*)
|
|
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
|
|
;;
|
|
esac
|