aredn: add aredn local alerts capability (#552)

This commit is contained in:
dman776 2020-08-18 16:17:03 -05:00 committed by GitHub
parent 6e579d4d6e
commit 5e572ff66a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 3 deletions

View File

@ -75,7 +75,7 @@ boot() {
fi
/usr/local/bin/usb_passthrough "${usbvalue}"
# package repositorys
# package repositories
local repos="core base arednpackages packages luci routing telephony"
set -- $repos
while [ -n "$1" ]; do
@ -95,4 +95,11 @@ boot() {
fi
shift
done
# set local alerts if available
local alertslocalpath=$(uci -q get aredn.@alerts[0].localpath)
if [ -z "$alertslocalpath" ]; then
uci -q add aredn alerts
uci -q commit aredn
fi
}

View File

@ -39,12 +39,12 @@ ping -q -W10 -c1 downloads.arednmesh.org > /dev/null &&
[ -f /tmp/aredn_message ] &&
rm /tmp/aredn_message
nodename=$(echo "$HOSTNAME" | tr '[:upper:]' '[:lower:]')
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
@ -62,3 +62,28 @@ then
fi
fi
# are local alerts enabled? uci: aredn.alerts.localpath != NULL
#
alertslocalpath=$(uci -q get aredn.@alerts[0].localpath)
if [ ! -z "$alertslocalpath" ]; then
# fetch node specific message file
wget -q -O local_message -P /tmp "${alertslocalpath}/${nodename}".txt
echo "<strong>(LOCAL ${nodename}):</strong>"|cat - /tmp/local_message > /tmp/out && mv /tmp/out /tmp/local_message
if [ $? -ne 0 ] # no node specific file
then
# fetch broadcast message file
wget -q -O local_message -P /tmp "${alertslocalpath}/all.txt"
echo "<strong>(LOCAL QST):</strong>"|cat - /tmp/local_message > /tmp/out && mv /tmp/out /tmp/local_message
else
# need to append to node file
wget -q -O local_message_all -P /tmp "${alertslocalpath}/all.txt" &&
echo "<strong>(LOCAL QST):</strong>"|cat - /tmp/local_message_all > /tmp/out && mv /tmp/out /tmp/local_message_all
echo "<br />" >> /tmp/local_message;
[ -f /tmp/local_message_all ] &&
cat /tmp/local_message_all >> /tmp/local_message &&
rm /tmp/local_message_all;
fi
fi

View File

@ -2,7 +2,7 @@
=for comment
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
Copyright (C) 2018 - Darryl Quinn
Copyright (C) 2020 - Darryl Quinn
See Contributors file for additional contributors
Copyright (c) 2013 David Rivenburg et al. BroadBand-HamNet
@ -146,6 +146,12 @@ push @setting, {
desc => "Value doesn't matter. Will attempt to pull any AREDN Alert messages.",
postcallback => "aam_refresh()"
};
push @setting, {
key => "aredn.\@alerts[0].localpath",
type => "string",
desc => "Specifies the URL of the location from which local AREDN Alerts can be downloaded.",
default => ""
};
# ----------------------------------------

View File

@ -1908,6 +1908,7 @@ 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");
$local_message = `cat /tmp/local_message` if( -f "/tmp/local_message");
print "<div class=\"TopBanner\">";
@ -1927,6 +1928,7 @@ sub alert_banner
}
}
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;
print "<div style=\"padding:5px;background-color:#FFFF00;border:1px solid #ccc;width:600px;\"><strong>Local Alert(s):</strong><br /><div style=\"text-align:left;\">$local_message</div></div>\n" if $local_message;
#TopBanner
print "</div>";