-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateweb.bash
executable file
·60 lines (50 loc) · 1.73 KB
/
updateweb.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Get yesterday's RBN data and run a number of analyses on it
# Put result in files rbnskew.txt, rbnskew2.txt, rbnhist.txt
# and anchors.txt and upload them to web host.
#
# Checks if it has already run for today and if it has, exits
#
# Using the command line parameter TEST will only send the
# results to a single email address.
#set -x
# Move to correct folder to allow cron execution on RPi
[ -d "/home/sm7iun/rbnskew" ] && cd /home/sm7iun/rbnskew
DATE=`date -u --date="1 days ago" +%Y%m%d`
OLDESTRES=`date -u --date="5 days ago" +%Y%m%d`.txt
FOLDER="webserver"
echo "---"
echo "Job started "`date -u "+%F %T"` UTC
START=$SECONDS
# Check if we already did the work for today, if so, exit
[ -f $FOLDER/done ] || echo "Never" > $FOLDER/done
if [ "$DATE" == "`cat $FOLDER/done`" ]; then
echo "Nothing to do."
exit
fi
[ -f $FOLDER/$OLDESTRES ] || ./initweb.bash
# Do the work
echo "Downloading RBN data for "`date -u --date="1 days ago" +%Y-%m-%d`
wget --quiet --no-hsts http://www.reversebeacon.net/raw_data/dl.php?f=$DATE -O $FOLDER/rbndata.zip
FILESIZE=$(stat -c%s $FOLDER/rbndata.zip)
if [[ $FILESIZE != "0" ]]; then
gunzip < $FOLDER/rbndata.zip > $FOLDER/rbndata.csv
echo "Downloaded yesterday's "$((`wc -l < $FOLDER/rbndata.csv` - 2))" spots into rbndata.csv"
./makenewref.bash
./$FOLDER/updatewebdata.bash
./$FOLDER/updatehistdata.bash
./$FOLDER/updateanchordata.bash
cd $FOLDER
printf "Uploading to web hosting..."
./upload.bash
printf "done\n"
echo $DATE > done
cd ..
else
echo "Could not download yesterday's RBN data!"
echo "Job failed "`date -u "+%F %T" `
exit
fi
./emailstatus.bash $1
echo "Job ended "`date -u "+%F %T"`" UTC and took $((SECONDS-START)) seconds"
exit