feat(gtfs): add gtfs/dload-gtfs.sh
This commit is contained in:
parent
0c0c4a916b
commit
a0ae2720cf
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
echo "Started..."
|
||||
#Started...
|
||||
#
|
||||
# special variable $# is the number of arguments
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo 'Call ./<script> <work dir>'
|
||||
exit 1
|
||||
fi
|
||||
#
|
||||
WORK_DIR="$1"
|
||||
echo "WORK_DIR: $WORK_DIR"
|
||||
dloadDir=${WORK_DIR}/gtfs
|
||||
echo "dloadDir: $dloadDir"
|
||||
# rm -rf: descend into write-protected directory
|
||||
rm -rf $dloadDir
|
||||
mkdir -p $dloadDir
|
||||
logFile=${dloadDir}/wget-log.txt
|
||||
echo "logFile: $logFile"
|
||||
dloadFile=${dloadDir}/gtfs.zip
|
||||
echo "dloadFile: $dloadFile"
|
||||
wget -o $logFile -O $dloadFile 'https://www.opendata-oepnv.de/index.php?id=1384&tx_vrrkit_view%5Bsharing%5D=eyJkYXRhc2V0IjoiZGV1dHNjaGxhbmR3ZWl0ZS1zb2xsZmFocnBsYW5kYXRlbi1ndGZzIiwidXNlcklkIjoxNjE0fQ%3D%3D&tx_vrrkit_view%5Baction%5D=download&tx_vrrkit_view%5Bcontroller%5D=View'
|
||||
#
|
||||
unzipDir=${dloadDir}/unzip
|
||||
echo "unzipDir: $unzipDir"
|
||||
mkdir -p $unzipDir
|
||||
unzip -qq -d $unzipDir $dloadFile
|
||||
#
|
||||
# add file feed_info.txt if not present so that gtfs-sql-importer git repo is not complaining
|
||||
#
|
||||
if [ $(unzip -Z -1 "$dloadFile" | grep feed_info.txt) ];
|
||||
then
|
||||
echo "feed_info.txt present"
|
||||
else
|
||||
echo "feed_info.txt NOT present"
|
||||
# (): replaces the shell without creating a new process
|
||||
BASEDIR=$(dirname $0)
|
||||
echo "BASEDIR: ${BASEDIR}"
|
||||
(sh ./${BASEDIR}/feed_info.sh $unzipDir)
|
||||
zip -jr ${dloadFile}-feed_info.zip ${unzipDir}
|
||||
fi
|
||||
#
|
||||
# add file stops_zhv.txt if not present so that gtfs-sql-importer git repo can consider
|
||||
#
|
||||
if [ $(unzip -Z -1 "$dloadFile" | grep stops_zhv.txt) ];
|
||||
then
|
||||
echo "stops_zhv.txt present"
|
||||
else
|
||||
echo "stops_zhv.txt NOT present"
|
||||
# (): replaces the shell without creating a new process
|
||||
BASEDIR=$(dirname $0)
|
||||
echo "BASEDIR: ${BASEDIR}"
|
||||
(sh ./${BASEDIR}/stops_zhv.sh $WORK_DIR)
|
||||
zip -jr ${dloadFile}-stops_zhv.zip ${unzipDir}
|
||||
fi
|
||||
echo "Done."
|
||||
#done.
|
Loading…
Reference in New Issue