diff --git a/scripts/PhotoshopSetup.sh b/scripts/PhotoshopSetup.sh index 56f7400..3f9ff9c 100755 --- a/scripts/PhotoshopSetup.sh +++ b/scripts/PhotoshopSetup.sh @@ -1,18 +1,13 @@ #!/usr/bin/env bash +source "sharedFuncs.sh" function main(){ - - source "sharedFuncs.sh" - - SCR_PATH="$HOME/.photoshopCCV19" - CACHE_PATH="$HOME/.cache/photoshopCCV19" mkdir -p $SCR_PATH mkdir -p $CACHE_PATH setup_log "================| script executed |================" - - check_arg $1 + is64 #make sure aria2c and wine package is already installed @@ -63,6 +58,7 @@ function main(){ # winetricks atmlib corefonts fontsmooth=rgb gdiplus vcrun2008 vcrun2010 vcrun2012 vcrun2013 vcrun2015 atmlib msxml3 msxml6 gdiplus winetricks atmlib fontsmooth=rgb vcrun2008 vcrun2010 vcrun2012 vcrun2013 vcrun2015 atmlib msxml3 msxml6 + #install photoshop sleep 3 install_photoshopSE @@ -86,4 +82,6 @@ function main(){ sleep 30 } -main $# $@ +check_arg $@ +save_paths +main \ No newline at end of file diff --git a/scripts/PhotoshopSetupCustom.sh b/scripts/PhotoshopSetupCustom.sh index 7ab5c1f..9af6190 100755 --- a/scripts/PhotoshopSetupCustom.sh +++ b/scripts/PhotoshopSetupCustom.sh @@ -1,18 +1,14 @@ #!/usr/bin/env bash -function main(){ - - source "sharedFuncs.sh" +source "sharedFuncs.sh" - SCR_PATH="$HOME/.photoshopCCV19" - CACHE_PATH="$HOME/.cache/photoshopCCV19" +function main(){ mkdir -p $SCR_PATH mkdir -p $CACHE_PATH setup_log "================| script executed |================" - check_arg $1 is64 #make sure aria2c and wine package is already installed @@ -227,4 +223,6 @@ function install_vcrun2008(){ unset filename filemd5 filelink filepath } -main $# $@ +check_arg $@ +save_paths +main diff --git a/scripts/cameraRawInstaller.sh b/scripts/cameraRawInstaller.sh index 525500d..5f0c190 100755 --- a/scripts/cameraRawInstaller.sh +++ b/scripts/cameraRawInstaller.sh @@ -3,8 +3,7 @@ function main(){ source "sharedFuncs.sh" - SCR_PATH="$HOME/.photoshopCCV19" - CACHE_PATH="$HOME/.cache/photoshopCCV19" + load_paths WINE_PATH="$SCR_PATH/wine-3.4" WINE_PREFIX="$SCR_PATH/prefix" diff --git a/scripts/installapp.sh b/scripts/installapp.sh new file mode 100755 index 0000000..36c1b5a --- /dev/null +++ b/scripts/installapp.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +function main(){ + SCR_PATH="$HOME/.photoshopCCV19" + CACHE_PATH="$HOME/.cache/photoshopCCV19" + WINE_PATH="$SCR_PATH/wine-3.4" + RESOURCES_PATH="$SCR_PATH/resources" + WINE_PREFIX="$SCR_PATH/prefix" + export WINEPREFIX="$WINE_PREFIX" + export PATH="$WINE_PATH/bin:$PATH" + export LD_LIBRARY_PATH="$WINE_PATH/lib:$LD_LIBRARY_PATH" + #export WINEDLLOVERRIDES="winemenubuilder.exe=d" + export WINESERVER="$WINE_PATH/bin/wineserver" + export WINELOADER="$WINE_PATH/bin/wine" + export WINEDLLPATH="$WINE_PATH/lib/wine" + wine "$1" +} + +main "$1" \ No newline at end of file diff --git a/scripts/launcher.sh b/scripts/launcher.sh index 6eefed0..9c047de 100755 --- a/scripts/launcher.sh +++ b/scripts/launcher.sh @@ -6,8 +6,10 @@ fi notify-send "photoshop started" -i "photoshop" -SCR_PATH="$HOME/.photoshopCCV19" -CACHE_PATH="$HOME/.cache/photoshopCCV19" +# SCR_PATH="$HOME/.photoshopCCV19" +# CACHE_PATH="$HOME/.cache/photoshopCCV19" +SCR_PATH="pspath" +CACHE_PATH="pscache" WINE_PATH="$SCR_PATH/wine-3.4" @@ -23,4 +25,4 @@ export WINESERVER="$WINE_PATH/bin/wineserver" export WINELOADER="$WINE_PATH/bin/wine" export WINEDLLPATH="$WINE_PATH/lib/wine" -wine $HOME/.photoshopCCV19/prefix/drive_c/users/$USER/PhotoshopSE/Photoshop.exe +wine "$SCR_PATH/prefix/drive_c/users/$USER/PhotoshopSE/Photoshop.exe" diff --git a/scripts/photoshop.desktop b/scripts/photoshop.desktop index 3a94347..fea6d98 100755 --- a/scripts/photoshop.desktop +++ b/scripts/photoshop.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Encoding=UTF-8 Name=photoshop -Exec=bash gictorbit/.photoshopCCV19/launcher/launcher.sh +Exec=bash pspath/launcher/launcher.sh Type=Application StartupNotify=true Comment=photoshop cc for linux diff --git a/scripts/sharedFuncs.sh b/scripts/sharedFuncs.sh old mode 100644 new mode 100755 index b4807fa..304107f --- a/scripts/sharedFuncs.sh +++ b/scripts/sharedFuncs.sh @@ -47,13 +47,21 @@ function show_message2(){ } function launcher(){ + + #create launcher script local launcher_path="$PWD/launcher.sh" - rmdir_if_exist "$SCR_PATH/launcher" + local launcher_dest="$SCR_PATH/launcher" + rmdir_if_exist "$launcher_dest" + if [ -f "$launcher_path" ];then show_message "launcher.sh detected..." - cp "$launcher_path" "$SCR_PATH/launcher" || error "can't copy launcher" - chmod +x "$SCR_PATH/launcher/launcher.sh" + + 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" else error "launcher.sh Note Found" fi @@ -70,7 +78,7 @@ function launcher(){ sudo rm "$desktop_entry_dest" fi sudo cp "$desktop_entry" "/usr/share/applications" || error "can't copy desktop entry" - sudo sed -i "s|gictorbit|$HOME|g" "$desktop_entry_dest" || error "can't edit desktop entry" + sudo sed -i "s|pspath|$SCR_PATH|g" "$desktop_entry_dest" || error "can't edit desktop entry" else error "desktop entry Not Found" fi @@ -83,7 +91,7 @@ function launcher(){ fi sudo ln -s "$SCR_PATH/launcher/launcher.sh" "/usr/local/bin/photoshop" || error "can't create photoshop command" - unset desktop_entry desktop_entry_dest launcher_path + unset desktop_entry desktop_entry_dest launcher_path launcher_dest } function replacement(){ @@ -274,19 +282,54 @@ function download_component(){ function rmdir_if_exist(){ if [ -d "$1" ];then - rm -rf $1 + rm -rf "$1" show_message "\033[0;36m$1\e[0m directory exists deleting it..." fi - mkdir $1 + mkdir "$1" show_message "create\033[0;36m $1\e[0m directory..." } function check_arg(){ - if [ $1 != 0 ] - then - error "It haven't any parameter just execute script" + 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" fi - show_message "argument checked..." } function is64(){ @@ -320,4 +363,22 @@ function ask_question(){ question_result="no" fi fi +} + +function usage(){ + echo "USAGE: [-c cache directory] [-d installation directory]" +} + +function save_paths(){ + local datafile="$HOME/.psdata.txt" + echo "$SCR_PATH" > "$datafile" + echo "$CACHE_PATH" >> "$datafile" + unset datafile +} + +function load_paths(){ + local datafile="$HOME/.psdata.txt" + SCR_PATH=$(head -n 1 "$datafile") + CACHE_PATH=$(tail -n 1 "$datafile") + unset datafile } \ No newline at end of file diff --git a/scripts/uninstaller.sh b/scripts/uninstaller.sh index 76d1f22..7ffd3ec 100755 --- a/scripts/uninstaller.sh +++ b/scripts/uninstaller.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -main(){ - check_arg $1 - SCR_PATH="$HOME/.photoshopCCV19" - CACHE_PATH="$HOME/.cache/photoshopCCV19" + +source "sharedFuncs.sh" + +main(){ CMD_PATH="/usr/local/bin/photoshop" ENTRY_PATH="/usr/share/applications/photoshop.desktop" @@ -18,7 +18,7 @@ main(){ #remove photoshop directory if [ -d "$SCR_PATH" ];then echo "remove photoshop directory..." - rm -rf "$SCR_PATH" || error "couldn't remove photoshop directory" + rm -r "$SCR_PATH" || error2 "couldn't remove photoshop directory" sleep 4 else echo "photoshop directory Not Found!" @@ -28,7 +28,7 @@ main(){ #Unlink command if [ -L "$CMD_PATH" ];then echo "remove launcher command..." - sudo unlink "$CMD_PATH" || error "couln't remove launcher command" + sudo unlink "$CMD_PATH" || error2 "couln't remove launcher command" else echo "launcher command Not Found!" fi @@ -36,7 +36,8 @@ main(){ #delete desktop entry if [ -f "$ENTRY_PATH" ];then echo "remove dekstop entry...." - sudo rm "$ENTRY_PATH" || error "couldn't remove desktop entry" + echo "$SCR_PATH" + sudo rm "$ENTRY_PATH" || error2 "couldn't remove desktop entry" else echo "desktop entry Not Found!" fi @@ -49,7 +50,7 @@ main(){ echo "--------------------------------" ask_question "would you delete cache directory?" "N" if [ "$result" == "yes" ];then - rm -rf "$CACHE_PATH" || error "couldn't remove cache directory" + rm -rf "$CACHE_PATH" || error2 "couldn't remove cache directory" else echo "nice, you can copy component data and use them later for photoshop installation" fi @@ -59,17 +60,6 @@ main(){ } -function error(){ - echo -e "\033[1;31merror:\e[0m $@" - exit 1 -} - -function check_arg(){ - if [ $1 != 0 ];then - error "please just run script without any argument" - fi -} - #parameters [Message] [default flag [Y/N]] function ask_question(){ result="" @@ -90,4 +80,5 @@ function ask_question(){ fi } -main $# $@ +load_paths +main diff --git a/scripts/winecfg.sh b/scripts/winecfg.sh index 5200808..c048aab 100755 --- a/scripts/winecfg.sh +++ b/scripts/winecfg.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash +source "sharedFuncs.sh" + function main(){ - SCR_PATH="$HOME/.photoshopCCV19" - CACHE_PATH="$HOME/.cache/photoshopCCV19" + load_paths WINE_PATH="$SCR_PATH/wine-3.4" RESOURCES_PATH="$SCR_PATH/resources" WINE_PREFIX="$SCR_PATH/prefix"