[svn-commits] tzafrir: branch tools/2.2 r7477 - in /tools/branches/2.2: ./ xpp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 4 14:32:29 CST 2009


Author: tzafrir
Date: Wed Nov  4 14:32:25 2009
New Revision: 7477

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7477
Log:
Add optional "hotplug mode" to init scripts

The hotplug mode is only used in XPP_HOTPLUG_DAHDI=yes is set in
/etc/dahdi/init.conf . If it is set and the system actually has
Astribanks, most of the init script will actually be run from the
context of a udev event.

Merged revisions 6987,7014,7334-7335,7409,7476 via svnmerge from 
https://origsvn.digium.com/svn/dahdi/tools/trunk

........
  r6987 | tzafrir | 2009-08-13 18:15:49 +0300 (Thu, 13 Aug 2009) | 9 lines
  
  xpp: Add astribank_is_starting:
  
  astribank_is_running is used to tell when we may have an Astribank that
  is initializing (and may be re-enumerating and thus not listed as a
  device).
  
  It uses a semaphore as we can always write to one and we can't always
  write to a file.
........
  r7014 | tzafrir | 2009-08-16 19:05:11 +0300 (Sun, 16 Aug 2009) | 4 lines
  
  xpp: A man page for astribank_is_starting
  
  xpp rev: 7321
........
  r7334 | tzafrir | 2009-10-04 15:35:51 +0200 (Sun, 04 Oct 2009) | 7 lines
  
  dahdi.init: move module loading to a separate function
  
  Move the module loading parts of the dahdi init script to a seperate
  function - load_modules. To be used by a later commit.
  
  There is not functional change here (but the diff is confusing).
........
  r7335 | tzafrir | 2009-10-04 15:53:01 +0200 (Sun, 04 Oct 2009) | 16 lines
  
  Add XPP_HOTPLUG_DAHDI mode: cfg initiated mostly from hotplug
  
  If XPP_HOTPLUG_DAHDI=yes is set in /etc/dahdi/init.conf (which is not
  the default), the normal run of the 'start' operation of the dahdi init
  script will only be responsible for loading modules. The rest will be
  done (if there are indeed Astribanks on the system) by a second call to
  the init script once all of them have connected.
  
  The astribank_hook has also been mostly rewritten. Most of the
  functionality of twinstar_hook moved to it. The current twinstar_hook is
  a simple example script.
  
  XPP_HOTPLUG_DAHDI mode assumes that all Astribanks on the system are
  listed in /etc/dahdi/xpp_order (which can be generated using, e.g.
  'dahdi_genconf xpporder')
........
  r7409 | tzafrir | 2009-10-21 16:30:32 +0200 (Wed, 21 Oct 2009) | 21 lines
  
  Fix XPP_HOTPLUG_DAHDI: logic; end of init.d script
  
  'Hotplug mode' was introduced in r7335.
  
  * The logic in the script was broken.
    - Negative logic is not such a grand idea to start with.
  * Interactive invocation of init.d ends when expected and not sooner.
  
  This change makes waitfor_xpds wait longer. Rather than waiting for all
  the Astribanks to load, it will now wait until the initialization of
  dahdi from the Astribanks hook script is run.
  
  This allows running e.g.: /etc/init.d/dahdi start; /etc/init.d/asterisk start
  
  It also means that 'astribank_is_starting' is actually used as a
  semaphore and not only as stamp file.
   
  As before, those changes have no effect if hotplug mode is not
  explicitly enabled (setting 'XPP_HOTPLUG_DAHDI=yes' in init.conf).
........
  r7476 | tzafrir | 2009-11-04 22:12:35 +0200 (Wed, 04 Nov 2009) | 6 lines
  
  xpp: make astribank_is_starting build without warnings.
  
  autoconfig.h is needed as semtimedop() requires _GNU_SOURCE.
  
  xpp rev: 7471
........

Added:
    tools/branches/2.2/xpp/astribank_is_starting.8
      - copied, changed from r7014, tools/trunk/xpp/astribank_is_starting.8
    tools/branches/2.2/xpp/astribank_is_starting.c
      - copied, changed from r6987, tools/trunk/xpp/astribank_is_starting.c
