Pushover for Allstarlink Connection Messages

Having installed Skywarn Plus on my Allstarlink node yesterday, it used Pushover for the weather alert text messages to your phone as opposed to cellular SMS messages. The app is so nice for receiving messages because it’s clean and you can easily delete them as they come in as opposed to using an SMS client.

So I thought it would be nice to setup a script to send new connection alerts through Pushover, and I had a previously operating SMS script from Doug Crompton that just needed some tweaking to convert over to Pushover. Consequently, Hamvoip has a guide on how to setup your Gmail account to allow for e-mail messages from your node, and once that’s setup and working you can utilize it to send e-mails to Pushover. And then use the e-mail address from your Pushover account to receive the alerts only when someone connects to your node via the smsconnectlog bash script below which I include in my /etc/asterisk/local directory, and don’t forget to make it executable (chmod +x).

#!/bin/bash
#
# Bash Script to Text/email new connects/disconnects
# filtered by callsign ignoreing your nodes,iaxrpt...
# Logging must be enabled for your nodes
#
# Destination SMS number and address or email
RECEIVER="Pushoveraddress@pomail.net"
# How often to check connection log 
ALERT_INTERVAL="15"
# Log file to monitor
LOGFILE="/var/log/asterisk/connectlog"
# Callsign to ignore
CALL="CALLSIGN"

length=$(find "$LOGFILE" -printf "%s")
CALL="$CALL*"
while sleep $ALERT_INTERVAL  
do
  new_length=$(find "$LOGFILE" -printf "%s")
  if [[ $length < $new_length ]]
  then
    newconnect=$(tail --bytes=$[new_length-length] "$LOGFILE"|cut -d' ' -f13)
    newconnect2=$(tail --bytes=$[new_length-length] "$LOGFILE"|cut -d' ' -f11)
    newconnect3=$(tail --bytes=$[new_length-length] "$LOGFILE"|cut -d' ' -f12)
    if [[ $newconnect != $CALL && $newconnect2 != $CALL ]]
    then
      if [ "$newconnect3" = "<=IN==" ]
        then
        newlogentries=$(tail --bytes=$[new_length-length] "$LOGFILE" |cut -c 11-16,29-)
        echo -e "Subject: Allstar ConnectLog\n\r$newlogentries" | sendmail -v $RECEIVER
      fi
    fi
  fi
  length=$new_length
  newlogentries=""
done

Then you’ll want to add the file once tested to your /etc/rc.local file to be loaded on boot, and reboot after everything is configured.

# Script to sms new external log entries
/etc/asterisk/local/smsconnectlog > null &

Once setup, you’ll only get messages when someone connects to your node, and the messages are very easy to check and delete. Worth pointing out that Pushover can be used for a lot of other automation messages as well and is a very good product. And I’ll include their Android privacy information below as you should always check this before installing any applications on your phone, especially since many are recording your location information, apps used… and sharing this with third parties like our government which purchases it to skirt around legal requirements.