-
Notifications
You must be signed in to change notification settings - Fork 3
/
update.sh
executable file
·50 lines (40 loc) · 1.22 KB
/
update.sh
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
#!/bin/bash
# Yeri Tiete
# http://yeri.be
#
# This file should be executed.
#
# some vars.
DATE=`date -u '+%H:%M:%S %d-%m-%Y'`
ISRUNNING=yes
# pull git
git pull
# get country
COUNTRY=`whois \`curl icanhazip.com -s\` | grep country | awk '{ print $2; }' | tr '[:upper:]' '[:lower:]'`
# test
mkdir -p testResults/$COUNTRY/
./checkHosts.sh hosts/hostlist.txt testResults/$COUNTRY/results
# check until wget is no longer running
while [ $ISRUNNING != "no" ]
do
# if there is no wget process anymore, continue
if ! ps x | grep -v grep | grep wget > /dev/null
then
ISRUNNING=no
fi
done
# merge -- this will overwrite the old file
cat testResults/$COUNTRY/results_nok.csv > testResults/$COUNTRY/results.csv
cat testResults/$COUNTRY/results_ok.csv >> testResults/$COUNTRY/results.csv
# sort
sort -f testResults/$COUNTRY/results_nok.csv > /tmp/results_nok.csv
mv /tmp/results_nok.csv testResults/$COUNTRY/results_nok.csv
sort -f testResults/$COUNTRY/results_ok.csv > /tmp/results_ok.csv
mv /tmp/results_ok.csv testResults/$COUNTRY/results_ok.csv
sort -f testResults/$COUNTRY/results.csv > /tmp/results.csv
mv /tmp/results.csv testResults/$COUNTRY/results.csv
# commit
git add .
git commit -m "$COUNTRY check @ $DATE (UTC)"
git push
# EOF