mirror of https://github.com/aredn/aredn.git
Add file size tests to arednMsg
Add tests for file content to aredn_message.sh
This commit is contained in:
parent
afb18b3a52
commit
ad578d8944
|
@ -44,21 +44,26 @@ nodename=$(echo "$HOSTNAME" | tr 'A-Z' 'a-z')
|
|||
if [ $online = "true" ]
|
||||
then
|
||||
# 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
|
||||
echo "<strong>↣ ${nodename}:</strong>"|cat - /tmp/aredn_message > /tmp/out && mv /tmp/out /tmp/aredn_message
|
||||
wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/"${nodename}".txt &&
|
||||
[ -s /tmp/aredn_message ] &&
|
||||
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>↣ all nodes:</strong>"|cat - /tmp/aredn_message > /tmp/out && mv /tmp/out /tmp/aredn_message
|
||||
wget -q -O aredn_message -P /tmp http://downloads.arednmesh.org/messages/all.txt &&
|
||||
[ -s /tmp/aredn_message ] &&
|
||||
echo "<strong>↣ all nodes:</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>↣ all nodes:</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;
|
||||
[ -s /tmp/aredn_message_all ] &&
|
||||
echo "<strong>↣ all nodes:</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
|
||||
|
||||
|
@ -67,20 +72,25 @@ fi
|
|||
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>↣ ${nodename}:</strong>"|cat - /tmp/local_message > /tmp/out && mv /tmp/out /tmp/local_message
|
||||
wget -q -O local_message -P /tmp "${alertslocalpath}/${nodename}".txt &&
|
||||
[ -s /tmp/local_message ] &&
|
||||
echo "<strong>↣ ${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>↣ all nodes:</strong>"|cat - /tmp/local_message > /tmp/out && mv /tmp/out /tmp/local_message
|
||||
wget -q -O local_message -P /tmp "${alertslocalpath}/all.txt" &&
|
||||
[ -s /tmp/local_message ] &&
|
||||
echo "<strong>↣ all nodes:</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>↣ all nodes:</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 ] &&
|
||||
[ -s /tmp/local_message_all ] &&
|
||||
echo "<strong>↣ all nodes:</strong>"|cat - /tmp/local_message_all > /tmp/out &&
|
||||
mv /tmp/out /tmp/local_message_all
|
||||
echo "<br />" >> /tmp/local_message
|
||||
cat /tmp/local_message_all >> /tmp/local_message &&
|
||||
rm /tmp/local_message_all;
|
||||
rm /tmp/local_message_all
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue