Guest User

pre-launch.sh

a guest
Jun 4th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.65 KB | None | 0 0
  1. #!/bin/bash
  2. usage(){
  3.     echo "Usage: $0 "
  4.     echo "This script needs to be run from the base install directory."
  5.     echo "-h for this dialog."
  6. }
  7.  
  8. rmathing(){
  9.     x="$(realpath -s "$1")"
  10.     filex="$(file "$x")"
  11.     if ! [[ "$filex" == *" (No such file or directory)" ]]; then #it exist
  12.         if [[ "$filex" == *": directory" ]]; then #it dir. use dir cmd instead.
  13.             echo "Running: rm -r $x"
  14.             rm -r "$x"
  15.         else
  16.             echo "Running: rm $x"
  17.             rm "$x"
  18.         fi
  19.     fi
  20. }
  21.  
  22. linkathing(){
  23.     x="$(realpath -s "$1")"
  24.     y="$(realpath -s "$2")"
  25.     filex="$(file "$x")"
  26.     if ! [[ "$filex" == *" (No such file or directory)" ]]; then #it exist
  27.         if [[ "$filex" == *": symbolic link to "* ]]; then #it symlink. maybe from past.
  28.             rmathing "$x" #past symlink could point wrong way. so update it anyways.
  29.         fi
  30.         echo "Running: ln -s $x $y"
  31.         ln -s "$x" "$y"
  32.     fi
  33. }
  34.  
  35. if (( $# >= 0 )); then
  36.     while getopts "h" OPTION; do
  37.         case "${OPTION}" in
  38.             h)
  39.                 usage
  40.                 exit
  41.                 ;;
  42.             \?)
  43.                 exit
  44.                 ;;
  45.         esac
  46.     done
  47.     shift "$(($OPTIND -1))"
  48.  
  49.     cd "$(realpath "$(dirname "$0")")"
  50.     if ! [[ "$PWD" == *"Divinity Original Sin 2" ]]; then #we in wrong dir. abort.
  51.         zenity --info --text="Error with $0:\n\nThere was a problem changing to or verifying the install directory.\nEnsure this script is in the Divinity Original Sin 2 directory.\nDiagnosing and fixing the problem is beyond the abilities of this script.\n\nExiting." --width=250
  52.         echo "ERROR: Wrong dir. Aborting."
  53.         exit
  54.     fi
  55.  
  56.     rmathing ./bin
  57.     linkathing ./DefEd/bin ./bin
  58.  
  59.     rmathing ./Data
  60.     linkathing ./DefEd/Data ./Data
  61.  
  62.     rmathing ./bin/SupportTool.exe
  63.     linkathing ./bin/EoCApp.exe ./bin/SupportTool.exe
  64.  
  65. else
  66.     usage
  67. fi
Advertisement
Add Comment
Please, Sign In to add comment