Add file size tests to arednMsg

Add tests for file content to aredn_message.sh
This commit is contained in:
Steve Lewis AB7PA 2020-08-31 07:34:38 -07:00 committed by Joe AE6XE
parent afb18b3a52
commit ad578d8944
1 changed files with 28 additions and 18 deletions

View File

@ -44,21 +44,26 @@ nodename=$(echo "$HOSTNAME" | tr 'A-Z' 'a-z')
if [ $online = "true" ] if [ $online = "true" ]
then then
# fetch node specific message file # fetch node specific message file
# nodename=$(echo "$HOSTNAME" | tr 'A-Z' 'a-z') wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/"${nodename}".txt &&
wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/"${nodename}".txt [ -s /tmp/aredn_message ] &&
echo "<strong>&#8611; ${nodename}:</strong>"|cat - /tmp/aredn_message > /tmp/out && mv /tmp/out /tmp/aredn_message echo "<strong>&#8611; ${nodename}:</strong>"|cat - /tmp/aredn_message > /tmp/out &&
mv /tmp/out /tmp/aredn_message
if [ $? -ne 0 ] # no node specific file if [ $? -ne 0 ] # no node specific file
then then
# fetch broadcast message file # fetch broadcast message file
wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/all.txt wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/all.txt &&
echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/aredn_message > /tmp/out && mv /tmp/out /tmp/aredn_message [ -s /tmp/aredn_message ] &&
echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/aredn_message > /tmp/out &&
mv /tmp/out /tmp/aredn_message
else else
# need to append to node file # need to append to node file
wget -q -O aredn_message_all -P /tmp http://downloads.arednmesh.org/messages/all.txt && wget -q -O aredn_message_all -P /tmp http://downloads.arednmesh.org/messages/all.txt &&
echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/aredn_message_all > /tmp/out && mv /tmp/out /tmp/aredn_message_all [ -s /tmp/aredn_message_all ] &&
echo "<br />" >> /tmp/aredn_message; echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/aredn_message_all > /tmp/out &&
cat /tmp/aredn_message_all >> /tmp/aredn_message; mv /tmp/out /tmp/aredn_message_all
rm /tmp/aredn_message_all; echo "<br />" >> /tmp/aredn_message
cat /tmp/aredn_message_all >> /tmp/aredn_message
rm /tmp/aredn_message_all
fi fi
fi fi
@ -67,20 +72,25 @@ fi
alertslocalpath=$(uci -q get aredn.@alerts[0].localpath) alertslocalpath=$(uci -q get aredn.@alerts[0].localpath)
if [ ! -z "$alertslocalpath" ]; then if [ ! -z "$alertslocalpath" ]; then
# fetch node specific message file # fetch node specific message file
wget -q -O local_message -P /tmp "${alertslocalpath}/${nodename}".txt wget -q -O local_message -P /tmp "${alertslocalpath}/${nodename}".txt &&
echo "<strong>&#8611; ${nodename}:</strong>"|cat - /tmp/local_message > /tmp/out && mv /tmp/out /tmp/local_message [ -s /tmp/local_message ] &&
echo "<strong>&#8611; ${nodename}:</strong>"|cat - /tmp/local_message > /tmp/out &&
mv /tmp/out /tmp/local_message
if [ $? -ne 0 ] # no node specific file if [ $? -ne 0 ] # no node specific file
then then
# fetch broadcast message file # fetch broadcast message file
wget -q -O local_message -P /tmp "${alertslocalpath}/all.txt" wget -q -O local_message -P /tmp "${alertslocalpath}/all.txt" &&
echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/local_message > /tmp/out && mv /tmp/out /tmp/local_message [ -s /tmp/local_message ] &&
echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/local_message > /tmp/out &&
mv /tmp/out /tmp/local_message
else else
# need to append to node file # need to append to node file
wget -q -O local_message_all -P /tmp "${alertslocalpath}/all.txt" && wget -q -O local_message_all -P /tmp "${alertslocalpath}/all.txt" &&
echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/local_message_all > /tmp/out && mv /tmp/out /tmp/local_message_all [ -s /tmp/local_message_all ] &&
echo "<br />" >> /tmp/local_message; echo "<strong>&#8611; all nodes:</strong>"|cat - /tmp/local_message_all > /tmp/out &&
[ -f /tmp/local_message_all ] && mv /tmp/out /tmp/local_message_all
echo "<br />" >> /tmp/local_message
cat /tmp/local_message_all >> /tmp/local_message && cat /tmp/local_message_all >> /tmp/local_message &&
rm /tmp/local_message_all; rm /tmp/local_message_all
fi fi
fi fi