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 is64
#make sure aria2c and wine package is already installed #make sure wine and winetricks package is already installed
# package_installed aria2c
package_installed wine package_installed wine
package_installed md5sum package_installed md5sum
package_installed winetricks package_installed winetricks

View File

@ -1,7 +1,16 @@
#has tow mode [pkgName] [mode=summary]
function package_installed() { function package_installed() {
which $1 &> /dev/null which $1 &> /dev/null
local pkginstalled="$?" local pkginstalled="$?"
if [ "$2" == "summary" ];then
if [ "$pkginstalled" -eq 0 ];then
echo "true"
else
echo "false"
fi
else
if [ "$pkginstalled" -eq 0 ];then if [ "$pkginstalled" -eq 0 ];then
show_message "package\033[1;36m $1\e[0m is installed..." show_message "package\033[1;36m $1\e[0m is installed..."
else else
@ -12,6 +21,7 @@ function package_installed() {
exit 5 exit 5
fi fi
fi fi
fi
} }
function setup_log() { function setup_log() {
@ -131,8 +141,8 @@ function replacement() {
function install_photoshopSE() { function install_photoshopSE() {
local filename="photoshopCC-V19.1.6-2018x64.tgz" local filename="photoshopCC-V19.1.6-2018x64.tgz"
local filemd5="b63f6ed690343ee12b6195424f94c33f" local filemd5="b63f6ed690343ee12b6195424f94c33f"
local filelink="https://victor.poshtiban.io/p/gictor/photoshopCC/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 filelink="http://127.0.0.1:8080/photoshopCC-V19.1.6-2018x64.tgz"
local filepath="$CACHE_PATH/$filename" local filepath="$CACHE_PATH/$filename"
download_component $filepath $filemd5 $filelink $filename download_component $filepath $filemd5 $filelink $filename
@ -204,7 +214,7 @@ function export_var() {
function download_component() { function download_component() {
local tout=0 local tout=0
while true;do while true;do
if [ $tout -ge 2 ];then if [ $tout -ge 3 ];then
error "sorry something went wrong during download $4" error "sorry something went wrong during download $4"
fi fi
if [ -f $1 ];then if [ -f $1 ];then
@ -218,11 +228,22 @@ function download_component() {
fi fi
else else
show_message "downloading $4 ..." show_message "downloading $4 ..."
# aria2c -c -x 8 -d $CACHE_PATH -o $4 $3 pkgres=$(package_installed aria2c "summary")
wget $3 -P $CACHE_PATH 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 if [ $? -eq 0 ];then
notify-send "$4 download completed" -i "download" notify-send "$4 download completed" -i "download"
fi 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++)) ((tout++))
fi fi
done done

View File

@ -51,8 +51,9 @@ main() {
ask_question "would you delete cache directory?" "N" ask_question "would you delete cache directory?" "N"
if [ "$result" == "yes" ];then if [ "$result" == "yes" ];then
rm -rf "$CACHE_PATH" || error2 "couldn't remove cache directory" rm -rf "$CACHE_PATH" || error2 "couldn't remove cache directory"
show_message2 "cache directory removed."
else 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 fi
else else
echo "cache directory Not Found!" echo "cache directory Not Found!"