#!/bin/bash # Allstar check connection script by Kyle Yoksh, K0KN # May 2013 # # This script allows you to periodically check to see if your node is # connected to another Allstar node. This can be run as a cron job every # so often. # # One use for this would be to automatically reconnect a node that # periodically becomes disconnected. You could also choose to send an # email or text message to notify you that the nodes have disconnected. # # If the DISABLEFILE below exists, the script will exit immediately. This # allows a DTMF to be assigned in rpt.conf to stop the nodes from automatically # reconnecting. Example: # # 123=cmd,touch /etc/asterisk/~chkconn_disable ; disable chkconn # 456=cmd,rm -f /etc/asterisk/~chkconn_disable ; enable chkconn DISABLEFILE="/etc/asterisk/~chkconn_disable" LOGFILE="/var/log/asterisk/connectlog" tempfile=/dev/shm/xchkconn.$1 # if [ "$1" == "" -o "$2" == "" ] ; then echo "Usage = chkconn [your node#] [remote node#]"; exit fi if [ -f $DISABLEFILE ] then echo "Disable flag set -- exiting" exit fi # asterisk -rx "rpt nodes $1" > $tempfile grep "$2" $tempfile > /dev/null || CONNECTSTATUS=0 # grep "$2" $tempfile > /dev/null && CONNECTSTATUS=1 # If nodes are connected if [[ "$CONNECTSTATUS" == "1" ]] then echo "$1 connected to $2" # add more commands as you like fi # If nodes are not connected if [[ "$CONNECTSTATUS" == "0" ]] then echo "$1 not connected to $2" # sample command to reconnect remote node if not connected: asterisk -rx "rpt fun $1 *3$2" # add log entry echo $(date) $1 reconnected to $2 via CHKCONN >> $LOGFILE fi exit