[dahdi-commits] tzafrir: branch tools/tzafrir/sysfs r8694 - in /tools/team/tzafrir/sysfs: ./ ...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Wed May 26 13:01:18 CDT 2010


Author: tzafrir
Date: Wed May 26 13:01:16 2010
New Revision: 8694

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8694
Log:
Remove Dahdi::Pool

* Totally remove Pool concept. Only use span+chan identifiers for everything
* Span identifiers can be (by priority):
  - An alias (from /etc/dahdi/hardware_aliases)
  - A Hardware_ID
  - A location
* The /usr/share/dahdi/symlink_span script:
  - documentation
  - log to syslog
  - Environment: $dahdiconfdir (to be set from driver)
  - Environment: Source $dahdiconfdir/init.conf
* Add a hardware_aliases sample file

Added:
    tools/team/tzafrir/sysfs/xpp/hardware_aliases   (with props)
Removed:
    tools/team/tzafrir/sysfs/xpp/chan_pools.sample
    tools/team/tzafrir/sysfs/xpp/dahdi_pools
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Pool.pm
Modified:
    tools/team/tzafrir/sysfs/Makefile
    tools/team/tzafrir/sysfs/xpp/Makefile
    tools/team/tzafrir/sysfs/xpp/dahdi_spanmap
    tools/team/tzafrir/sysfs/xpp/lsdahdi
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Chans.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/System.pm
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
    tools/team/tzafrir/sysfs/xpp/symlink_span

Modified: tools/team/tzafrir/sysfs/Makefile
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/Makefile?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/Makefile (original)
+++ tools/team/tzafrir/sysfs/Makefile Wed May 26 13:01:16 2010
@@ -195,9 +195,6 @@
 docs: $(GENERATED_DOCS)
 
 genconf_parameters.sample: xpp/genconf_parameters
-	cp $< $@
-
-chan_pools.sample: xpp/chan_pools
 	cp $< $@
 
 README.html: README system.conf.asciidoc init.conf.asciidoc tonezones.txt \

Modified: tools/team/tzafrir/sysfs/xpp/Makefile
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/Makefile?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/Makefile (original)
+++ tools/team/tzafrir/sysfs/xpp/Makefile Wed May 26 13:01:16 2010
@@ -49,7 +49,6 @@
 		xpp_blink	\
 		dahdi_genconf	\
 		dahdi_hardware	\
-		dahdi_pools	\
 		dahdi_spanmap	\
 		twinstar	\
 		#

Modified: tools/team/tzafrir/sysfs/xpp/dahdi_spanmap
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/dahdi_spanmap?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/dahdi_spanmap (original)
+++ tools/team/tzafrir/sysfs/xpp/dahdi_spanmap Wed May 26 13:01:16 2010
@@ -14,7 +14,6 @@
 
 use Dahdi;
 use Dahdi::Span;
-use Dahdi::Pool;
 use Dahdi::Xpp;
 use Dahdi::Xpp::Xbus;
 use Dahdi::Hardware;
@@ -31,12 +30,15 @@
 my @devices = Dahdi::Hardware->device_list;
 my @spans = Dahdi::spans;
 
-my $format = "%-3s %-20s %-25s %-18s %-10s %s\n";
+my $format = "%-3s %-18s %-15s %-18s %-25s %-10s %s\n";
 
-printf $format, "#", "Name", "Location", "Hardware ID", "Span ID", "Type";
+printf $format, "#", "Name", "Alias", "Hardware ID", "Location", "Span ID", "Type";
 foreach my $span (sort { $a->num <=> $b->num } @spans) {
+	my $alias = $span->alias || '-';
+	my $hardware_id = $span->hardware_id || '-';
+	my $location = $span->location || '-';
 	printf $format,
-		(0+$span->num), $span->name, $span->location, $span->hardware_id,
+		(0+$span->num), $span->name, $alias, $hardware_id, $location,
 		$span->span_id, $span->spantype;
 }
 

Added: tools/team/tzafrir/sysfs/xpp/hardware_aliases
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/hardware_aliases?view=auto&rev=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/hardware_aliases (added)
+++ tools/team/tzafrir/sysfs/xpp/hardware_aliases Wed May 26 13:01:16 2010
@@ -1,0 +1,11 @@
+#
+# /etc/dahdi/hardware_aliases:
+#  Maps hardware_id or location into a symbolic name
+# Used by /usr/share/dahdi/symlink_span to create friendlier
+# symbolic links in /dev/dahdi/span-names. These names can
+# than be used in /etc/dahdy/system.conf as well
+# as /etc/asterisk/chan_dahdi.conf
+#
+# Name		Hardware_ID or Location
+QA-10		usb_INT01201
+old_bri		@usb-0000_00_03.3-6