Modified:
    tools/branches/2.2/   (props changed)
    tools/branches/2.2/dahdi.init
    tools/branches/2.2/init.conf.sample
    tools/branches/2.2/xpp/Makefile
    tools/branches/2.2/xpp/astribank_hook
    tools/branches/2.2/xpp/twinstar_hook
    tools/branches/2.2/xpp/waitfor_xpds
    tools/branches/2.2/xpp/xpp_fxloader

Propchange: tools/branches/2.2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Nov  4 14:32:25 2009
@@ -1,1 +1,1 @@
-/tools/trunk:1-6678,6823,6829-6830,6832-6833,6835,6837-6886,6889-6982,6985-6986,6988-6992,6994-6998,7000-7011,7013,7015-7042,7044,7046-7131,7133,7135-7136,7139-7217,7220-7251,7254-7255,7257-7262,7264-7332,7336-7408,7410-7460,7462
+/tools/trunk:1-6678,6823,6829-6830,6832-6833,6835,6837-6886,6889-6982,6985-6992,6994-6998,7000-7011,7013-7042,7044,7046-7131,7133,7135-7136,7139-7217,7220-7251,7254-7255,7257-7262,7264-7332,7334-7460,7462,7464-7476

Modified: tools/branches/2.2/dahdi.init
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/dahdi.init?view=diff&rev=7477&r1=7476&r2=7477
==============================================================================
--- tools/branches/2.2/dahdi.init (original)
+++ tools/branches/2.2/dahdi.init Wed Nov  4 14:32:25 2009
@@ -86,10 +86,39 @@
 	rmmod $module
 }
 
+# In (xpp) hotplug mode, the init script is also executed from the
+# hotplug hook. In that case it should not attempt to loade modules.
+#
+# This function only retunrs false (1) if we're in hotplug mode and
+# coming from the hotplug hook script.
+hotplug_should_load_modules() {
+	if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" != '' ]
+	then
+		return 1
+	fi
+	return 0
+}
+
+# In (xpp) hotplug mode: quit after we loaded modules.
+#
+# In hotplug mode, the main run should end here, whereas the rest of the
+# script should be finished by the instance running from the hook.
+# Note that we only get here if there are actually Astribanks on the
+# system (otherwise noone will trigger the run of the hotplug hook
+# script).
+hotplug_exit_after_load() {
+	if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" = '' ]
+	then
+		exit 0
+	fi
+}
+
 # Initialize the Xorcom Astribank (xpp/) using perl utiliites:
 xpp_startup() {
 	# do nothing if there are no astribank devices:
 	if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
+
+	hotplug_exit_after_load
 
 	# overriding locales for the above two, as perl can be noisy
 	# when locales are missing.
@@ -144,21 +173,7 @@
 	$DAHDI_CFG_CMD -s
 }
 
-if [ ! -x "$DAHDI_CFG" ]; then
-       echo "dahdi_cfg not executable"
-       exit 0
-fi
-
-if [ ! -f /etc/dahdi/system.conf ]; then
-	echo "/etc/dahdi/system.conf not found. Nothing to do."
-       exit 0
-fi
-
-RETVAL=0
-
-# See how we were called.
-case "$1" in
-  start)
+load_modules() {
   	# Some systems, e.g. Debian Lenny, add here -b, which will break
 	# loading of modules blacklisted in modprobe.d/*
 	unset MODPROBE_OPTIONS
@@ -181,6 +196,26 @@
 		fi
 	done
 	echo ""
+}
+
+if [ ! -x "$DAHDI_CFG" ]; then
+       echo "dahdi_cfg not executable"
+       exit 0
+fi
+
+if [ ! -f /etc/dahdi/system.conf ]; then
+	echo "/etc/dahdi/system.conf not found. Nothing to do."
+       exit 0
+fi
+
+RETVAL=0
+
+# See how we were called.
+case "$1" in
+  start)
+  	if hotplug_should_load_modules; then
+		load_modules
+	fi
 
 	TMOUT=$DAHDI_DEV_TIMEOUT # max secs to wait
 

