summaryrefslogtreecommitdiff
path: root/fetcher/fetch.sh
blob: 3c695674c5a515e28024b9d3621ad4915518f162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
pushd $(dirname $0) > /dev/null
wget -N http://ergast.com/downloads/f1db.sql.gz -q
if [[ $? != 0 ]]; then
    if [[ -f f1db.sql.gz ]]; then
        echo "Warning: could not fetch new DB, using archived version"
    else
        echo "Error: could not fetch DB"
        popd > /dev/null
        exit 1
    fi
fi
if [[ f1db.sql.gz -nt f1db.sql ]]; then
    echo "Found new ErgastDB version"
    zcat f1db.sql.gz | sed 's/ ENGINE=MyISAM//' > f1db.sql
    find -name f1db.sql.gz -printf '%f: %Td-%Tm-%TY %TH:%TM, %s bytes\n'
    touch -r f1db.sql.gz f1db.sql
    if [ "$1" == "dump" ]
    then
        cp f1db.sql ../dump/original.sql
        ../dump/convert.sh ../dump/original.sql > ../dump/sqlite.sql
    fi
fi
popd > /dev/null