feat: add file-dload-curl-cert-while.sh

This commit is contained in:
dancingCycle 2023-11-27 14:36:36 +01:00
parent 34e97f3c33
commit 0b6f6e296e
4 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,34 @@
#!/bin/sh
#
echo "started..."
#
# special variable $# is the number of arguments
if [ $# -lt 7 ] ; then
echo 'Call ./<script> <size: absolute file name> <size: minimum file size in bytes> <size: csv email recipient list> <dload: url> <dload: cert secret> <dload: cert file path & name> <dload: save as abs file path & name>'
exit 1
fi
#
file="$1"
minimumSize="$2"
emailRecipientList="$3"
dloadUrl="$4"
dloadCertKey="$5"
dloadCertFile="$6"
dloadFile="$7"
#
retVal=1;
echo "retVal init: ${retVal}"
#
while [ $retVal -ne 0 ]
do
echo "call file-dload.sh"
sh ./file-dload-curl-cert.sh $dloadUrl $dloadCertKey $dloadCertFile $dloadFile
echo "call file-size.sh"
sh ./file-size.sh $file $minimumSize $emailRecipientList
retVal=$?
echo "retVal: ${retVal}"
done
exit $retVal
#
echo "done."
#done.

24
file-dload-curl-cert.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/sh
#
echo "Started..."
#
# special variable $# is the number of arguments
if [ $# -lt 4 ] ; then
echo 'Call ./<script> <url> <cert secret> <cert file path & name> <save as abs file path & name with SUFFIX /gtfs.gz>'
exit 1
fi
#
downloadUrl="$1"
certSecret="$2"
certPath="$3"
#ATTENTION: use SUFFIX ".../gtfs.gz"
output="$4"
echo "output: ${output}"
#
cd ~
rm -r ${HOME}/gtfs
mkdir -p ${HOME}/gtfs
curl --request GET --url $downloadUrl --header "Accept-Encoding: gzip, deflate" --cert-type P12 --cert ${certPath}:"$certSecret" --output $output
#
echo "Done."
#done.

View File

@ -4,7 +4,7 @@ echo "started..."
#
# special variable $# is the number of arguments
if [ $# -lt 6 ] ; then
echo 'Call ./<script> <size: absolute file name> <size: minimum file size in bytes> <size: csv email recipient list> <dload work dir> <dload: save as file name> <dload: URL>'
echo 'Call ./<script> <size: absolute file name> <size: minimum file size in bytes> <size: csv email recipient list> <dload: work dir> <dload: save as file name> <dload: URL>'
exit 1
fi
#

View File

@ -12,4 +12,16 @@ sh ./file-size.sh ~/Downloads/....pdf 19779 ...@posteo.de,...@hostsharing.net
```
sh ./file-dload-while.sh ~/Downloads/....pbf 19800967 ...@sposteo.de,...@hostsharing.net ~/Downloads ....pbf http://download.geofabrik.de/europe/germany/bremen-latest.osm.pbf
```
## file-dload-curl-cert
```
sh file-dload-curl-cert.sh https://mobilithek.info:8443/mobilithek/api/v1.0/container/subscription?subscriptionID=... <key> ~/.../certificate.p12 ~/.../foo/gtfs.gz
```
## file download using curl --cert while loop
```
sh ./file-dload-curl-cert-while.sh ~/.../gtfs.gz 49800700 ...@hostsharing.net https://mobilithek.info:8443/mobilithek/api/v1.0/container/subscription?subscriptionID=... <key> ~/.../certificate.p12 ~/.../foo/gtfs.gz
```