From cb01267f42eba7bc5a572235e5d2571cc9b60303 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Thu, 2 Apr 2009 20:56:42 +0000 Subject: Support for Astribanks 116x: tools part * New USB firmware loading mechanism. - Incompatible with previous one: upgrade using fxload or hard reset - astribank_hexload is the new low-level loading tool - fpga_load remains for backward compatibility. - xpp/astribank_upgrade: automate upgrading using fxload * Much enhanced control protocol ("MPP") - astribank_tool is the low-level tool for that. * Support for the TwinStar (dual USB port) - Managed through astribank_tool - Wrapper perl modules and scripts provided * Allow explicit ordering of Astribanks - /etc/dahdi/xpp_order - explicit order of Astribanks on the system - The default sorter is now to use those and fall back to connectors (previous default). - An option to dahdi_registration to change sorting. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@6313 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- xpp/twinstar_hook | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 xpp/twinstar_hook (limited to 'xpp/twinstar_hook') diff --git a/xpp/twinstar_hook b/xpp/twinstar_hook new file mode 100755 index 0000000..d014500 --- /dev/null +++ b/xpp/twinstar_hook @@ -0,0 +1,93 @@ +#! /bin/sh + +me=`basename $0` +dir=`dirname $0` +LOGGER="logger -i -t '$me'" + +# 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}_$XBUS_NAME" 1>&2 + +PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin" + +set -e + +TWS_SETUP="/etc/dahdi/twinstar_setup.conf" +if [ ! -r "$TWS_SETUP" ]; then + echo "Skip($ACTION): No '$TWS_SETUP'" | $LOGGER + exit 0 +fi +SYSTEMCONF="/tmp/xortel/dahdi/system.conf" +dahdi_registration="/usr/sbin/dahdi_registration" +dahdi_cfg="/usr/sbin/dahdi_cfg" +xpp_blink="/usr/sbin/xpp_blink" +twinstar="/usr/sbin/twinstar" + +TWS_DIR="/var/tmp" +TWS_PREFIX="$TWS_DIR/twinstar-" +LABELFILE="/sys/$DEVPATH/label" +export XBUS_SORT='SORT_LABEL' + +echo "starting($ACTION): '$*'" | $LOGGER +STAMP="${TWS_PREFIX}${XBUS_NAME}" +TWS_TOTAL=`sed -e 's/#.*//' -e '/^[ ]*$/d' "$TWS_SETUP" | wc -l` + +case "$ACTION" in +online) + if [ ! -f "$LABELFILE" ]; then + echo "Missing labelfile '$LABELFILE'" | $LOGGER + exit 1 + fi + LABEL=`cat $LABELFILE` + TWS_LINE=`awk "/^$LABEL/" $TWS_SETUP` + if [ "$TWS_LINE" = "" ]; then + echo "online($XBUS_NAME): '$LABEL' is not in '$TWS_SETUP'" | $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 | $LOGGER + echo "Using '$SYSTEMCONF'" 2>&1 | $LOGGER + "$dahdi_cfg" -v -c "$SYSTEMCONF" 2>&1 | $LOGGER + asterisk -rx 'module load chan_dahdi.so' 2>&1 | $LOGGER + sleep 1 # Just for visual effect + "$xpp_blink" bzzt xpd "$XBUS_NUM" + ports=`"$twinstar" ports` + if [ "$ports" = 0 ]; then + play /usr/share/zaptel/primary-pbx-is-ready.wav || : + elif [ "$ports" = 1 ]; then + play /usr/share/zaptel/backup-pbx-is-ready.wav || : + fi + echo "online: READY" | $LOGGER + fi + ;; +offline) + LABEL=`cat $STAMP` + TWS_LINE=`awk "/^$LABEL/" $TWS_SETUP` + rm -f "$STAMP" + if [ "$TWS_LINE" = "" ]; then + echo "offline($XBUS_NAME): $LABEL is not in $TWS_SETUP" | $LOGGER + exit 1 + fi + echo "offline($XBUS_NAME): $LABEL" | $LOGGER + "$twinstar" disable-wd + # If we want to disconnect everybody + "$twinstar" jump + asterisk -rx 'module unload chan_dahdi.so' + ;; +*) + echo "$0: Unknown ACTION='$ACTION'" | $LOGGER + echo "$0: ARGS='$*'" | $LOGGER + echo "$0: ENV:" | $LOGGER + env | $LOGGER + exit 1 +esac + -- cgit v1.2.3