[svn-commits] tzafrir: branch linux/tzafrir/sysfs r5980 - in /linux/team/tzafrir/sysfs: ./ ...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Feb 4 19:15:36 CST 2009
Author: tzafrir
Date: Wed Feb 4 19:15:36 2009
New Revision: 5980
URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=5980
Log:
Span auto-configuration: supporting scripts
We already have a udev event when a span is ready. Let's use it.
Provide udev rule and a script to be run when a new span is available
to configure it: simply run dahdi_cfg, or try generating DAHDI
configuration for the span.
Added:
linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample (with props)
Modified:
linux/team/tzafrir/sysfs/README
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp.rules
Modified: linux/team/tzafrir/sysfs/README
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/README?view=diff&rev=5980&r1=5979&r2=5980
==============================================================================
--- linux/team/tzafrir/sysfs/README (original)
+++ linux/team/tzafrir/sysfs/README Wed Feb 4 19:15:36 2009
@@ -343,6 +343,33 @@
generated, and ditto for spans.
+Automatic Configuration
+~~~~~~~~~~~~~~~~~~~~~~~
+When a span is ready, a udev event will be sent from the kernel (with
+action 'online'. Note that 'add' is sent a bit before that and before
+the span is ready. Likewise are 'offline' and 'remove'.
+
+Thus when 'online' is sent, the span is ready for configuration.
+The file drivers/dahdi/span_hook.sample demonstrates how to use it to
+get a more dynamic DAHDI configuration:
+
+It will run dahdi_cfg if it finds /etc/dahdi/sysetm.conf .
+Otherwise it will try:
+
+* If there is a file with partial system.conf for the span (using the
+ name of the span) it will run dahdi_cfg for that file alone. TODO: I
+ still need to implement some basic templating there. e.g. repalce
+ @NN@ with the index of the channel in the span (channo).
+* If all else fails, it will generate a partial system.conf for that
+ span and configure it through dahdi_cfg .
+
+
+NOTE: The device files under /dev/dahdi are generated by a separate
+udev event. Normally /dev/dahdi/ctl would alerady be generated by the
+time the 'online' event for a span is sent. However this is not fully
+guaranteed. In such a "bad" case, modprobe dahdi in advance.
+
+
PROCFS Interface: /proc/dahdi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A simple way to get the current list of spans and channels each span contains
Added: linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample?view=auto&rev=5980
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample (added)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample Wed Feb 4 19:15:36 2009
@@ -1,0 +1,58 @@
+#! /bin/sh
+
+# For tracing:
+#exec 2>/tmp/span_trace.$$
+#set -x
+
+me=`basename $0`
+LOGGER="logger -i -t '$me'"
+
+# FIXME: The following are needed in order to run the hook from the
+# "live" environment
+#BASEDIR=/usr/src/dahdi-linux/live
+#PATH="$BASEDIR/usr/sbin:$PATH"
+#export PATH
+# This is for Debian. See live_dahdi:
+#PERL5LIB="$BASEDIR/usr/local/share/perl/5.10.0"
+#export PERL5LIB
+
+
+set -e
+
+echo "starting($ACTION): '$*'" | $LOGGER
+
+case "$ACTION" in
+add)
+ span_name=`echo $SPAN_NAME | tr / _`
+ span_conf=/etc/dahdi/span-$span_name.conf
+ if [ -r /etc/dahdi/system.conf ]; then
+ dahdi_cfg
+ elif [ -r "$span_conf" ]; then
+ # TODO: implement pattern matching here to make this case useful
+ dahdi_cfg -c "$span_conf"
+ else
+ dev_file="/sys/$DEVPATH"
+ tmpfile=`mktemp dahdi_span_XXXXXX`
+
+ # Generate a temporary configuration file for this span:
+ DAHDI_CONF_FILE="$tmpfile" dahdi_genconf "$dev_file" dahdi
+ dahdi_cfg -c "$tmpfile"
+
+ #cat $tmpfile >&2
+ rm "$tmpfile"
+ fi
+ ;;
+remove)
+ ;;
+online)
+ ;;
+offline)
+ ;;
+*)
+ echo "$0: Unknown ACTION='$ACTION'" | $LOGGER
+ echo "$0: ARGS='$*'" | $LOGGER
+ echo "$0: ENV:" | $LOGGER
+ env | $LOGGER
+ exit 1
+esac
+
Propchange: linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample
------------------------------------------------------------------------------
svn:executable = *
Propchange: linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: linux/team/tzafrir/sysfs/drivers/dahdi/span_hook.sample
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp.rules
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp.rules?view=diff&rev=5980&r1=5979&r2=5980
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp.rules (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp.rules Wed Feb 4 19:15:36 2009
@@ -14,3 +14,7 @@
#
# By default XPP_INIT_DIR="/usr/share/dahdi"
#KERNEL=="xbus*" RUN+="%E{XPP_INIT_DIR}/astribank_hook udev $kernel $sysfs{status} $sysfs{connector}"
+
+# Likewise, a hook script to be run when a span is ready
+# FIXME: move this line to a different file.
+#KERNEL=="span*" RUN+="%E{DAHDI_INIT_DIR}/span_hook udev $kernel $sysfs{status} $sysfs{connector}"
More information about the svn-commits
mailing list