-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·49 lines (38 loc) · 1.24 KB
/
build.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
#!/bin/bash
MONTH=$(date -u +"%b"| tr [a-z] [A-Z])
RELEASEDATE=$(date -u +"%d%H%MZ${MONTH}%y")
echo "Release date: ${RELEASEDATE}"
echo > tmp.txt
for DIR in src/???; do
egrep -hv "^#" ${DIR}/*.txt >> tmp.txt
done
sed -i "/^$/d" tmp.txt
sed -i "s/^\(\"......\"\)/\L\1/g" tmp.txt
sort tmp.txt > tmp_sorted.txt
mv tmp_sorted.txt tmp.txt
cat tmp.txt | jq -cnR 'reduce (inputs / "," | map(fromjson)) as $i ({}; .[$i[0]] = $i[1:])' > cotdb_indexed.json
cat tmp.txt | sed "s/\"//g" | \
jq -cRsn '
{"aircraft":
[inputs
| . / "\n"
| (.[] | select(length > 0) | . / ",") as $input
| {"hexid": $input[0], "cot": $input[1], "reg": $input[2], "type": $input[3], "operator": $input[4]}
]
}
' >cotdb.json
AIRCRAFT=$(jq '. | length' cotdb_indexed.json)
echo ${AIRCRAFT}
sed -i "s/\(message\=\)[0-9]*\&/\1${AIRCRAFT}\&/g" Readme.md
echo '#TAK ADSB IDs' > cotdb.txt
echo '#Copyright 2021 Stefan Gofferje' >> cotdb.txt
echo '#License: CC-BY-SA 4.0' >> cotdb.txt
echo '#Format:' >> cotdb.txt
echo '#"hexid","SIDC","registration","type","operator"' >> cotdb.txt
echo >> cotdb.txt
cat tmp.txt | sort | egrep -v "^$" >> cotdb.txt
rm cotdb.txt tmp.txt
git checkout master
git add .
git commit -a -m "New aircraft (${RELEASEDATE})"
git push origin master