Propchange: tools/team/tzafrir/sysfs/xpp/hardware_aliases
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/team/tzafrir/sysfs/xpp/hardware_aliases
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/team/tzafrir/sysfs/xpp/hardware_aliases
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: tools/team/tzafrir/sysfs/xpp/lsdahdi
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/lsdahdi?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/lsdahdi (original)
+++ tools/team/tzafrir/sysfs/xpp/lsdahdi Wed May 26 13:01:16 2010
@@ -29,6 +29,7 @@
 	my $xpd = Dahdi::Xpp::xpd_of_span($span);
 	my @lines;
 	my $index = 0;
+	my $unique_string = $span->unique_string;
 
 	@lines = @{$xpd->lines} if defined $xpd;
 	printf "### Span %2d: %s %s\n", $span->num, $span->name, $span->description;
@@ -44,7 +45,7 @@
 		my $alarm_str = join(" ", @alarms);
 		my $chanstr;
 		if($opts{'p'}) {
-			$chanstr = sprintf "%3d %-15s", $chan->num, $chan->poolstr;
+			$chanstr = sprintf "%3d %-25s", $chan->num, $span->range_string_channels($chan);
 		} else {
 			$chanstr = sprintf "%3d", $chan->num;
 		}

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Chans.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Chans.pm?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Chans.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Chans.pm Wed May 26 13:01:16 2010
@@ -9,7 +9,6 @@
 #
 use strict;
 use Dahdi::Utils;
-use Dahdi::Pool;
 
 =head1 NAME
 
@@ -174,12 +173,6 @@
 	return $type;
 }
 
-sub poolstr() {
-	my $chan = shift || die;
-	my $span = $chan->span;
-	return $span->map_channel_range($chan);
-}
-
 sub new($$$) {
 	my $pack = shift or die "Wasn't called as a class method\n";
 	my $span = shift or die "Missing a span parameter\n";

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen.pm?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen.pm Wed May 26 13:01:16 2010
@@ -47,7 +47,6 @@
 @EXPORT_OK = qw(is_true);
 
 use strict;
-use Dahdi::Pool;
 use Dahdi::Utils;
 
 # Parse values as true/false 

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm Wed May 26 13:01:16 2010
@@ -2,9 +2,6 @@
 use strict;
 
 use Dahdi::Config::Gen qw(is_true);
-use Dahdi::Pool;
-
-my @pools = Dahdi::Pool->get_pools;
 
 sub new($$$) {
 	my $pack = shift || die;
@@ -39,11 +36,6 @@
 			print "$arg =\n";
 		}
 	}
-}
-
-sub has_pool($) {
-	my $span = shift || die;
-	return defined $span->subdir && $span->subdir;
 }
 
 sub gen_openr2($$$) {
@@ -109,7 +101,7 @@
 		$sig = 'em_e1' if $span->proto eq 'E1';
 	}
 	my @to_reset = qw/context group/;
-	my $chans = Dahdi::Config::Gen::chan_range($span->chans());
+	my $chans = $span->range_string_channels($span->chans());
 	$group .= "," . (10 + $num);	# Invent unique group per span
 	printf "group=$group\n";
 	printf "context=$context\n";
@@ -161,7 +153,6 @@
 	my $self = shift || die;
 	my $chan = shift || die;
 	my $span = $chan->span;
-	my $relative_numbers = has_pool($chan->span);
 	my $gconfig = $self->{GCONFIG};
 	my $type = $chan->type;
 	my $num = $chan->num;
@@ -176,7 +167,7 @@
 	die "missing default_chan_dahdi_signalling for chan #$num type $type" unless $sig;
 	die "missing context for chan #$num type $type" unless $context;
 	my $caller_id;
