-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch-airfield-data.sh
executable file
·68 lines (52 loc) · 2.06 KB
/
fetch-airfield-data.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh -e
FLIGHTS=/mnt/blacklibrary/aviation/tracks/csv/Export-g.csv
FLIGHTS_CLEAN=/tmp/Export-g-$$.cvs
cat ${FLIGHTS} | grep -v Bemerkung | grep -v Zeitspanne > ${FLIGHTS_CLEAN}
if [ -r ${FLIGHTS_CLEAN} ]
then
while IFS= read -r line; do
# Remove quotes from the entire line
line=$(echo "$line" | sed 's/"//g')
DATE=$(echo ${line} | cut -d';' -f1)
# Convert the date format from dd.mm.yyyy to yyyy-mm-dd
DATE_YYYY_MM_DD=$(echo "$DATE" | awk -F'.' '{ printf("%s-%s-%s", $3, $2, $1) }')
DATE_YYYY_MM=$(echo "$DATE" | awk -F'.' '{ printf("%s-%s", $3, $2, $1) }')
DATE_YYYY=$(echo "$DATE" | awk -F'.' '{ printf("%s", $3, $2, $1) }')
AD_FROM=$(echo ${line} | cut -d';' -f4)
AD_FROM_ICAO=$(echo "${AD_FROM}" | awk '{print $NF}')
AD_TO=$(echo ${line} | cut -d';' -f5)
AD_TO_ICAO=$(echo "${AD_TO}" | awk '{print $NF}')
# echo ${DATE} - ${DATE_YYYY_MM_DD} - ${DATE_YYYY_MM} - ${DATE_YYYY} - ${AD_FROM} - ${AD_TO} - ${AD_FROM_ICAO} - ${AD_TO_ICAO}
if [ -r "${DATA}/${AD_FROM}-Platzrunde.gpx" ]
then
if [ -d ${DATA}/${DATE_YYYY} ]
then
cp ${DATA}/${AD_FROM}-* ${DATA}/${DATE_YYYY}
fi
if [ -d ${DATA}/${DATE_YYYY_MM} ]
then
cp ${DATA}/${AD_FROM}-* ${DATA}/${DATE_YYYY_MM_DD}
fi
if [ -d ${DATA}/${DATE_YYYY_MM} ]
then
cp ${DATA}/${AD_FROM}-* ${DATA}/${DATE_YYYY_MM_DD}
fi
fi
if [ -r "${DATA}/${AD_TO}-Platzrunde.gpx" ]
then
if [ -d ${DATA}/${DATE_YYYY} ]
then
cp ${DATA}/${AD_TO}-* ${DATA}/${DATE_YYYY}
fi
if [ -d ${DATA}/${DATE_YYYY_MM} ]
then
cp ${DATA}/${AD_TO}-* ${DATA}/${DATE_YYYY_MM_DD}
fi
if [ -d ${DATA}/${DATE_YYYY_MM} ]
then
cp ${DATA}/${AD_TO}-* ${DATA}/${DATE_YYYY_MM_DD}
fi
fi
done < "${FLIGHTS_CLEAN}"
fi
rm -f ${FLIGHTS_CLEAN}