Modified: tools/branches/2.2/init.conf.sample
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/init.conf.sample?view=diff&rev=7477&r1=7476&r2=7477
==============================================================================
--- tools/branches/2.2/init.conf.sample (original)
+++ tools/branches/2.2/init.conf.sample Wed Nov  4 14:32:25 2009
@@ -11,3 +11,4 @@
 # Override settings for xpp_fxloader
 #XPP_FIRMWARE_DIR=/usr/share/dahdi
 #XPP_HOTPLUG_DISABLED=yes
+#XPP_HOTPLUG_DAHDI=yes

Modified: tools/branches/2.2/xpp/Makefile
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/Makefile?view=diff&rev=7477&r1=7476&r2=7477
==============================================================================
--- tools/branches/2.2/xpp/Makefile (original)
+++ tools/branches/2.2/xpp/Makefile Wed Nov  4 14:32:25 2009
@@ -65,8 +65,9 @@
 	   astribank_tool	\
 	   astribank_hexload	\
 	   astribank_allow	\
+	   astribank_is_starting	\
 	   test_parse
-PROG_INSTALL	+= fpga_load astribank_tool astribank_hexload astribank_allow
+PROG_INSTALL	+= fpga_load astribank_tool astribank_hexload astribank_allow astribank_is_starting
 endif
 ifneq	(,$(PERLLIBDIR))
 PROG_INSTALL	+= $(PERL_SCRIPTS)
@@ -113,6 +114,9 @@
 astribank_allow: $(ABALLOW_OBJS)
 	$(CC) -L. -o $@ $(ABALLOW_OBJS) $(EXTRA_LIBS) -lusb
 
+astribank_is_starting: astribank_is_starting.o
+	$(CC) -L. -o $@ $^ $(EXTRA_LIBS)
+
 fpga_load.o: CFLAGS+=-D_GNU_SOURCE	# We use memrchr()
 
 test_parse: test_parse.o hexfile.o

Modified: tools/branches/2.2/xpp/astribank_hook
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/astribank_hook?view=diff&rev=7477&r1=7476&r2=7477
==============================================================================
--- tools/branches/2.2/xpp/astribank_hook (original)
+++ tools/branches/2.2/xpp/astribank_hook Wed Nov  4 14:32:25 2009
@@ -11,11 +11,76 @@
 ## If you wish to trace this script:
 #exec 2> "/tmp/${me}_$XBUS_NAME" 1>&2
 
+# Our directory in the beginning, so we can use local lab setup
 PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
 
 set -e
 
-echo "starting($ACTION): '$*'" | $LOGGER
+[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
+
+# For lab testing
+liveconf="$dir/liveconf/dahdi"
+
+if [ -d "$liveconf" ]; then
+	dahdi_conf="$liveconf"
+else
+	dahdi_conf="/etc/dahdi"
+fi
+
+export XPPORDER_CONF="$dahdi_conf/xpp_order"
+if [ ! -r "$XPPORDER_CONF" ]; then
+	(
+		echo "Skip($ACTION): No '$XPPORDER_CONF'"
+		echo "Removing uneeded startup semaphore"
+		astribank_is_starting -v -r 2>&1
+	) 2>&1 | $LOGGER
+	exit 0
+fi
+export DAHDI_CFG_CMD="dahdi_cfg -c $dahdi_conf/system.conf"
+export CALLED_FROM_ATRIBANK_HOOK=yes
+
+clean_lines() {
+	sed -e 's/#.*//' -e 'y/\t/ /' -e 's/^ *//' -e 's/ *$//' "$XPPORDER_CONF"
+}
+
+matched_devices() {
+	ready=`grep -H READY /sys/bus/astribanks/devices/*/xbus_state | sed 's,/xbus_state.*,,'`
+	for dev in $ready
+	do
+		label=`cat "$dev/label"`
+		connector=`cat "$dev/connector"`
+		xbus=`echo "$dev" | sed 's,.*/,,'`
+		lineno=`clean_lines | egrep -n "^${label}$|^@${connector}$" | cut -d: -f1`
+		if [ "$lineno" != "" ]; then
+			#echo "$xbus: $XPPORDER_CONF:$lineno -- Match ${label} @${connector}" | $LOGGER
+			echo -e "${xbus}\t${label}"
+		else
+			echo "${xbus}: ${label} @${connector} not found in $XPPORDER_CONF: Ignore($ACTION)" | $LOGGER
+		fi
+	done
+}
+
+NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
+NUM_GOOD=`matched_devices | wc -l`
+
+start_dahdi() {
+	script=/etc/init.d/dahdi
+	if [ "$XPP_HOTPLUG_DAHDI" = yes ]; then
+		echo "Starting $script."
+		"$script" start | logger -i -t "$script"
+		status=$?
+		echo "Status($script): $status"
+	else
+		echo "$0: Skip($script): No XPP_HOTPLUG_DAHDI=yes in /etc/dahdi/init.conf"
+		exit 0
+	fi
+	if [ -x "$dir/twinstar_hook" ]; then
+		"$dir/twinstar_hook"
+	fi
+	# Finished astribanks
+	echo "Removing semaphore"
+	astribank_is_starting -v -r
+}
 
 case "$ACTION" in
 add)
