add bin/add-file-feed-info.sh

This commit is contained in:
dancingCycle 2023-12-16 21:01:39 +01:00
parent 74b9672580
commit a5030d1b6f
2 changed files with 74 additions and 0 deletions

38
bin/add-file-feed-info.sh Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
#
echo "Started..."
#Started...
#
# special variable $# is the number of arguments
if [ $# -lt 2 ] ; then
echo 'Call ./<script> <gtfs zip file path> <gtfs zip file name>'
exit 1
fi
#
gtfsZipFilePath="$1"
echo "gtfsZipFilePath: $gtfsZipFilePath"
gtfsZipFileName=${gtfsZipFilePath}/"$2"
echo "gtfsZipFileName: $gtfsZipFileName"
unzipDir=${gtfsZipFilePath}/unzip
echo "unzipDir: $unzipDir"
baseDir=$(dirname $0)
echo "baseDir: $baseDir"
# extract gtfs archive
rm -rf $unzipDir
mkdir -p $unzipDir
unzip -qq -d $unzipDir $gtfsZipFileName
#
# add file feed_info.txt if not present so that gtfs-sql-importer git repo is not complaining
#
if [ $(unzip -Z -1 "$gtfsZipFileName" | 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
(bash ./${baseDir}/create-file-feed-info.sh $unzipDir)
zip -jr ${gtfsZipFileName}-feed_info.zip ${unzipDir}
fi
#
echo "Done."
#done.

View File

@ -0,0 +1,36 @@
#!/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
echo "start_date: ${feed_start_date}"
feed_end_date=$((${date}+9999))
echo "end_date: ${feed_end_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.