download with aria2 if available else wget
This commit is contained in:
parent
2177830173
commit
4aaac3f394
|
@ -8,8 +8,7 @@ function main() {
|
|||
|
||||
setup_log "================| script executed |================"
|
||||
|
||||
#make sure aria2c and wine package is already installed
|
||||
# package_installed aria2c
|
||||
#make sure wine package is already installed
|
||||
package_installed wine
|
||||
package_installed md5sum
|
||||
|
||||
|
|
|
@ -102,9 +102,18 @@ function rmdir_if_exist() {
|
|||
show_message "create\033[0;36m $1\e[0m directory..."
|
||||
}
|
||||
|
||||
#has tow mode [pkgName] [mode=summary]
|
||||
function package_installed() {
|
||||
which $1 &> /dev/null
|
||||
local pkginstalled="$?"
|
||||
|
||||
if [ "$2" == "summary" ];then
|
||||
if [ "$pkginstalled" -eq 0 ];then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
else
|
||||
if [ "$pkginstalled" -eq 0 ];then
|
||||
show_message "package\033[1;36m $1\e[0m is installed..."
|
||||
else
|
||||
|
@ -115,6 +124,7 @@ function package_installed() {
|
|||
exit 5
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function export_var() {
|
||||
|
@ -169,7 +179,7 @@ function set_dark_mod() {
|
|||
function download_component() {
|
||||
local tout=0
|
||||
while true;do
|
||||
if [ $tout -ge 2 ];then
|
||||
if [ $tout -ge 3 ];then
|
||||
error "sorry something went wrong during download $4"
|
||||
fi
|
||||
if [ -f $1 ];then
|
||||
|
@ -183,11 +193,22 @@ function download_component() {
|
|||
fi
|
||||
else
|
||||
show_message "downloading $4 ..."
|
||||
# aria2c -c -x 8 -d $CACHE_PATH -o $4 $3
|
||||
wget $3 -P $CACHE_PATH
|
||||
pkgres=$(package_installed aria2c "summary")
|
||||
if [ "$pkgres" == "true" ];then
|
||||
show_message "using aria2c to download $4"
|
||||
aria2c -c -x 8 -d "$CACHE_PATH" -o $4 $3
|
||||
|
||||
if [ $? -eq 0 ];then
|
||||
notify-send "$4 download completed" -i "download"
|
||||
fi
|
||||
else
|
||||
show_message "using wget to download $4"
|
||||
wget "$3" -P "$CACHE_PATH"
|
||||
|
||||
if [ $? -eq 0 ];then
|
||||
notify-send "$4 download completed" -i "download"
|
||||
fi
|
||||
fi
|
||||
((tout++))
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue