firmware/src/packages/ffol/ath9k-watchdog/files/ath9k-watchdog-pm

26 lines
773 B
Bash
Executable File

#!/bin/sh
# Save log
mkdir -p /usr/lib/ath9k-watchdog
WGETC=$(which wget)
# CD to avoid annoying prefixes
cd /usr/lib/ath9k-watchdog
#Poll directory every 60 secs
while [ 1 = 1 ]
do
if [ "$(ls .)" != "" ]
then
UPLOAD_URL="http://[$(uci get configurator.@api[0].ipv6_address)%$(uci get configurator.@api[0].ipv6_interface)]/api/rest/event/"
for f in $(ls .); do
$WGETC -q $UPLOAD_URL"?api_key=$(uci get configurator.@api[0].api_key)&object=router&object_id="$(uci get configurator.@crawl[0].router_id)"&action=watchdog_ath9k_bug&"$(cat $f) -O - && rm $f
done
# If there are more than 15 files, assume that files cannot be uploaded
# Delete oldest files in order to avoid jffs-overflow
ls -t | sed -e '1,15d' | xargs rm 2> /dev/null
fi
sleep 60
done