2020-02-09 19:00:41 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-02-10 09:14:38 +00:00
|
|
|
|
|
|
|
function main(){
|
2020-02-10 12:38:25 +00:00
|
|
|
|
|
|
|
SCR_PATH="$HOME/.photoshopCCV19"
|
|
|
|
CACHE_PATH="$HOME/.cache/photoshopCCV19"
|
|
|
|
|
|
|
|
mkdir -p $SCR_PATH
|
|
|
|
mkdir -p $CACHE_PATH
|
|
|
|
|
2020-02-10 10:13:07 +00:00
|
|
|
setup_log "================| script executed |================"
|
2020-02-10 12:38:25 +00:00
|
|
|
|
2020-02-10 09:14:38 +00:00
|
|
|
check_arg $1
|
|
|
|
is64
|
2020-02-10 12:38:25 +00:00
|
|
|
|
|
|
|
#make sure aria2c and wine package is already installed
|
2020-02-10 09:14:38 +00:00
|
|
|
package_installed aria2c
|
|
|
|
package_installed wine
|
2020-02-10 12:38:25 +00:00
|
|
|
|
|
|
|
#delete wine3.4 dir if exist then create it
|
|
|
|
WINE_PATH="$SCR_PATH/wine-3.4"
|
|
|
|
rmdir_if_exist $WINE_PATH
|
2020-02-10 10:13:07 +00:00
|
|
|
|
2020-02-10 12:38:25 +00:00
|
|
|
RESOURCES_PATH="$SCR_PATH/resources"
|
2020-02-11 06:38:42 +00:00
|
|
|
|
|
|
|
install_wine34
|
2020-02-11 04:51:08 +00:00
|
|
|
|
2020-02-10 10:13:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setup_log(){
|
2020-02-10 12:38:25 +00:00
|
|
|
echo -e "$(date) : $@" >> $SCR_PATH/setuplog.log
|
2020-02-10 10:13:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_message(){
|
|
|
|
echo -e "$@"
|
|
|
|
setup_log "$@"
|
2020-02-10 09:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function error(){
|
|
|
|
echo -e "\033[1;31merror:\e[0m $@"
|
2020-02-10 10:13:07 +00:00
|
|
|
setup_log "$@"
|
2020-02-10 09:14:38 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function warning(){
|
|
|
|
echo -e "\033[1;33mWarning:\e[0m $@"
|
2020-02-10 10:13:07 +00:00
|
|
|
setup_log "$@"
|
2020-02-10 09:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-11 06:38:42 +00:00
|
|
|
function install_wine34(){
|
|
|
|
local filename="wine-3.4.tgz"
|
|
|
|
local filepath="$CACHE_PATH/$filename"
|
|
|
|
local filemd5="72b485c28e40bba2b73b0d4c0c29a15f"
|
|
|
|
local filelink="http://bit.ly/2Sh9idu"
|
|
|
|
download_component $filepath $filemd5 $filelink $filename
|
|
|
|
tar -xzvf $filepath -C $WINE_PATH 1>/dev/null
|
|
|
|
}
|
|
|
|
|
2020-02-11 04:51:08 +00:00
|
|
|
#parameters is [PATH] [CheckSum] [URL] [FILE NAME]
|
|
|
|
function download_component(){
|
|
|
|
local tout=0
|
|
|
|
while true;do
|
|
|
|
if [ $tout -ge 2 ];then
|
|
|
|
error "sorry somthing went wrong"
|
|
|
|
fi
|
|
|
|
if [ -f $1 ];then
|
|
|
|
local FILE_ID=$(md5sum $1 | cut -d" " -f1)
|
|
|
|
if [ "$FILE_ID" == $2 ];then
|
|
|
|
show_message "\033[1;36m$4\e[0m is detected"
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
show_message "md5 is not match"
|
|
|
|
rm $1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
show_message "downloading $4"
|
|
|
|
aria2c -c -x 8 -d $CACHE_PATH -o $4 $3
|
|
|
|
((tout++))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-02-10 12:38:25 +00:00
|
|
|
function rmdir_if_exist(){
|
|
|
|
if [ -d "$1" ];then
|
|
|
|
rm -rf $1
|
|
|
|
show_message "\033[0;36m$1\e[0m directory exists deleting it..."
|
|
|
|
fi
|
|
|
|
mkdir $1
|
|
|
|
show_message "create\033[0;36m $1\e[0m directory..."
|
|
|
|
}
|
|
|
|
|
2020-02-10 09:14:38 +00:00
|
|
|
function check_arg(){
|
|
|
|
if [ $1 != 0 ]
|
|
|
|
then
|
|
|
|
error "It haven't any parameter just execute script"
|
|
|
|
fi
|
2020-02-10 10:13:07 +00:00
|
|
|
show_message "argument checked..."
|
2020-02-10 09:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function is64(){
|
|
|
|
local arch=$(uname -m)
|
|
|
|
if [ $arch != "x86_64" ];then
|
|
|
|
warning "your distro is not 64 bit"
|
|
|
|
read -r -p "Would you continue? [N/y] " response
|
|
|
|
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]];then
|
2020-02-10 10:13:07 +00:00
|
|
|
echo "Good Bye!"
|
2020-02-10 09:14:38 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
2020-02-10 10:13:07 +00:00
|
|
|
show_message "is64 checked..."
|
2020-02-10 09:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function package_installed(){
|
|
|
|
local which=$(which $1 2>/dev/null)
|
|
|
|
if [ "$which" == "/usr/bin/$1" ];then
|
2020-02-10 10:13:07 +00:00
|
|
|
show_message "package\033[1;36m $1\e[0m is installed..."
|
2020-02-10 09:14:38 +00:00
|
|
|
else
|
|
|
|
error "package\033[1;33m $1\e[0m is not installed.\nplease install it and Try again"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main $# $@
|