allstar_status.sh

Summary: This script reviews the AllStarLink.org status page for your node and creates a log on the status. I will be implementing a restart option similar to the ping test as well as adding an option for looking a the GMRS Network Status page to see if it can also be added.

#!/bin/bash
# SCRIPT NAME: allstar_status.sh
# CREATED BY: Justin Grigg
# CREATED ON: 04/21/2020
# SCRIPT PURPOSE: parses the allstarlink status page to check the status of the node
# SCRIPT NOTES: lynx application needs to be installed. Use command 'pacman -Syu lynx
# SCRIPT NOTES: Saves a temp logfile allstar_result.txt to /
# SCRIPT NOTES: Saves a temp file tp /text.txt and then deletes it.
# set script options below. Only edit between " "
node_number="501660"                            # AllStarLink Node Number
path_to_script="/usr/local/sbin/asterisk.sh"    # path to script that will run upon fail
result_onscreen="on"                            # if you wish to display a status (on / off)
# Please do not edit below this line
# -------------------------------------------------------------------------
#setting system variables
allstar_url="http://stats.allstarlink.org/nodeinfo.cgi?node="
timestamp=$(date)
search_string="error"
lynx -dump $allstar_url$node_number > /text.txt
if grep -q $search_string /text.txt
        #search term found
        then
                # writing information to the allstar_result log
                echo "ALLSTAR CONNECTION FAIL |" $timestamp >>/allstar_result.txt
                echo "---Running Script" $path_to_script >>/allstar_result.txt
                # setting a variable to display on the screen
                answer="1"
                # running the define script
                #("$path_to_script")
        #search term not found
 		else
                # writing information to the allstar_result log
                echo "ALLSTAR CONNECTION CONFIRMED |" $timestamp >>/allstar_result.txt
                # setting a variable to display on the screen
                answer="0"
        fi
# displays response on the screen
echo $answer
# removes temp file
rm -rf /text.txt