forked from amigocloud/gtfs-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_data.sh
executable file
·71 lines (61 loc) · 2.11 KB
/
load_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
69
70
71
#!/bin/bash
###
#
# GTFS Manager Load Data and Rebuild OpenTripPlanner Graph object daily script
#
# @author LinuxWebExpert - see GitHub
# @date 10/01/2017
# @see https://github.com/vta/
#
###
MAILTO=""
OTP_DIR="/srv/tripplanner"
DATA_DIR="$OTP_DIR/data"
GTFSM="python $OTP_DIR/gtfs-manager/src/gtfs-manager/gtfsmanager.py"
GTFSM_TEMP_DIR="$OTP_DIR/data_tmp"
# Change working directory to data folder and confirm
cd $DATA_DIR
pwd
# Safely use curl with options to download OpenStreetMap latest map archive with error handling
curl -f -L -w "HTTP Result Code: %{http_code}\nContent-Type: %{content_type}\nFilesize: %{size_download}\nTotal Time: %{time_total}" -o map.osm.bz2 https://s3-us-west-2.amazonaws.com/gis-busstops-inventory/OSM+bayarea+network+older+prod+version/map.osm.bz2
res=$?
if test "$res" != "0"; then
printf "ERROR Curl fetch of OpenStreetMap failed - exit code: $res"
elif test "$res" == "0"; then
rm -f map.osm
bunzip2 map.osm.bz2
res=$?
if test "$res" != "0"; then
printf "ERROR OSM archive is corrupted - exit code: $res"
exit $res
fi
fi
# Change to data tmp directory and confirm
cd $GTFSM_TEMP_DIR
pwd
# Execute GTFS Manager for all agency feeds from config file
$GTFSM -o $DATA_DIR/ ALL ALL
# Change directory to OpenTripPlanner and confirm
cd $OTP_DIR/otp
pwd
# Java startup configuration for OpenTripPlanner instance
jrun="java -Xmx6G -Xverify:none -jar $OTP_DIR/otp/otp-1.2.0-shaded.jar --build $OTP_DIR/data/ --cache $OTP_DIR/otp/ned --verbose"
# Captures today's date for log file
now=`date +%F`
# Execute Java OpenTripPlanner rebuild of Graph.obj with a log handler
$jrun
res=$?
echo "JRUN RESULT CODE: $res\n"
if test "$res" != "0"; then
printf "ERROR Java build of Graph.obj failed - exit code: $res"
else
# Copy the new Graph.obj to OpenTripPlanner default directory
cp -v $DATA_DIR/Graph.obj $DATA_DIR/graphs/default/
res=$?
if test "$res" != "0"; then
printf "ERROR Cannot copy new Graph.obj to default directory - exit code: $res"
fi
fi
# Restart the supervisor service to reload the new Graph.obj
/usr/bin/supervisorctl restart vta:vta_otp
exit 0