@@ -23,13 +88,20 @@
 remove)
 	;;
 online)
-	if [ -x "$dir/twinstar_hook" ]; then
-		"$dir/twinstar_hook"
+	echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
+	if [ "$NUM_GOOD" -eq "$NUM_WANTED" ]; then
+		echo "START-DAHDI: Total $NUM_GOOD online." | $LOGGER
+		# Fork services
+		start_dahdi < /dev/null 2>&1 | $LOGGER &
 	fi
 	;;
 offline)
-	if [ -x "$dir/twinstar_hook" ]; then
-		"$dir/twinstar_hook"
+	echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
+	if [ "$NUM_GOOD" -eq 0 ]; then
+		echo "All Astribanks offline" | $LOGGER
+		if [ -x "$dir/twinstar_hook" ]; then
+			"$dir/twinstar_hook"
+		fi
 	fi
 	;;
 *)

Copied: tools/branches/2.2/xpp/astribank_is_starting.8 (from r7014, tools/trunk/xpp/astribank_is_starting.8)
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/astribank_is_starting.8?view=diff&rev=7477&p1=tools/trunk/xpp/astribank_is_starting.8&r1=7014&p2=tools/branches/2.2/xpp/astribank_is_starting.8&r2=7477
==============================================================================
--- tools/trunk/xpp/astribank_is_starting.8 (original)
+++ tools/branches/2.2/xpp/astribank_is_starting.8 Wed Nov  4 14:32:25 2009
@@ -3,9 +3,9 @@
 .SH NAME
 astribank_is_starting \- Mark / check is a Xorcom Astribank (xpp) is starting
 .SH SYNOPSIS
-.B astribank_is_starting [-d] <-a|-r>
+.B astribank_is_starting [-d] [-v] [-t \fItimeout\fB] <-a|-r|-w>
 
-.B astribank_is_starting [-d]
+.B astribank_is_starting [-d] [-v]
 
 .B astribank_is_starting -h
 
@@ -29,10 +29,27 @@
 Reset the mark. Should return 0 unless there's an error.
 .RE
 
+.BI -t timeout
+.RS
+.B Timeout.
+Set the timeout value for the \fB-w\fR option. Default is 60 seconds.
+.RE
+
+.B -w
+.RS
+.B Wait.
+Wait for mark to be reset. Should return 0 unless there's an error.
+.RE
+
 Without -a or -r: return 0 if the mark has been set, or a non-zero value
 otherwise.
 
 .B -d
+.RS
+Print debug information to stderr.
+.RE
+
+.B -v
 .RS
 Verbose execution.
 .RE
@@ -65,6 +82,11 @@
 
 A: because, unlike the filesystem, it is writable at any given time.
 
