2020-05-19 13:31:52 +00:00
|
|
|
|
2021-01-06 08:00:38 +00:00
|
|
|
#has tow mode [pkgName] [mode=summary]
|
2020-12-29 18:16:49 +00:00
|
|
|
function package_installed() {
|
2020-12-30 21:05:49 +00:00
|
|
|
which $1 &> /dev/null
|
|
|
|
local pkginstalled="$?"
|
2021-01-06 08:00:38 +00:00
|
|
|
|
|
|
|
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
|
2020-05-19 14:44:57 +00:00
|
|
|
fi
|
2020-05-19 13:31:52 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function setup_log() {
|
2020-05-19 13:31:52 +00:00
|
|
|
echo -e "$(date) : $@" >> $SCR_PATH/setuplog.log
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function show_message() {
|
2020-05-19 13:31:52 +00:00
|
|
|
echo -e "$@"
|
|
|
|
setup_log "$@"
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function error() {
|
2020-05-19 13:31:52 +00:00
|
|
|
echo -e "\033[1;31merror:\e[0m $@"
|
|
|
|
setup_log "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function error2() {
|
2020-05-19 13:31:52 +00:00
|
|
|
echo -e "\033[1;31merror:\e[0m $@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function warning() {
|
2020-05-19 13:31:52 +00:00
|
|
|
echo -e "\033[1;33mWarning:\e[0m $@"
|
|
|
|
setup_log "$@"
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function warning2() {
|
2020-05-19 13:53:16 +00:00
|
|
|
echo -e "\033[1;33mWarning:\e[0m $@"
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function show_message2() {
|
2020-05-19 13:53:16 +00:00
|
|
|
echo -e "$@"
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function launcher() {
|
2020-05-29 16:05:54 +00:00
|
|
|
|
|
|
|
#create launcher script
|
2020-05-19 13:31:52 +00:00
|
|
|
local launcher_path="$PWD/launcher.sh"
|
2020-05-29 16:05:54 +00:00
|
|
|
local launcher_dest="$SCR_PATH/launcher"
|
|
|
|
rmdir_if_exist "$launcher_dest"
|
|
|
|
|
2020-05-19 13:31:52 +00:00
|
|
|
|
|
|
|
if [ -f "$launcher_path" ];then
|
|
|
|
show_message "launcher.sh detected..."
|
2020-05-29 16:05:54 +00:00
|
|
|
|
|
|
|
cp "$launcher_path" "$launcher_dest" || error "can't copy launcher"
|
|
|
|
|
|
|
|
sed -i "s|pspath|$SCR_PATH|g" "$launcher_dest/launcher.sh" && sed -i "s|pscache|$CACHE_PATH|g" "$launcher_dest/launcher.sh" || error "can't edit launcher script"
|
|
|
|
|
|
|
|
chmod +x "$SCR_PATH/launcher/launcher.sh" || error "can't chmod launcher script"
|
2020-05-19 13:31:52 +00:00
|
|
|
else
|
|
|
|
error "launcher.sh Note Found"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#create desktop entry
|
|
|
|
local desktop_entry="$PWD/photoshop.desktop"
|
2021-01-01 13:19:19 +00:00
|
|
|
local desktop_entry_dest="/home/$USER/.local/share/applications/photoshop.desktop"
|
2020-05-19 13:31:52 +00:00
|
|
|
|
|
|
|
if [ -f "$desktop_entry" ];then
|
|
|
|
show_message "desktop entry detected..."
|
2021-01-01 13:19:19 +00:00
|
|
|
|
2020-05-19 13:31:52 +00:00
|
|
|
#delete desktop entry if exists
|
|
|
|
if [ -f "$desktop_entry_dest" ];then
|
|
|
|
show_message "desktop entry exist deleted..."
|
2021-01-01 13:19:19 +00:00
|
|
|
rm "$desktop_entry_dest"
|
2020-05-19 13:31:52 +00:00
|
|
|
fi
|
2021-01-01 13:19:19 +00:00
|
|
|
cp "$desktop_entry" "$desktop_entry_dest" || error "can't copy desktop entry"
|
|
|
|
sed -i "s|pspath|$SCR_PATH|g" "$desktop_entry_dest" || error "can't edit desktop entry"
|
2020-05-19 13:31:52 +00:00
|
|
|
else
|
|
|
|
error "desktop entry Not Found"
|
|
|
|
fi
|
|
|
|
|
2021-01-01 13:19:19 +00:00
|
|
|
#change photoshop icon of desktop entry
|
|
|
|
local entry_icon="../images/AdobePhotoshop-icon.png"
|
|
|
|
local launch_icon="$launcher_dest/AdobePhotoshop-icon.png"
|
|
|
|
|
2021-01-02 19:58:44 +00:00
|
|
|
cp "$entry_icon" "$launcher_dest" || error "can't copy icon image"
|
2021-01-01 13:19:19 +00:00
|
|
|
sed -i "s|photoshopicon|$launch_icon|g" "$desktop_entry_dest" || error "can't edit desktop entry"
|
|
|
|
sed -i "s|photoshopicon|$launch_icon|g" "$launcher_dest/launcher.sh" || error "can't edit launcher script"
|
|
|
|
|
2020-05-19 13:31:52 +00:00
|
|
|
#create photoshop command
|
|
|
|
show_message "create photoshop command..."
|
|
|
|
if [ -f "/usr/local/bin/photoshop" ];then
|
|
|
|
show_message "photoshop command exist deleted..."
|
|
|
|
sudo rm "/usr/local/bin/photoshop"
|
|
|
|
fi
|
2021-03-06 14:22:18 +00:00
|
|
|
sudo mkdir -p "/usr/local/bin"
|
2020-05-19 13:31:52 +00:00
|
|
|
sudo ln -s "$SCR_PATH/launcher/launcher.sh" "/usr/local/bin/photoshop" || error "can't create photoshop command"
|
|
|
|
|
2020-05-29 16:05:54 +00:00
|
|
|
unset desktop_entry desktop_entry_dest launcher_path launcher_dest
|
2020-05-19 13:31:52 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function set_dark_mod() {
|
2020-05-19 13:31:52 +00:00
|
|
|
echo " " >> "$WINE_PREFIX/user.reg"
|
|
|
|
local colorarray=(
|
|
|
|
'[Control Panel\\Colors] 1491939580'
|
|
|
|
'#time=1d2b2fb5c69191c'
|
|
|
|
'"ActiveBorder"="49 54 58"'
|
|
|
|
'"ActiveTitle"="49 54 58"'
|
|
|
|
'"AppWorkSpace"="60 64 72"'
|
|
|
|
'"Background"="49 54 58"'
|
|
|
|
'"ButtonAlternativeFace"="200 0 0"'
|
|
|
|
'"ButtonDkShadow"="154 154 154"'
|
|
|
|
'"ButtonFace"="49 54 58"'
|
|
|
|
'"ButtonHilight"="119 126 140"'
|
|
|
|
'"ButtonLight"="60 64 72"'
|
|
|
|
'"ButtonShadow"="60 64 72"'
|
|
|
|
'"ButtonText"="219 220 222"'
|
|
|
|
'"GradientActiveTitle"="49 54 58"'
|
|
|
|
'"GradientInactiveTitle"="49 54 58"'
|
|
|
|
'"GrayText"="155 155 155"'
|
|
|
|
'"Hilight"="119 126 140"'
|
|
|
|
'"HilightText"="255 255 255"'
|
|
|
|
'"InactiveBorder"="49 54 58"'
|
|
|
|
'"InactiveTitle"="49 54 58"'
|
|
|
|
'"InactiveTitleText"="219 220 222"'
|
|
|
|
'"InfoText"="159 167 180"'
|
|
|
|
'"InfoWindow"="49 54 58"'
|
|
|
|
'"Menu"="49 54 58"'
|
|
|
|
'"MenuBar"="49 54 58"'
|
|
|
|
'"MenuHilight"="119 126 140"'
|
|
|
|
'"MenuText"="219 220 222"'
|
|
|
|
'"Scrollbar"="73 78 88"'
|
|
|
|
'"TitleText"="219 220 222"'
|
|
|
|
'"Window"="35 38 41"'
|
|
|
|
'"WindowFrame"="49 54 58"'
|
|
|
|
'"WindowText"="219 220 222"'
|
|
|
|
)
|
|
|
|
for i in "${colorarray[@]}";do
|
|
|
|
echo "$i" >> "$WINE_PREFIX/user.reg"
|
|
|
|
done
|
|
|
|
show_message "set dark mode for wine..."
|
|
|
|
unset colorarray
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function export_var() {
|
2020-05-19 13:31:52 +00:00
|
|
|
export WINEPREFIX="$WINE_PREFIX"
|
|
|
|
show_message "wine variables exported..."
|
|
|
|
}
|
|
|
|
|
|
|
|
#parameters is [PATH] [CheckSum] [URL] [FILE NAME]
|
2020-12-29 18:16:49 +00:00
|
|
|
function download_component() {
|
2020-05-19 13:31:52 +00:00
|
|
|
local tout=0
|
|
|
|
while true;do
|
2021-01-06 08:00:38 +00:00
|
|
|
if [ $tout -ge 3 ];then
|
2020-08-11 13:21:04 +00:00
|
|
|
error "sorry something went wrong during download $4"
|
2020-05-19 13:31:52 +00:00
|
|
|
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 detected"
|
2020-05-19 18:39:35 +00:00
|
|
|
return 0
|
2020-05-19 13:31:52 +00:00
|
|
|
else
|
|
|
|
show_message "md5 is not match"
|
|
|
|
rm $1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
show_message "downloading $4 ..."
|
2021-01-09 11:28:31 +00:00
|
|
|
ariapkg=$(package_installed aria2c "summary")
|
|
|
|
curlpkg=$(package_installed curl "summary")
|
|
|
|
|
|
|
|
if [ "$ariapkg" == "true" ];then
|
2021-01-06 08:00:38 +00:00
|
|
|
show_message "using aria2c to download $4"
|
|
|
|
aria2c -c -x 8 -d "$CACHE_PATH" -o $4 $3
|
|
|
|
|
|
|
|
if [ $? -eq 0 ];then
|
2021-01-09 10:57:04 +00:00
|
|
|
notify-send "Photoshop CC" "$4 download completed" -i "download"
|
2021-01-06 08:00:38 +00:00
|
|
|
fi
|
2021-01-09 11:28:31 +00:00
|
|
|
|
|
|
|
elif [ "$curlpkg" == "true" ];then
|
|
|
|
show_message "using curl to download $4"
|
|
|
|
curl $3 -o $1
|
2021-01-06 08:00:38 +00:00
|
|
|
else
|
|
|
|
show_message "using wget to download $4"
|
2021-08-13 04:23:54 +00:00
|
|
|
wget --no-check-certificate "$3" -P "$CACHE_PATH"
|
2021-01-06 08:00:38 +00:00
|
|
|
|
|
|
|
if [ $? -eq 0 ];then
|
2021-01-09 10:57:04 +00:00
|
|
|
notify-send "Photoshop CC" "$4 download completed" -i "download"
|
2021-01-06 08:00:38 +00:00
|
|
|
fi
|
2020-05-19 13:31:52 +00:00
|
|
|
fi
|
|
|
|
((tout++))
|
|
|
|
fi
|
2021-01-09 11:28:31 +00:00
|
|
|
done
|
2020-05-19 13:31:52 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function rmdir_if_exist() {
|
2020-05-19 13:31:52 +00:00
|
|
|
if [ -d "$1" ];then
|
2020-05-29 16:05:54 +00:00
|
|
|
rm -rf "$1"
|
2020-05-19 13:31:52 +00:00
|
|
|
show_message "\033[0;36m$1\e[0m directory exists deleting it..."
|
|
|
|
fi
|
2020-05-29 16:05:54 +00:00
|
|
|
mkdir "$1"
|
2020-05-19 13:31:52 +00:00
|
|
|
show_message "create\033[0;36m $1\e[0m directory..."
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function check_arg() {
|
2020-05-29 16:05:54 +00:00
|
|
|
while getopts "hd:c:" OPTION; do
|
|
|
|
case $OPTION in
|
|
|
|
d)
|
|
|
|
PARAMd="$OPTARG"
|
|
|
|
SCR_PATH=$(readlink -f "$PARAMd")
|
|
|
|
|
|
|
|
dashd=1
|
|
|
|
echo "install path is $SCR_PATH"
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
PARAMc="$OPTARG"
|
|
|
|
CACHE_PATH=$(readlink -f "$PARAMc")
|
|
|
|
dashc=1
|
|
|
|
echo "cahce is $CACHE_PATH"
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "wrong argument"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
|
|
|
if [[ $# != 0 ]];then
|
|
|
|
usage
|
|
|
|
error2 "unknown argument"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $dashd != 1 ]] ;then
|
|
|
|
echo "-d not define default directory used..."
|
|
|
|
SCR_PATH="$HOME/.photoshopCCV19"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $dashc != 1 ]];then
|
|
|
|
echo "-c not define default directory used..."
|
|
|
|
CACHE_PATH="$HOME/.cache/photoshopCCV19"
|
2020-05-19 13:31:52 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function is64() {
|
2020-05-19 13:31:52 +00:00
|
|
|
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
|
|
|
|
echo "Good Bye!"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
show_message "is64 checked..."
|
2020-05-19 14:44:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#parameters [Message] [default flag [Y/N]]
|
2020-12-29 18:16:49 +00:00
|
|
|
function ask_question() {
|
2020-05-19 14:44:57 +00:00
|
|
|
question_result=""
|
|
|
|
if [ "$2" == "Y" ];then
|
|
|
|
read -r -p "$1 [Y/n] " response
|
|
|
|
if [[ "$response" =~ $(locale noexpr) ]];then
|
|
|
|
question_result="no"
|
|
|
|
else
|
|
|
|
question_result="yes"
|
|
|
|
fi
|
|
|
|
elif [ "$2" == "N" ];then
|
|
|
|
read -r -p "$1 [N/y] " response
|
|
|
|
if [[ "$response" =~ $(locale yesexpr) ]];then
|
|
|
|
question_result="yes"
|
|
|
|
else
|
|
|
|
question_result="no"
|
|
|
|
fi
|
|
|
|
fi
|
2020-05-29 16:05:54 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function usage() {
|
2020-05-29 16:05:54 +00:00
|
|
|
echo "USAGE: [-c cache directory] [-d installation directory]"
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function save_paths() {
|
2020-05-29 16:05:54 +00:00
|
|
|
local datafile="$HOME/.psdata.txt"
|
|
|
|
echo "$SCR_PATH" > "$datafile"
|
|
|
|
echo "$CACHE_PATH" >> "$datafile"
|
|
|
|
unset datafile
|
|
|
|
}
|
|
|
|
|
2020-12-29 18:16:49 +00:00
|
|
|
function load_paths() {
|
2020-05-29 16:05:54 +00:00
|
|
|
local datafile="$HOME/.psdata.txt"
|
|
|
|
SCR_PATH=$(head -n 1 "$datafile")
|
|
|
|
CACHE_PATH=$(tail -n 1 "$datafile")
|
|
|
|
unset datafile
|
2020-08-11 13:21:04 +00:00
|
|
|
}
|