-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathimport.sh
executable file
·74 lines (52 loc) · 1.45 KB
/
import.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
69
70
71
72
73
74
#!/bin/bash
# Usage:
#
# poetry run ./import.sh username password
#
# Where 'username' and 'password' are your username and password for the
# Traveline National Dataset FTP server
if [[ ! -f manage.py ]] ; then
echo './manage.py not found, exiting'
exit 1
fi
# create lockfile
# I think it's important that this goes before the `trap`
mkdir /var/lock/bustimes-import || {
echo "An import appears to be running already"
exit 1
}
function finish {
# remove lockfile
rmdir /var/lock/bustimes-import 2> /dev/null
}
trap finish EXIT SIGINT SIGTERM
USERNAME=$1
PASSWORD=$2
./manage.py nptg_new
./manage.py naptan_new
./manage.py naptan_new "Irish NaPTAN"
cd data/TNDS
ncsd_old=$(ls -l NCSD.zip)
wget -qN https://bodds-prod-coach-data.s3.eu-west-2.amazonaws.com/TxC-2.4.zip -O NCSD.zip
ncsd_new=$(ls -l NCSD.zip)
tfl_old=$(ls -l L.zip)
wget -qN https://tfl.gov.uk/tfl/syndication/feeds/journey-planner-timetables.zip -O L.zip
tfl_new=$(ls -l L.zip)
cd ../..
if [[ $ncsd_old != $ncsd_new ]]; then
echo 'NCSD.zip'
./manage.py import_transxchange data/TNDS/NCSD.zip
fi
if [[ $tfl_old != $tfl_new ]]; then
echo 'L.zip'
./manage.py import_transxchange data/TNDS/L.zip
fi
./manage.py import_noc
if [[ $USERNAME == '' || $PASSWORD == '' ]]; then
echo 'TNDS username and/or password not supplied :('
exit 1
fi
./manage.py import_tnds "$USERNAME" "$PASSWORD"
./manage.py import_gtfs
./manage.py update_search_indexes
finish