+.SH BUGS
+Option ordering matter. The \fB-v\fR and \fB-d\fR options should preceed
+the actions (\fB-a\fR, \fB-r\fR and \fB-w\fR).
+The \fB-t\fItimeout\fR option should preceed the \fB-w\fR option.
+
 .SH SEE ALSO
 semctl(3)
 

Copied: tools/branches/2.2/xpp/astribank_is_starting.c (from r6987, tools/trunk/xpp/astribank_is_starting.c)
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/astribank_is_starting.c?view=diff&rev=7477&p1=tools/trunk/xpp/astribank_is_starting.c&r1=6987&p2=tools/branches/2.2/xpp/astribank_is_starting.c&r2=7477
==============================================================================
--- tools/trunk/xpp/astribank_is_starting.c (original)
+++ tools/branches/2.2/xpp/astribank_is_starting.c Wed Nov  4 14:32:25 2009
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE /* 2.3 and later will define this from autoconfig.h */
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/sem.h>
@@ -6,14 +7,18 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 
 static char		*progname;
 static const key_t	key_astribanks = 0xAB11A0;
 static int		debug;
+static int		verbose;
+static int		timeout_seconds = 60;
+
 
 static void usage(void)
 {
-	fprintf(stderr, "Usage: %s [-d] [-a] [-r]\n", progname);
+	fprintf(stderr, "Usage: %s [-d] [-t <seconds>] [-a|-r|-w]\n", progname);
 	exit(1);
 }
 
@@ -41,6 +46,8 @@
 	}
 	if(debug)
 		fprintf(stderr, "%s: touched absem\n", progname);
+	if(verbose)
+		printf("Astribanks initialization is starting\n");
 	return 0;
 }
 
@@ -63,6 +70,47 @@
 	}
 	if(debug)
 		fprintf(stderr, "%s: removed absem\n", progname);
+	if(verbose)
+		printf("Astribanks initialization is done\n");
+	return 0;
+}
+
+static int absem_wait(void)
+{
+	int		absem;
+	struct sembuf	sops;
+	long		now;
+	long		start_wait;
+	struct timespec	timeout;
+
+	if((absem = absem_get(0)) < 0) {
+		perror(__FUNCTION__);
+		return absem;
+	}
+	sops.sem_num = 0;
+	sops.sem_op = -1;
+	sops.sem_flg = 0;
+	start_wait = time(NULL);
+	timeout.tv_sec = timeout_seconds;
+	timeout.tv_nsec = 0;
+	if(semtimedop(absem, &sops, 1, &timeout) < 0) {
+		switch(errno) {
+		case EIDRM:	/* Removed -- OK */
+			break;
+		case EAGAIN:	/* Timeout -- Report */
+			fprintf(stderr, "Astribanks waiting timed out\n");
+			return -errno;
+		default:	/* Unexpected errors */
+			perror("semop");
+			return -errno;
+		}
+		/* fall-thgough */
+	}
+	now = time(NULL);
+	if(debug)
+		fprintf(stderr, "%s: waited on absem %ld seconds\n", progname, now - start_wait);
+	if(verbose)
+		printf("Finished after %ld seconds\n", now - start_wait);
 	return 0;
 }
 
@@ -77,17 +125,20 @@
 	}
 	if(debug)
 		fprintf(stderr, "%s: absem exists\n", progname);
