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
|
||||
INFO="info.cfg" # Desired name of document containing information
|
||||
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=""
|
||||
MODE=""
|
||||
|
||||
@@ -25,6 +26,8 @@ slow or unstable internet connections."
|
||||
Default is $INFO"
|
||||
echo "-c Define the program which should be used to calculate the hashsum.
|
||||
Default is $CHECKSUM"
|
||||
echo "-w Define the options for wget.
|
||||
Default is $WGETOPT"
|
||||
echo
|
||||
echo "Examples:"
|
||||
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"
|
||||
}
|
||||
|
||||
while getopts h:s:i:c:f:m: opt; do
|
||||
while getopts h:s:i:c:w:f:m: opt; do
|
||||
case $opt in
|
||||
h)
|
||||
help
|
||||
@@ -50,6 +53,9 @@ while getopts h:s:i:c:f:m: opt; do
|
||||
c)
|
||||
CHECKSUM=$OPTARG
|
||||
;;
|
||||
w)
|
||||
WGETOPT=$OPTARG
|
||||
;;
|
||||
f)
|
||||
FILE=$OPTARG
|
||||
;;
|
||||
@@ -302,7 +308,7 @@ until [ "$STATUS" == "F" ]; do
|
||||
# File doesn't exist yet, so start fresh download
|
||||
if [ ! -e $SMALLPATH ]; then
|
||||
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
|
||||
STATUS="C"
|
||||
else
|
||||
@@ -315,7 +321,7 @@ until [ "$STATUS" == "F" ]; do
|
||||
# File already exists but not finished yet
|
||||
elif [ -e $SMALLPATH ] && ! $(compdu $SMALLPATH $SMALLSIZE); then
|
||||
echo "[INFO] Continuing download."
|
||||
wget -c -O $SMALLPATH -nv --show-progress $SMALLURL
|
||||
wget -c -O $SMALLPATH $WGETOPT $SMALLURL
|
||||
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
||||
STATUS="C"
|
||||
else
|
||||
@@ -331,7 +337,7 @@ until [ "$STATUS" == "F" ]; do
|
||||
echo "[INFO] Deleting file and starting new download."
|
||||
checkwait
|
||||
rm $SMALLPATH
|
||||
wget -O $SMALLPATH -nv --show-progress $SMALLURL
|
||||
wget -O $SMALLPATH $WGETOPT $SMALLURL
|
||||
if $(compall $SMALLPATH $SMALLSIZE $SMALLHASH); then
|
||||
STATUS="C"
|
||||
else
|
||||
@@ -353,7 +359,6 @@ until [ "$STATUS" == "F" ]; do
|
||||
fi
|
||||
|
||||
# Define time when the download finished
|
||||
echo
|
||||
TEND=$(date +"%s")
|
||||
TDIFF=$[$TEND-$TSTART]
|
||||
if [ $TDIFF -ge "3" ]; then
|
||||
@@ -361,7 +366,8 @@ until [ "$STATUS" == "F" ]; do
|
||||
BPS=$[$SMALLSIZE / $TDIFF]
|
||||
DUDIFF=$[$BIGSIZE - $(getdu $FOLDER)]
|
||||
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
|
||||
|
||||
# Check if all small downloads are finished
|
||||
|
||||
Reference in New Issue
Block a user