-	my $pos = $chan->poolstr;
+	my $pos = $span->range_string_channels($chan);
 	if(defined $pos) {
 		$caller_id = sprintf "\"Channel %s\" <%04d>", $pos, $exten;
 	} else {
@@ -242,11 +233,6 @@
 HEAD
 	foreach my $span (@spans) {
 		printf "; Span %d: %s %s\n", $span->num, $span->name, $span->description;
-		my $subdir = undef;
-		if(has_pool($span)) {
-			$subdir = $span->subdir;
-			printf "subdir = %s\n", $subdir;
-		}
 		if($span->is_digital) {
 			if($span->is_pri) {
 				if($gconfig->{'pri_connection_type'} eq 'R2') {
@@ -273,7 +259,6 @@
 				$self->gen_channel($chan);
 			}
 		}
-		print "subdir=\n" if defined $subdir;
 		print "\n";
 	}
 	close F;

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/System.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/System.pm?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/System.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Config/Gen/System.pm Wed May 26 13:01:16 2010
@@ -2,7 +2,6 @@
 use strict;
 
 use Dahdi::Config::Gen qw(is_true);
-use Dahdi::Pool;
 
 sub new($$$) {
 	my $pack = shift || die;
@@ -90,7 +89,7 @@
 				$sig = 'e&me1' if $proto eq 'E1';
 			}
 			die "unknown default dahdi signalling for chan $num type $type" unless defined $sig;
-			$chan_range = Dahdi::Config::Gen::chan_range($span->chans());
+			$chan_range = $span->range_string_channels($span->chans());
 			printf "%s=%s\n", $sig, $chan_range;
 		}
 	} else {
@@ -188,7 +187,7 @@
 		printf "# channel %s, no module.\n", $chan->fqn;
 		return;
 	}