+	if(verbose)
+		printf("Astribanks are initializing...\n");
 	return 0;
 }
 
 int main(int argc, char *argv[])
 {
-	const char	options[] = "darh";
+	const char	options[] = "dvarwt:h";
 	int		val;
 
 	progname = argv[0];
 	while (1) {
 		int	c;
+		int	t;
 
 		c = getopt (argc, argv, options);
 		if (c == -1)
@@ -96,6 +147,19 @@
 		switch (c) {
 			case 'd':
 				debug++;
+				break;
+			case 'v':
+				verbose++;
+				break;
+			case 't':
+				t = atoi(optarg);
+				if(t <= 0) {
+					fprintf(stderr,
+						"%s: -t expect a positive number of seconds: '%s'\n",
+						progname, optarg);
+					usage();
+				}
+				timeout_seconds = t;
 				break;
 			case 'a':
 				if((val = absem_touch()) < 0) {
@@ -109,6 +173,12 @@
 					return 1;
 				}
 				return 0;
+			case 'w':
+				if((val = absem_wait()) < 0) {
+					fprintf(stderr, "%s: Wait failed: %d\n", progname, val);
+					return 1;
+				}
+				return 0;
 			case 'h':
 			default:
 				fprintf(stderr, "Unknown option '%c'\n", c);

Modified: tools/branches/2.2/xpp/twinstar_hook
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/twinstar_hook?view=diff&rev=7477&r1=7476&r2=7477
==============================================================================
--- tools/branches/2.2/xpp/twinstar_hook (original)
+++ tools/branches/2.2/xpp/twinstar_hook Wed Nov  4 14:32:25 2009
@@ -49,74 +49,25 @@
 
 set -e
 
-# For lab testing
-liveconf="$dir/liveconf/dahdi"
-
-if [ -d "$liveconf" ]; then
-	dahdi_conf="$liveconf"
-else
-	dahdi_conf="/etc/dahdi"
-fi
-
-export XPPORDER_CONF="$dahdi_conf/xpp_order"
-if [ ! -r "$XPPORDER_CONF" ]; then
-	echo "Skip($ACTION): No '$XPPORDER_CONF'" | $LOGGER
-	exit 0
-fi
-SYSTEMCONF="$dahdi_conf/system.conf"
-
-TWS_DIR="/var/tmp"
-TWS_PREFIX="$TWS_DIR/twinstar-"
-LABELFILE="/sys/$DEVPATH/label"
 export XBUS_SORT='SORT_LABEL'
-
-echo "starting($ACTION): setup from $XPPORDER_CONF" | $LOGGER
-STAMP="${TWS_PREFIX}${XBUS_NAME}"
-TWS_TOTAL=`sed -e 's/#.*//' -e '/^[ 	]*$/d' -e 'y/\t/ /' "$XPPORDER_CONF" | wc -l`
 
 case "$ACTION" in
 online)
-	if [ ! -f "$LABELFILE" ]; then
-		echo "Missing labelfile '$LABELFILE'" | $LOGGER
-		exit 1
+	echo "$ACTION($XBUS_NAME): " | $LOGGER
+	twinstar enable-wd
+	sleep 1	# Just for visual effect
+	asterisk -rx 'module load chan_dahdi.so' 2>&1 | $LOGGER
+	xpp_blink bzzt xpd "$XBUS_NUM"
+	ports=`twinstar ports`
+	if [ "$ports" = 0 ]; then
+		play /usr/share/dahdi/primary-pbx-is-ready.wav || :
+	elif [ "$ports" = 1 ]; then
+		play /usr/share/dahdi/backup-pbx-is-ready.wav || :
 	fi
-	LABEL=`cat $LABELFILE`
-	TWS_LINE=`awk "/^$LABEL/" $XPPORDER_CONF`
-	if [ "$TWS_LINE" = "" ]; then
-		echo "online($XBUS_NAME): '$LABEL' is not in '$XPPORDER_CONF'" | $LOGGER
-		exit 1
-	fi
-	echo "$LABEL" > "$STAMP"
-	HOW_MANY=`ls ${TWS_PREFIX}* | wc -l`
-	echo "online($XBUS_NAME): $LABEL (${HOW_MANY}/${TWS_TOTAL})" | $LOGGER
-	twinstar enable-wd
-	if [ "$HOW_MANY" -eq "$TWS_TOTAL" ]; then
-		echo "online: GOT ALL $TWS_TOTAL" | $LOGGER
-		dahdi_registration on
-		dahdi_registration 2>&1 | tr '\t' ' ' | $LOGGER
-		echo "Using '$SYSTEMCONF'" 2>&1 | $LOGGER
-		dahdi_cfg -v -c "$SYSTEMCONF" 2>&1 | $LOGGER
-		sleep 1	# Just for visual effect
-		asterisk -rx 'module load chan_dahdi.so' 2>&1 | $LOGGER
-		xpp_blink bzzt xpd "$XBUS_NUM"
-		ports=`twinstar ports`
-		if [ "$ports" = 0 ]; then
-			play /usr/share/dahdi/primary-pbx-is-ready.wav || :
-		elif [ "$ports" = 1 ]; then
-			play /usr/share/dahdi/backup-pbx-is-ready.wav || :
-		fi
-		echo "online: READY" | $LOGGER
-	fi
+	echo "online: READY" | $LOGGER
 	;;
 offline)
-	LABEL=`cat $STAMP`
-	TWS_LINE=`awk "/^$LABEL/" $XPPORDER_CONF`
-	rm -f "$STAMP"
-	if [ "$TWS_LINE" = "" ]; then
-		echo "offline($XBUS_NAME): $LABEL is not in $XPPORDER_CONF" | $LOGGER
-		exit 1
-	fi
-	echo "offline($XBUS_NAME): $LABEL" | $LOGGER
+	echo "$ACTION($XBUS_NAME): " | $LOGGER
 	twinstar disable-wd
 	# If we want to disconnect everybody
 	twinstar jump

Modified: tools/branches/2.2/xpp/waitfor_xpds
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/waitfor_xpds?view=diff&rev=7477&r1=7476&r2=7477
==============================================================================
--- tools/branches/2.2/xpp/waitfor_xpds (original)
+++ tools/branches/2.2/xpp/waitfor_xpds Wed Nov  4 14:32:25 2009
@@ -29,6 +29,8 @@
 mydir=`dirname $0`
 PATH="${mydir}:${PATH}"
 
+[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
+
 ab_list() {
 	# Only check /sys info (don't use /proc anymore).
 	ab=`find /sys/bus/astribanks/devices/xbus-*/ -name waitfor_xpds 2> /dev/null || :`
@@ -40,7 +42,14 @@
 	echo >&2 "$0: Missing dahdi_hardware"
 	exit 0
 fi
-if [ "`$dahdi_hardware | grep xpp_usb`" = "" ]; then
+if ! astribank_is_starting="`which astribank_is_starting 2>/dev/null`"; then
+	echo >&2 "$0: Missing astribank_is_starting"
+	exit 0
+fi
+if [ "`$dahdi_hardware | grep xpp_usb`" != "" ]; then
+	astribank_is_starting -v -a
+fi
+if ! astribank_is_starting; then
 	exit 0
 fi
 
@@ -60,7 +69,7 @@
 echo ""
 
 # Wait for device to stabilize and XPD's to finish initalizations
-echo 1>&2 "Astribanks initalization "
+echo 1>&2 "Astribanks initializing spans"
 while
 	if ! ab=`ab_list`; then
 		exit 1
@@ -70,3 +79,14 @@
 	oldab="$ab"
 	cat $ab
 done
+
+if [ "$XPP_HOTPLUG_DAHDI" = yes ]; then
+	if [ "$CALLED_FROM_ATRIBANK_HOOK" = '' ]; then
+		# Now we can wait until the hotplug run would remove the semaphore
+		echo -n 1>&2 "Other DAHDI initializations... "
+		astribank_is_starting -v -w 1>&2
+	fi
+else
+	# Non-hotplug -- Sequential initialization, remove semaphore
+	astribank_is_starting -v -r 1>&2
+fi

Modified: tools/branches/2.2/xpp/xpp_fxloader
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/xpp_fxloader?view=diff&rev=7477&r1=7476&r2=7477
==============================================================================
--- tools/branches/2.2/xpp/xpp_fxloader (original)
+++ tools/branches/2.2/xpp/xpp_fxloader Wed Nov  4 14:32:25 2009
@@ -261,6 +261,9 @@
 	echo "$0 usb   : manual firmware loading: USB firmware only."
 	echo "$0 help  : this text."
 }
+
+# We have a potential astribank
+astribank_is_starting -a
 
 #########################
 ##




More information about the svn-commits mailing list