From c3f94bd0d548bcb260001c8ab902b10339e1c2a1 Mon Sep 17 00:00:00 2001 From: dman776 Date: Wed, 8 Apr 2020 21:31:01 -0500 Subject: [PATCH] feature: add "aredn alerts" feature in header (#505) * feature: add "aredn alerts" feature in header * optimize conditional logic * additional fixes * improve presentation display --- files/etc/crontabs/root | 1 + files/usr/local/bin/aredn_message.sh | 64 ++++++++++++++++++++++++++++ files/www/cgi-bin/perlfunc.pm | 4 ++ 3 files changed, 69 insertions(+) create mode 100755 files/usr/local/bin/aredn_message.sh diff --git a/files/etc/crontabs/root b/files/etc/crontabs/root index 0293c59c..780a36fa 100644 --- a/files/etc/crontabs/root +++ b/files/etc/crontabs/root @@ -2,4 +2,5 @@ * * * * * /usr/local/bin/rssi_monitor * * * * * /usr/local/bin/snrlog * * * * * /usr/local/bin/clean_zombie.sh +0 */12 * * * /usr/local/bin/aredn_message.sh diff --git a/files/usr/local/bin/aredn_message.sh b/files/usr/local/bin/aredn_message.sh new file mode 100755 index 00000000..91e297f5 --- /dev/null +++ b/files/usr/local/bin/aredn_message.sh @@ -0,0 +1,64 @@ +#!/bin/sh +true <<'LICENSE' + Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks + Copyright (C) 2020 Darryl Quinn K5DLQ + See Contributors file for additional contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 3 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Additional Terms: + + Additional use restrictions exist on the AREDN(TM) trademark and logo. + See AREDNLicense.txt for more info. + + Attributions to the AREDN Project must be retained in the source code. + If importing this code into a new or existing project attribution + to the AREDN project must be added to the source code. + + You must not misrepresent the origin of the material contained within. + + Modified versions must be modified to attribute to the original source + and be marked in reasonable ways as differentiate it from the original + version. + +LICENSE + +# does the node have access to downloads.arednmesh.org +ping -q -W10 -c1 downloads.arednmesh.org > /dev/null && + online=true; + [ -f /tmp/aredn_message ] && + rm /tmp/aredn_message + + +if [ $online = "true" ] +then + # fetch node specific message file + # nodename=$(echo "$HOSTNAME" | tr 'A-Z' 'a-z') + nodename=$(echo "$HOSTNAME" | tr 'A-Z' 'a-z') + wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/"${nodename}".txt + echo "(${nodename}):"|cat - /tmp/aredn_message > /tmp/out && mv /tmp/out /tmp/aredn_message + if [ $? -ne 0 ] # no node specific file + then + # fetch broadcast message file + wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/all.txt + echo "(QST):"|cat - /tmp/aredn_message > /tmp/out && mv /tmp/out /tmp/aredn_message + else + # need to append to node file + wget -q -O aredn_message_all -P /tmp http://downloads.arednmesh.org/messages/all.txt && + echo "(QST):"|cat - /tmp/aredn_message_all > /tmp/out && mv /tmp/out /tmp/aredn_message_all + echo "
" >> /tmp/aredn_message; + cat /tmp/aredn_message_all >> /tmp/aredn_message; + rm /tmp/aredn_message_all; + fi +fi + diff --git a/files/www/cgi-bin/perlfunc.pm b/files/www/cgi-bin/perlfunc.pm index c5b83d43..cd6c292a 100644 --- a/files/www/cgi-bin/perlfunc.pm +++ b/files/www/cgi-bin/perlfunc.pm @@ -1877,6 +1877,9 @@ sub is_hardware_supported # Needs to be renamed from alert_banner sub alert_banner { + # if /tmp/aredn_message file exists, then read and set $aredn_message to contents + $aredn_message = `cat /tmp/aredn_message` if( -f "/tmp/aredn_message"); + print "
"; #AREDN Banner @@ -1894,6 +1897,7 @@ sub alert_banner print "
!!!! UNTESTED HARDWARE !!!!
\n"; } } + print "
AREDN Alert(s):
$aredn_message
\n" if $aredn_message; #TopBanner print "
";