-	my $num = $span->map_channel_range($chan);
+	my $num = $span->chan_range_string($chan);
 	my $signalling = $gconfig->{'dahdi_signalling'};
 	my $sig = $signalling->{$type} || die "unknown default dahdi signalling for chan $num type $type";
 	if ($type eq 'IN') {
@@ -224,7 +223,7 @@
 #
 HEAD
 	foreach my $span (@spans) {
-		printf "# Span %d: %s %s\n", $span->num, $span->name, $span->description;
+		printf "# Span %d: '%s' %s %s\n", $span->num, $span->unique_string, $span->name, $span->description;
 		if($span->is_digital) {
 			if($span->is_pri) {
 				if($gconfig->{'pri_connection_type'} eq 'CAS') {

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm Wed May 26 13:01:16 2010
@@ -10,7 +10,6 @@
 use strict;
 use Dahdi;
 use Dahdi::Utils;
-use Dahdi::Pool;
 use Dahdi::Chans;
 use Dahdi::Xpp::Xpd;
 
@@ -177,61 +176,29 @@
 
 # Generate channel range strings from chan objects
 # E.g: "63-77,79-93"
-sub chan_range(@) {
-	my @chans = sort { $a->num <=> $b->num } @_;
-	my @channos = map { $_->num } @chans;
-	return Dahdi::Utils::channo_range(@channos);
-}
-
-# Generate channel range strings from digital span objects
-# E.g: "63-77,79-93"
-# This also support pool prefixes:
-# E.g: "Lab1!63-77,79-93"
-sub map_channel_range(@) {
-	my $span = shift || die;
-	my @poolchans = @_;
-	my @chans;
-	my $poolname;
-	my $chans_str;
-	foreach my $chan (@poolchans) {
-		my $poolidx;
-		my $pe = Dahdi::Pool->chan2poolentry($chan);
-		if(defined $pe) {
-			my $pool = $pe->{POOL};
-			if(! defined $poolname) {
-				die "$0: No poolname for " . $chan->fqn . "" unless $pool->{NAME};
-				$poolname = $pool->{NAME};
-				$chans_str = sprintf "%s!", $pool->{POOLSTR};
-			} elsif($poolname ne $pool->{NAME}) {
-				die "$0: Mixed pools in a span: was '$poolname', now '$pool->{NAME}'"
-			}
-			$poolidx = $pe->{POOLIDX};
-			push(@chans, $poolidx);
-		} elsif (defined $poolname) {
-			die "$0: Non-pool channel (" . $chan->fqn . ") while inside '$poolname'";
-		} else {
-			push(@chans, $chan->num);
-		}
-	}
-	$chans_str .= join(',', @chans);
-	#printf STDERR "map_channel_range(%s)>>>\t $chans_str\n", $span->name;
-	return $chans_str;
+# This is normally called via bchan_range() or dchan_string()
+sub range_string_channels() {
+	my $span = shift || die;
+	my @chans = @_;
+	my $unique_string = $span->unique_string;
+	my @index = map { $_->index } @chans;
+	my $channels_string = Dahdi::Utils::channo_range(@index);
+	my $str = $unique_string . '!' . $channels_string;
+	return $str;
 }
 
 sub bchan_range() {
 	my $span = shift || die;
 	die unless $span->is_digital();
 	my @chans = $span->bchans();
-	my $str = $span->map_channel_range(@chans);
-	return $str;
+	return $span->range_string_channels(@chans);
 }
 
 sub dchan_string() {
 	my $span = shift || die;
 	die unless $span->is_digital();
 	my @chans = $span->dchan();
-	my $str = $span->map_channel_range(@chans);
-	return $str;
+	return $span->range_string_channels(@chans);
 }
 
 my @bri_strings = (
@@ -296,9 +263,47 @@
 	my $span = shift || die;
 	my $location;
 	$location = $span->_get_dev_attr('location');
-	$location =~ tr/a-zA-Z0-9.!:-/_/c;	# Cleanup
+	$location =~ tr/@a-zA-Z0-9.!-/_/c;	# Cleanup
 	$location =~ s/^/@/;			# Add prefix
 	$span->{LOCATION} = $location;
+}
+
+sub set_hardware_id() {
+	my $span = shift || die;
+	my $hardware_id;
+	$hardware_id = $span->_get_dev_attr('hardware_id');
+	$hardware_id =~ tr/@a-zA-Z0-9.!_-/_/c;	# Cleanup
+	$span->{HARDWARE_ID} = $hardware_id;
+}
+
+sub set_span_id() {
+	my $span = shift || die;
+	my $span_id;
+	$span_id = $span->_get_dev_attr('span_id');
+	$span->{SPAN_ID} = $span_id;
+}
+
+sub set_span_alias() {
+	my $span = shift || die;
+	my $span_num = $span->num;
+	my $hardware_id = $span->hardware_id;
+	my $location = $span->location;
+	my $name_base = '/dev/dahdi/span-names';
+	my @names = glob "$name_base/*";
+	$span->{ALIAS} = '';
+	foreach my $n (@names) {
+		next unless -l $n;
+		my $l = readlink $n;
+		$n =~ s|$name_base/?||;
+		$n =~ s|\(\d+\)$||;
+		next if $hardware_id && $n =~ /^\Q$hardware_id\E/;
+		next if $location && $n =~ /^\Q$location\E.*/;
+		$l =~ s|/dev/dahdi/spans/0*||;
+		if ($l == $span_num) {
+			$span->{ALIAS} = $n;
+			#print STDERR "DEBUG($span_num): '$n'\t-> '$l'\n";
+		}
+	}
 }
 
 # TYPE
@@ -319,6 +324,9 @@
 		$self->{XPD} = $xpd;
 	}
 	$self->set_location;
+	$self->set_hardware_id;
+	$self->set_span_id;
+	$self->set_span_alias;
 	$self->{IS_DIGITAL} = $self->_get_dev_attr('is_digital');
 	$self->{IS_DAHDI_SYNC_MASTER} = $self->_get_dev_attr('is_sync_master');
 	$self->{NAME} = $self->_get_dev_attr('name');
@@ -332,11 +340,10 @@
 	$self->{MANUFACTURER} = $self->_get_dev_attr('manufacturer');
 	# FIXME: the following is a number, rather than a readable value:
 	$self->{ALARMS} = $self->_get_dev_attr('alarms');
-	$self->{HARDWARE_ID} = $self->_get_dev_attr('hardware_id');
-	$self->{SPAN_ID} = $self->_get_dev_attr('span_id');
-	my $hwname = $self->{HARDWARE_ID} || $self->{LOCATION};
+	my $hwname = $self->alias || $self->hardware_id || $self->location;
 	if (defined $hwname) {
-		$self->{UNIQUE_STRING} = sprintf "span-names/%s(%s)", $hwname, $self->{SPAN_ID};
+		my $unique_string = sprintf "span-names!%s(%s)", $hwname, $self->{SPAN_ID};
+		$self->{UNIQUE_STRING} = $unique_string;
 	} else {
 		$self->{UNIQUE_STRING} = $num;
 	}
@@ -559,5 +566,4 @@
 	$span->set_termtype($match_termtype);
 }
 
-
 1;

Modified: tools/team/tzafrir/sysfs/xpp/symlink_span
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/symlink_span?view=diff&rev=8694&r1=8693&r2=8694
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/symlink_span (original)
+++ tools/team/tzafrir/sysfs/xpp/symlink_span Wed May 26 13:01:16 2010
@@ -1,60 +1,109 @@
 #! /bin/sh
+#
+# /usr/share/dahdi/symlink_span
+#
+# Called by UDEV when a span goes online/offline to create
+# symbolic links under /dev/dahdi/span-names.
+# The following names are generated (if available):
+#   - /dev/dahdi/span-names/<hardware_id>(<span_id>)
+#   - /dev/dahdi/span-names/<location>(<span_id>)
+#   - /dev/dahdi/span-names/<alias>(<span_id>)
+#
+# Alias names are defined in /etc/dahdi/hardware_aliases
+
+me=`basename $0`
+dir=`dirname $0`
+LOGGER="logger -i -t '$me'"
+
+exec 2> /dev/null
+# 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/console
+## If you wish to trace this script:
+#exec 2> "/tmp/${me}" 1>&2
+
+# Our directory in the beginning, so we can use local lab setup
+PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
 
 set -e
 
-#exec 2> /tmp/dahdi-symlinks-$$.stderr
-#env 1>&2
+dahdiconfdir=${dahdiconfdir:-/etc/dahdi}
+initfile="$dahdiconfdir/init.conf"
 
-SPANMAP="/dev/dahdi/span-names"
+
+[ -r "$initfile" ] && . "$initfile"
+
+SPANNAMES="/dev/dahdi/span-names"
 LINK_DEST="/dev/dahdi/spans/${SPAN_NUM}"
+ALIASES_FILE='/etc/dahdi/hardware_aliases'
+
+span_alias() {
+	if [ -r "$ALIASES_FILE" ]; then
+		awk -v span="$1" '$2 ~ span { print $1 }' "$ALIASES_FILE" 2> /dev/null
+	fi
+}
 
 create_links() {
-	mkdir -p "$SPANMAP"
+	mkdir -p "$SPANNAMES"
 
-	SPAN_ID=`cat "/sys${DEVPATH}/span_id" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'`
+	SPAN_ID=`cat "/sys${DEVPATH}/span_id" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/.-' '_'`
 	if [ "$SPAN_ID" == '' ]; then
 		echo >&2 "$0: Missing span_id attribute for '$DEVPATH'"
 		exit 1
 	fi
-	LOCATION=`cat "/sys${DEVPATH}/location" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'`
+	ALIAS=''
+	HARDWARE_ID=`cat "/sys${DEVPATH}/hardware_id" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/.-' '_'`
+	if [ "$HARDWARE_ID" != '' ]; then
+		LINK="${SPANNAMES}/${HARDWARE_ID}($SPAN_ID)"
+		#echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
+		ln -s "$LINK_DEST" "$LINK" 1>&2
+		ALIAS=`span_alias "$HARDWARE_ID"`
+	else
+		echo >&2 "$0: Missing hardware_id attribute for '$DEVPATH'"
+	fi
+	LOCATION=`cat "/sys${DEVPATH}/location" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/.-' '_'`
 	if [ "$LOCATION" != '' ]; then
-		LINK="${SPANMAP}/@${LOCATION}($SPAN_ID)"
-		echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
+		LINK="${SPANNAMES}/@${LOCATION}($SPAN_ID)"
+		#echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
 		ln -s "$LINK_DEST" "$LINK" 1>&2
+		if [ "$ALIAS" = '' ]; then
+			ALIAS=`span_alias "$LOCATION"`
+		fi
 	else
 		echo >&2 "$0: Missing location attribute for '$DEVPATH'"
 	fi
-	HARDWARE_ID=`cat "/sys${DEVPATH}/hardware_id" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'`
-	if [ "$HARDWARE_ID" != '' ]; then
-		LINK="${SPANMAP}/${HARDWARE_ID}($SPAN_ID)"
-		echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
-		ln -s "$LINK_DEST" "$LINK" 1>&2
-	else
-		echo >&2 "$0: Missing hardware_port attribute for '$DEVPATH'"
+	if [ "$ALIAS" != '' ]; then
+		ALIAS="${SPANNAMES}/$ALIAS($SPAN_ID)"
+		#echo "$0: alias: '$ALIAS'" 1>&2
+		ln -s "$LINK_DEST" "$ALIAS" 1>&2
 	fi
 }
 
 remove_links() {
-	for i in "$SPANMAP/"*
+	for i in "$SPANNAMES/"*
 	do
 		if [ -L "$i" ]; then
 			LINK_DEST=`readlink "$i"`
 			REAL_SPAN_NUM=`echo "$DEVPATH" | sed 's/.*-//'`
 			if [ "$LINK_DEST" = "/dev/dahdi/spans/$REAL_SPAN_NUM" ]; then
-				echo >&2 "$0: Removing '$i'"
+				#echo >&2 "$0: Removing '$i'"
 				rm -f "$i" 1>&2
 			fi
 		fi
 	done
-	echo "$0: Try to remove '$SPANMAP'"
-	rmdir "$SPANMAP" 1>&2
+	#echo "$0: Try to remove '$SPANNAMES'"
+	rmdir "$SPANNAMES" 1>&2
 }
 
 case "$ACTION" in
 online)
-	create_links
+	(
+		create_links
+		dahdi_cfg -k -c "$dahdiconfdir/system.conf"
+	) 2>&1 | $LOGGER
 	;;
 offline)
-	remove_links
+	remove_links 2>&1 | $LOGGER
 	;;
 esac




More information about the dahdi-commits mailing list