feature: add "aredn alerts" feature in header (#505)

* feature: add "aredn alerts" feature in header

* optimize conditional logic

* additional fixes

* improve presentation display
This commit is contained in:
dman776 2020-04-08 21:31:01 -05:00 committed by GitHub
parent 5142710e20
commit c3f94bd0d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 0 deletions

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>.
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 "<strong>(${nodename}):</strong>"|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 "<strong>(QST):</strong>"|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 "<strong>(QST):</strong>"|cat - /tmp/aredn_message_all > /tmp/out && mv /tmp/out /tmp/aredn_message_all
echo "<br />" >> /tmp/aredn_message;
cat /tmp/aredn_message_all >> /tmp/aredn_message;
rm /tmp/aredn_message_all;
fi
fi

View File

@ -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 "<div class=\"TopBanner\">";
#AREDN Banner
@ -1894,6 +1897,7 @@ sub alert_banner
print "<div style=\"padding:5px;background-color:#FFFF00;border:1px solid #ccc;width:600px;\"><a href=\"/cgi-bin/sysinfo\">!!!! UNTESTED HARDWARE !!!!</a></div>\n";
}
}
print "<div style=\"padding:5px;background-color:#FFFF00;border:1px solid #ccc;width:600px;\"><strong>AREDN Alert(s):</strong><br /><div style=\"text-align:left;\">$aredn_message</div></div>\n" if $aredn_message;
#TopBanner
print "</div>";