I have been experimenting with this for a bit, and have it working well. I am running a FT-991A connected via DINAH to a Raspberry Pi using allstar to connect to the East Coast Reflector. Sometimes there are ISP hiccups and it gets disconnected, and I don't realize it until hours later. So I wrote a little bash script to run and reconnect me if it needs to.
Raspberry Pi is running Arch linux, so it uses cronie instead of cron. I am running a check every minute, but you can change to your liking. Since it is cronie, the file I edit is /var/spool/cron/root.
I just added the line: * * * * * /var/spool/cron/check_connect.sh to the end of the file. I have my script check_connect.sh in the same directory.
Here is the bash file if you want to play around with it. I set it up with variables to make it easier to configure:
MYSITE is your node number
REMSITE is the node you are connecting to
LOGFILE is the name of the file you want to log to
LOGRECONLY is set to 1 or 0, where 1 will only write to the logfile if disconnected and needs to reconnect. This saves on logfile size. 0 will write to the logfile everytime the file is called.
Just copy and paste into your file and set your variables.
It's quite simple and straightforward. If I make changes to improve or update I will add to or refer to this thread.
Enjoy.
#!/bin/bash
##################################
#### KO4IYY ####
#### Steve Clay ####
#### steve@ko4iyy.com ####
#### ####
#### Simple script to check ####
#### if asterisk is connected####
#### to your remote node. ####
#### Used for East Coast ####
#### Reflector connection ####
#### via Raspberry Pi ####
##################################
# Set this file up in your crontab to
# run at desired intervals
# Change these to match your local settings
MYSITE="00000"
REMSITE="00000"
# Change if you want to change the location of your logfile
LOGFILE="/var/log/checkConnect.log"
# 0 = Write all checks to log file, 1 = Only write when a reconnect is performed (saves on logfile size).
LOGRECONLY="1"
# You shouldn't have to change anything below
#############################################
if [ "$LOGRECONLY" = "0" ]
then
echo "#############################" >> "$LOGFILE" 2>&1
date "+%m-%d-%Y %H:%M:%S" >> "$LOGFILE" 2>&1
CHK=""
echo "Checking if connected to hub node "$REMSITE"" >> "$LOGFILE" 2>&1
CHK=$(asterisk -rx "rpt nodes "$MYSITE"" | grep -c "$REMSITE")
if [ "$CHK" = "1" ]
then
echo "You are already connected to $REMSITE." >> "$LOGFILE" 2>&1
else
echo "Reconnecting to $REMSITE...." >> "$LOGFILE" 2>&1
asterisk -rx "rpt cmd "$MYSITE" ilink 3 "$REMSITE""
fi
echo "#############################" >> "$LOGFILE" 2>&1
else
CHK=""
CHK=$(asterisk -rx "rpt nodes "$MYSITE"" | grep -c "$REMSITE")
if [ "$CHK" = "0" ]
then
echo "#############################" >> "$LOGFILE" 2>&1
date "+%m-%d-%Y %H:%M:%S" >> "$LOGFILE" 2>&1
echo "You are DISCONNECTED to hub node "$REMSITE"" >> "$LOGFILE" 2>&1
echo "Attempting to RECONNECT to "$REMSITE"...." >> "$LOGFILE" 2>&1
asterisk -rx "rpt cmd "$MYSITE" ilink 3 "$REMSITE""
CHK=$(asterisk -rx "rpt nodes "$MYSITE"" | grep -c "$REMSITE")
if [ "$CHK" = "1" ]
then
echo "Reconnect successful. Your node "$MYSITE" is now connected to ECR node "$REMSITE"." >> "$LOGFILE"
else
echo "Reconnect unsuccessful. I will retry next time this file is called." >> "$LOGFILE"
fi
echo "#############################" >> "$LOGFILE" 2>&1
fi
fi