summaryrefslogtreecommitdiff
path: root/xpp/twinstar_hook
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/twinstar_hook')
-rwxr-xr-xxpp/twinstar_hook85
1 files changed, 62 insertions, 23 deletions
diff --git a/xpp/twinstar_hook b/xpp/twinstar_hook
index d014500..7b2101f 100755
--- a/xpp/twinstar_hook
+++ b/xpp/twinstar_hook
@@ -1,4 +1,37 @@
#! /bin/sh
+#
+# Written by Oron Peled <oron@actcom.co.il>
+# Copyright (C) 2009, Xorcom
+#
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+#
+# This is an experimental script to activate an Astribank TwinStar
+# during failover.
+#
+# The script assume that there is an /etc/dahdi/xpp_order file
+# specifying the Astribanks' labels according to the required
+# registration order.
+#
+# This file can be easily generated by running:
+# dahdi_genconf xpporder
+# after the system is configured and working.
+#
me=`basename $0`
dir=`dirname $0`
@@ -11,29 +44,35 @@ LOGGER="logger -i -t '$me'"
## 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
-TWS_SETUP="/etc/dahdi/twinstar_setup.conf"
-if [ ! -r "$TWS_SETUP" ]; then
- echo "Skip($ACTION): No '$TWS_SETUP'" | $LOGGER
+# 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="/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"
+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): '$*'" | $LOGGER
+echo "starting($ACTION): setup from $XPPORDER_CONF" | $LOGGER
STAMP="${TWS_PREFIX}${XBUS_NAME}"
-TWS_TOTAL=`sed -e 's/#.*//' -e '/^[ ]*$/d' "$TWS_SETUP" | wc -l`
+TWS_TOTAL=`sed -e 's/#.*//' -e '/^[ ]*$/d' -e 'y/\t/ /' "$XPPORDER_CONF" | wc -l`
case "$ACTION" in
online)
@@ -42,25 +81,25 @@ online)
exit 1
fi
LABEL=`cat $LABELFILE`
- TWS_LINE=`awk "/^$LABEL/" $TWS_SETUP`
+ TWS_LINE=`awk "/^$LABEL/" $XPPORDER_CONF`
if [ "$TWS_LINE" = "" ]; then
- echo "online($XBUS_NAME): '$LABEL' is not in '$TWS_SETUP'" | $LOGGER
+ 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
+ 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
+ dahdi_registration on
+ dahdi_registration 2>&1 | tr '\t' ' ' | $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
+ dahdi_cfg -v -c "$SYSTEMCONF" 2>&1 | $LOGGER
sleep 1 # Just for visual effect
- "$xpp_blink" bzzt xpd "$XBUS_NUM"
- ports=`"$twinstar" ports`
+ 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/zaptel/primary-pbx-is-ready.wav || :
elif [ "$ports" = 1 ]; then
@@ -71,16 +110,16 @@ online)
;;
offline)
LABEL=`cat $STAMP`
- TWS_LINE=`awk "/^$LABEL/" $TWS_SETUP`
+ TWS_LINE=`awk "/^$LABEL/" $XPPORDER_CONF`
rm -f "$STAMP"
if [ "$TWS_LINE" = "" ]; then
- echo "offline($XBUS_NAME): $LABEL is not in $TWS_SETUP" | $LOGGER
+ echo "offline($XBUS_NAME): $LABEL is not in $XPPORDER_CONF" | $LOGGER
exit 1
fi
echo "offline($XBUS_NAME): $LABEL" | $LOGGER
- "$twinstar" disable-wd
+ twinstar disable-wd
# If we want to disconnect everybody
- "$twinstar" jump
+ twinstar jump
asterisk -rx 'module unload chan_dahdi.so'
;;
*)