using aria2 if available else using wget to download files

This commit is contained in:
victor 2021-01-06 11:30:38 +03:30
parent 0ca346c398
commit df99154c49
3 changed files with 40 additions and 19 deletions

View File

@ -10,8 +10,7 @@ function main() {
is64
#make sure aria2c and wine package is already installed
# package_installed aria2c
#make sure wine and winetricks package is already installed
package_installed wine
package_installed md5sum
package_installed winetricks

View File

@ -1,15 +1,25 @@
#has tow mode [pkgName] [mode=summary]
function package_installed() {
which $1 &> /dev/null
local pkginstalled="$?"
if [ "$pkginstalled" -eq 0 ];then
show_message "package\033[1;36m $1\e[0m is installed..."
else
warning "package\033[1;33m $1\e[0m is not installed.\nplease make sure it's already installed"
ask_question "would you continue?" "N"
if [ "$question_result" == "no" ];then
echo "exit..."
exit 5
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
warning "package\033[1;33m $1\e[0m is not installed.\nplease make sure it's already installed"
ask_question "would you continue?" "N"
if [ "$question_result" == "no" ];then
echo "exit..."
exit 5
fi
fi
fi
}
@ -131,8 +141,8 @@ function replacement() {
function install_photoshopSE() {
local filename="photoshopCC-V19.1.6-2018x64.tgz"
local filemd5="b63f6ed690343ee12b6195424f94c33f"
local filelink="https://victor.poshtiban.io/p/gictor/photoshopCC/photoshopCC-V19.1.6-2018x64.tgz"
# local filelink="http://127.0.0.1:8080/photoshopCC-V19.1.6-2018x64.tgz"
# local filelink="https://victor.poshtiban.io/p/gictor/photoshopCC/photoshopCC-V19.1.6-2018x64.tgz"
local filelink="http://127.0.0.1:8080/photoshopCC-V19.1.6-2018x64.tgz"
local filepath="$CACHE_PATH/$filename"
download_component $filepath $filemd5 $filelink $filename
@ -204,7 +214,7 @@ function export_var() {
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
@ -218,14 +228,25 @@ function download_component() {
fi
else
show_message "downloading $4 ..."
# aria2c -c -x 8 -d $CACHE_PATH -o $4 $3
wget $3 -P $CACHE_PATH
if [ $? -eq 0 ];then
notify-send "$4 download completed" -i "download"
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
done
}
function rmdir_if_exist() {

View File

@ -51,8 +51,9 @@ main() {
ask_question "would you delete cache directory?" "N"
if [ "$result" == "yes" ];then
rm -rf "$CACHE_PATH" || error2 "couldn't remove cache directory"
show_message2 "cache directory removed."
else
echo "nice, you can copy component data and use them later for photoshop installation"
echo "nice, you can use downloaded data later for photoshop installation"
fi
else
echo "cache directory Not Found!"