summaryrefslogtreecommitdiff
path: root/getjson.sh
diff options
context:
space:
mode:
Diffstat (limited to 'getjson.sh')
-rwxr-xr-xgetjson.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/getjson.sh b/getjson.sh
new file mode 100755
index 0000000..3ff6080
--- /dev/null
+++ b/getjson.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+if [ ! -f ./timetable_full.json ]; then
+ curl https://admin.libertybus.je/cache/timetables/timetable_full.json > ./timetable_full.json
+ md5sum ./timetable_full.json | cut -f1 -d ' ' > timetable_full.json.md5hash.txt
+else
+ curl https://admin.libertybus.je/cache/timetables/timetable_full.json > ./timetable_full.new.json
+ newHash=`md5sum timetable_full.new.json | cut -f1 -d ' '`
+ if [ $newHash != ./timetable_full.json.md5hash.txt ]; then
+ rm ./timetable_full.json && rm ./timetable_full.json.md5hash.txt
+ mv ./timetable_full.new.json ./timetable_full.json
+ echo "$newHash" > ./timetable_full.json.md5hash.txt
+ fi
+fi
+if [ ! -f ./service_updates.json ]; then
+ curl https://admin.libertybus.je/api/v1/service_updates > ./service_updates.json
+ md5sum ./service_updates.json | cut -f1 -d ' ' > service_updates.json.md5hash.txt
+else
+ curl https://admin.libertybus.je/api/v1/service_updates > ./service_updates.new.json
+ newHash=`md5sum service_updates.new.json | cut -f1 -d ' '`
+ if [ $newHash != ./service_updates.json.md5hash.txt ]; then
+ rm ./service_updates.json && rm ./service_updates.json.md5hash.txt
+ mv ./service_updates.new.json ./service_updates.json
+ echo "$newHash" > ./service_updates.json.md5hash.txt
+ fi
+fi