xpp: can use modern Asterisk hotplug support
* New asynchronous behavior is used only when two conditions are met: - Finding new $ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes in /etc/dahdi/init.conf This should be set only when Asterisk support hotplug and configured to use it (no_failed_channels==1). - DAHDI auto_assign_spans==0 * Adapt /usr/share/dahdi/astribank_hook: - Refactor old twinstar behavior into functions - Add new behavior in a function (just enable the Asrribank watchdog) - Call the correct function. * Adapt init script: If asynchronous behavior is on, don't wait for all Astribanks to finish initialization (it's enough that we saw all/some of them) Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
This commit is contained in:
parent
cd6083b6ce
commit
f11b937659
@ -144,6 +144,14 @@ hotplug_exit_after_load() {
|
|||||||
|
|
||||||
# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
|
# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
|
||||||
xpp_startup() {
|
xpp_startup() {
|
||||||
|
if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
|
||||||
|
aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
|
||||||
|
aas=`cat "$aas_param" 2>/dev/null`
|
||||||
|
if [ "$aas" = 0 ]; then
|
||||||
|
echo 1>&2 "Don't wait for Astribanks (use Asterisk hotplug-support)"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# do nothing if there are no astribank devices:
|
# do nothing if there are no astribank devices:
|
||||||
if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
|
if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#XPP_FIRMWARE_DIR=/usr/share/dahdi
|
#XPP_FIRMWARE_DIR=/usr/share/dahdi
|
||||||
#XPP_HOTPLUG_DISABLED=yes
|
#XPP_HOTPLUG_DISABLED=yes
|
||||||
#XPP_HOTPLUG_DAHDI=yes
|
#XPP_HOTPLUG_DAHDI=yes
|
||||||
|
#ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes
|
||||||
|
|
||||||
# Disable udev handling:
|
# Disable udev handling:
|
||||||
#DAHDI_UDEV_DISABLE_DEVICES=yes
|
#DAHDI_UDEV_DISABLE_DEVICES=yes
|
||||||
|
@ -16,6 +16,8 @@ PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
LOCK="/var/lock/twinstar_startup"
|
||||||
|
|
||||||
[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
|
[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
|
||||||
|
|
||||||
# For lab testing
|
# For lab testing
|
||||||
@ -32,16 +34,37 @@ if [ "$XPP_HOTPLUG_DAHDI" != yes ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
export XPPORDER_CONF="$dahdi_conf/xpp_order"
|
export XPPORDER_CONF="$dahdi_conf/xpp_order"
|
||||||
if [ ! -r "$XPPORDER_CONF" ]; then
|
export DAHDI_CFG_CMD="dahdi_cfg -c $dahdi_conf/system.conf"
|
||||||
|
export CALLED_FROM_ATRIBANK_HOOK=yes
|
||||||
|
|
||||||
|
can_full_async() {
|
||||||
|
# Can we work aynchronously:
|
||||||
|
# - Need modern Asterisk that accept hotplug DAHDI devices.
|
||||||
|
# - Need DAHDI with "auto_assign_spans" == 0
|
||||||
|
if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
|
||||||
|
aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
|
||||||
|
aas=`cat "$aas_param" 2>/dev/null`
|
||||||
|
if [ "$aas" = 0 ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
$LOGGER "No async operation ($aas_param != 0)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
$LOGGER "No async operation (ASTERISK_SUPPORTS_DAHDI_HOTPLUG!=yes)"
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_xpporder_conf() {
|
||||||
|
if [ ! -r "$XPPORDER_CONF" ]; then
|
||||||
(
|
(
|
||||||
echo "Skip($ACTION): No '$XPPORDER_CONF'"
|
echo "Skip($ACTION): No '$XPPORDER_CONF'"
|
||||||
echo "Removing uneeded startup semaphore"
|
echo "Removing uneeded startup semaphore"
|
||||||
astribank_is_starting -v -r 2>&1
|
astribank_is_starting -v -r 2>&1
|
||||||
) 2>&1 | $LOGGER
|
) 2>&1 | $LOGGER
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
export DAHDI_CFG_CMD="dahdi_cfg -c $dahdi_conf/system.conf"
|
}
|
||||||
export CALLED_FROM_ATRIBANK_HOOK=yes
|
|
||||||
|
|
||||||
clean_lines() {
|
clean_lines() {
|
||||||
sed -e 's/#.*//' -e 'y/\t/ /' -e 's/^ *//' -e 's/ *$//' -e '$s/$/\n/' "$XPPORDER_CONF"
|
sed -e 's/#.*//' -e 'y/\t/ /' -e 's/^ *//' -e 's/ *$//' -e '$s/$/\n/' "$XPPORDER_CONF"
|
||||||
@ -64,10 +87,6 @@ matched_devices() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
|
||||||
NUM_GOOD=`matched_devices | wc -l`
|
|
||||||
LOCK="/var/lock/twinstar_startup"
|
|
||||||
|
|
||||||
# Wait until udev finished processing our requests
|
# Wait until udev finished processing our requests
|
||||||
# so we know the device files were actually created
|
# so we know the device files were actually created
|
||||||
# before trying dahdi_cfg et-al.
|
# before trying dahdi_cfg et-al.
|
||||||
@ -110,13 +129,9 @@ start_dahdi() {
|
|||||||
rm -f "$LOCK"
|
rm -f "$LOCK"
|
||||||
}
|
}
|
||||||
|
|
||||||
#echo "$0: $ACTION($XBUS_NAME)" | $LOGGER
|
old_synchronous_start() {
|
||||||
case "$ACTION" in
|
NUM_GOOD=`matched_devices | wc -l`
|
||||||
add)
|
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
||||||
;;
|
|
||||||
remove)
|
|
||||||
;;
|
|
||||||
online)
|
|
||||||
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
||||||
if [ "$NUM_GOOD" -eq "$NUM_WANTED" ]; then
|
if [ "$NUM_GOOD" -eq "$NUM_WANTED" ]; then
|
||||||
(
|
(
|
||||||
@ -142,8 +157,11 @@ online)
|
|||||||
fi
|
fi
|
||||||
) < /dev/null 2>&1 | $LOGGER &
|
) < /dev/null 2>&1 | $LOGGER &
|
||||||
fi
|
fi
|
||||||
;;
|
}
|
||||||
offline)
|
|
||||||
|
old_synchronous_stop() {
|
||||||
|
NUM_GOOD=`matched_devices | wc -l`
|
||||||
|
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
||||||
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
||||||
if [ "$NUM_GOOD" -eq 0 ]; then
|
if [ "$NUM_GOOD" -eq 0 ]; then
|
||||||
echo "All Astribanks offline" | $LOGGER
|
echo "All Astribanks offline" | $LOGGER
|
||||||
@ -152,6 +170,47 @@ offline)
|
|||||||
fi
|
fi
|
||||||
rm -f "$LOCK"
|
rm -f "$LOCK"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
tws_watchdog_enable() {
|
||||||
|
devdir="/sys$DEVPATH"
|
||||||
|
label=`cat "$devdir/label"`
|
||||||
|
connector=`cat "$devdir/connector"`
|
||||||
|
xbus=`echo "$devdir" | sed 's,.*/,,'`
|
||||||
|
prefix="${xbus}: [${label}] @${connector}"
|
||||||
|
TWS_NOAUTOJUMPFILE="$TWS_DIR/twinstar_no_autojump"
|
||||||
|
if [ -e "$TWS_NOAUTOJUMPFILE" ]; then
|
||||||
|
$LOGGER "$prefix: ignore wd (found $TWS_NOAUTOJUMPFILE)"
|
||||||
|
else
|
||||||
|
# Re-arm Astribank watchdog
|
||||||
|
transportdir="$devdir/transport"
|
||||||
|
busnum=`cat "$transportdir/busnum" 2>/dev/null || :`
|
||||||
|
devnum=`cat "$transportdir/devnum" 2>/dev/null || :`
|
||||||
|
devaddr=`printf "%03d/%03d" "$busnum" "$devnum"`
|
||||||
|
$LOGGER "$prefix: enabling twinstar watchdog"
|
||||||
|
astribank_tool -D "$devaddr" -w 1 2>&1 | $LOGGER
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#echo "$0: $ACTION($XBUS_NAME)" | $LOGGER
|
||||||
|
case "$ACTION" in
|
||||||
|
add)
|
||||||
|
;;
|
||||||
|
remove)
|
||||||
|
;;
|
||||||
|
online)
|
||||||
|
if can_full_async; then
|
||||||
|
tws_watchdog_enable
|
||||||
|
else
|
||||||
|
old_synchronous_start
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
offline)
|
||||||
|
if can_full_async; then
|
||||||
|
: # Nothing to do
|
||||||
|
else
|
||||||
|
old_synchronous_stop
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$0: Unknown ACTION='$ACTION'" | $LOGGER
|
echo "$0: Unknown ACTION='$ACTION'" | $LOGGER
|
||||||
|
Loading…
Reference in New Issue
Block a user