feat: add dload dir

This commit is contained in:
dancingCycle 2023-05-09 10:48:22 +02:00
parent d35dafdf5c
commit 3fa4b81dc3
2 changed files with 36 additions and 0 deletions

4
dload/crontab Normal file
View File

@ -0,0 +1,4 @@
HOME=<set variable!>
# m h dom mon dow command
23 0 * * Tue,Thu cd $HOME/git/zhv/dload && sh ./dload.sh <work dir> <url>
27 0 * * Tue,Thu echo 'Next!'

32
dload/dload.sh Normal file
View File

@ -0,0 +1,32 @@
#!/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
#
echo "Done."
#done.