Skip to content

Commit 15e9c23

Browse files
authored
Create get-latest-digiroad-datav2.sh
1 parent 47f58c7 commit 15e9c23

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

get-latest-digiroad-datav2.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Assign the filename
4+
filename="/root/digiroad.sh"
5+
6+
# Get offline version info
7+
offlineversion=0
8+
9+
# Get latest data from Digiroad server
10+
onlineversion=$(curl -s -I https://ava.vaylapilvi.fi/ava/Tie/Digiroad/Aineistojulkaisut/latest/KokoSuomi_DIGIROAD_R_EUREF-FIN.zip | awk '/last-modified/{ date=""; for(i=2;i<=NF;++i) date=(date " " $i); print date;}' | xargs -I{} date -d {} +"%s")
11+
12+
# Compare if online version is newer than previously recorded
13+
if [ $onlineversion -gt $offlineversion ]
14+
then
15+
echo New KokoSuomi_DIGIROAD_R_EUREF-FIN.zip detected. Downloading to /opt/KokoSuomi_DIGIROAD_R_EUREF-FIN.zip
16+
curl -o /opt/KokoSuomi_DIGIROAD_R_EUREF-FIN.zip https://ava.vaylapilvi.fi/ava/Tie/Digiroad/Aineistojulkaisut/latest/KokoSuomi_DIGIROAD_R_EUREF-FIN.zip
17+
# Change latest digiroad version for downloaded version
18+
sed -i "s/$offlineversion/$onlineversion/" $filename
19+
20+
else
21+
echo No new version of KokoSuomi_DIGIROAD_R_EUREF-FIN.zip found.
22+
fi
23+
echo Done

0 commit comments

Comments
 (0)