add wget download options
This commit is contained in:
18
split-dl.sh
18
split-dl.sh
@@ -3,6 +3,7 @@
|
|||||||
SPLITSIZE="10M" # Desired size of splitted files
|
SPLITSIZE="10M" # Desired size of splitted files
|
||||||
INFO="info.cfg" # Desired name of document containing information
|
INFO="info.cfg" # Desired name of document containing information
|
||||||
CHECKSUM="md5sum" # Define application to create hashsums
|
CHECKSUM="md5sum" # Define application to create hashsums
|
||||||
|
WGETOPT="-nv --show-progress" # Define options for wget. The default value is good for wget 1.16.x
|
||||||
FILE=""
|
FILE=""
|
||||||
MODE=""
|
MODE=""
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ slow or unstable internet connections."
|
|||||||
Default is $INFO"
|
Default is $INFO"
|
||||||
echo "-c Define the program which should be used to calculate the hashsum.
|
echo "-c Define the program which should be used to calculate the hashsum.
|
||||||
Default is $CHECKSUM"
|
Default is $CHECKSUM"
|
||||||
|
echo "-w Define the options for wget.
|
||||||
|
Default is $WGETOPT"
|
||||||
echo
|
echo
|
||||||
echo "Examples:"
|
echo "Examples:"
|
||||||
echo "Split Hugefile.iso in parts of 50MB and use sha1sum as hashing program."
|
echo "Split Hugefile.iso in parts of 50MB and use sha1sum as hashing program."
|
||||||
@@ -35,7 +38,7 @@ The hashing program has to be the same as on the server side."
|
|||||||
echo " split-dl -m client -f http://example.com/dl-Hugefile.iso -c sha1sum"
|
echo " split-dl -m client -f http://example.com/dl-Hugefile.iso -c sha1sum"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts h:s:i:c:f:m: opt; do
|
while getopts h:s:i:c:w:f:m: opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
h)
|
h)
|
||||||
help
|
help
|
||||||
@@ -50,6 +53,9 @@ while getopts h:s:i:c:f:m: opt; do
|
|||||||
c)
|
c)
|
||||||
CHECKSUM=$OPTARG
|
CHECKSUM=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
w)
|
||||||
|
WGETOPT=$OPTARG
|
||||||
|
;;
|
||||||
f)
|
f)
|
||||||
FILE=$OPTARG
|
FILE=$OPTARG
|
||||||
;;
|
;;
|
||||||
@@ -302,7 +308,7 @@ until [ "$STATUS" == "F" ]; do
|
|||||||
# File doesn't exist yet, so start fresh download
|
# File doesn't exist yet, so start fresh download
|
||||||
if [ ! -e $SMALLPATH ]; then
|
if [ ! -e $SMALLPATH ]; then
|
||||||
echo "[INFO] File doesn't exist yet. Starting new download."
|
echo "[INFO] File doesn't exist yet. Starting new download."
|
||||||
wget -O $SMALLPATH -nv --show-progress $SMALLURL
|
wget -O $SMALLPATH $WGETOPT $SMALLURL
|
||||||
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
||||||
STATUS="C"
|
STATUS="C"
|
||||||
else
|
else
|
||||||
@@ -315,7 +321,7 @@ until [ "$STATUS" == "F" ]; do
|
|||||||
# File already exists but not finished yet
|
# File already exists but not finished yet
|
||||||
elif [ -e $SMALLPATH ] && ! $(compdu $SMALLPATH $SMALLSIZE); then
|
elif [ -e $SMALLPATH ] && ! $(compdu $SMALLPATH $SMALLSIZE); then
|
||||||
echo "[INFO] Continuing download."
|
echo "[INFO] Continuing download."
|
||||||
wget -c -O $SMALLPATH -nv --show-progress $SMALLURL
|
wget -c -O $SMALLPATH $WGETOPT $SMALLURL
|
||||||
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
||||||
STATUS="C"
|
STATUS="C"
|
||||||
else
|
else
|
||||||
@@ -331,7 +337,7 @@ until [ "$STATUS" == "F" ]; do
|
|||||||
echo "[INFO] Deleting file and starting new download."
|
echo "[INFO] Deleting file and starting new download."
|
||||||
checkwait
|
checkwait
|
||||||
rm $SMALLPATH
|
rm $SMALLPATH
|
||||||
wget -O $SMALLPATH -nv --show-progress $SMALLURL
|
wget -O $SMALLPATH $WGETOPT $SMALLURL
|
||||||
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
||||||
STATUS="C"
|
STATUS="C"
|
||||||
else
|
else
|
||||||
@@ -353,7 +359,6 @@ until [ "$STATUS" == "F" ]; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Define time when the download finished
|
# Define time when the download finished
|
||||||
echo
|
|
||||||
TEND=$(date +"%s")
|
TEND=$(date +"%s")
|
||||||
TDIFF=$[$TEND-$TSTART]
|
TDIFF=$[$TEND-$TSTART]
|
||||||
if [ $TDIFF -ge "3" ]; then
|
if [ $TDIFF -ge "3" ]; then
|
||||||
@@ -361,7 +366,8 @@ until [ "$STATUS" == "F" ]; do
|
|||||||
BPS=$[$SMALLSIZE / $TDIFF]
|
BPS=$[$SMALLSIZE / $TDIFF]
|
||||||
DUDIFF=$[$BIGSIZE - $(getdu $FOLDER)]
|
DUDIFF=$[$BIGSIZE - $(getdu $FOLDER)]
|
||||||
TREST=$[$DUDIFF / $BPS]
|
TREST=$[$DUDIFF / $BPS]
|
||||||
echo "[INFO] The last file was downloaded at ~$[$BPS / 1024] KB/s. ETA $(($TREST / 60)):$(($TREST % 60))."
|
echo
|
||||||
|
echo "[INFO] The last file was downloaded at ~$[$BPS / 1024] KB/s. ETA $[$TREST / 60]:$[$TREST % 60] minutes."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if all small downloads are finished
|
# Check if all small downloads are finished
|
||||||
|
|||||||
Reference in New Issue
Block a user