feat(gtfs): add gtfs
This commit is contained in:
parent
8eee9241ce
commit
fac1263226
|
@ -0,0 +1,4 @@
|
|||
HOME=<set variable!>
|
||||
# m h dom mon dow command
|
||||
23 0 * * Tue,Thu cd $HOME/git/gtfs4delfi/dload && sh ./dload.sh <work dir> <url>
|
||||
27 0 * * Tue,Thu echo 'Next!'
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
echo "Started..."
|
||||
#Started...
|
||||
#
|
||||
# special variable $# is the number of arguments
|
||||
if [ $# -lt 2 ] ; then
|
||||
echo 'Call ./<script> <work dir> <dload URL>'
|
||||
exit 1
|
||||
fi
|
||||
#
|
||||
WORK_DIR="$1"
|
||||
echo "WORK_DIR: $WORK_DIR"
|
||||
dloadDir=${WORK_DIR}/gtfs
|
||||
echo "dloadDir: $dloadDir"
|
||||
rm -r $dloadDir
|
||||
mkdir -p $dloadDir
|
||||
logFile=${dloadDir}/wget-log.txt
|
||||
echo "logFile: $logFile"
|
||||
dloadFile=${dloadDir}/gtfs.zip
|
||||
echo "dloadFile: $dloadFile"
|
||||
dloadUrl=$2
|
||||
echo "dloadUrl: $dloadUrl"
|
||||
wget -o $logFile -O $dloadFile $dloadUrl
|
||||
#
|
||||
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
|
||||
echo "Done."
|
||||
#done.
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
echo "Started..."
|
||||
#Started...
|
||||
#
|
||||
# special variable $# is the number of arguments
|
||||
if [ $# -lt 1 ]; then
|
||||
echo 'Call ./<script> <work dir>'
|
||||
exit 1
|
||||
fi
|
||||
#
|
||||
file=${1}/feed_info.txt
|
||||
echo "file: "
|
||||
echo $file
|
||||
rm $file
|
||||
touch ${file}
|
||||
head='feed_publisher_name,feed_publisher_url,feed_lang,feed_start_date,feed_end_date,feed_version'
|
||||
echo "head: "
|
||||
echo $head
|
||||
echo $head >> ${file}
|
||||
date=$(date +"%Y%m%d")
|
||||
feed_publisher_name=DELFI
|
||||
feed_publisher_url=https://delfi.de
|
||||
feed_lang=de
|
||||
feed_start_date=$date
|
||||
feed_end_date=$date
|
||||
feed_version=1
|
||||
entry=${feed_publisher_name},${feed_publisher_url},${feed_lang},${feed_start_date},${feed_end_date},${feed_version}
|
||||
echo "entry: "
|
||||
echo $entry
|
||||
echo $entry >> ${file}
|
||||
#
|
||||
echo "Done."
|
||||
#done.
|
Loading…
Reference in New Issue