Provides automatic installation scripts for OpenRA with Tiberian Sun & Red Alert 2 + Dune 2 (Windows, Linux)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
8.2 KiB

  1. #!/bin/bash
  2. ##-------------------------------------------------------------
  3. # Allow interruption of the script at any time (Ctrl + C)
  4. trap "exit" INT
  5. ##-------------------------------------------------------------
  6. # Check if we're using bash or sh to run the script. If bash, OK. If sh, ask user to run the script with bash.
  7. BASH_CHECK=$(ps | grep `echo $$` | awk '{ print $4 }')
  8. if [ ! $BASH_CHECK = "bash" ]; then
  9. echo "
  10. Please run this script using bash (/usr/bin/bash).
  11. "
  12. exit 1
  13. fi
  14. ##-------------------------------------------------------------
  15. # Check if we are root or not. If yes, then terminate the script.
  16. if [[ $UID = 0 ]]; then
  17. echo -e "\nPlease run this script as a regular user. Do not use root or sudo. Some commands used in the script require regular user permissions.\n"
  18. exit 1
  19. fi
  20. ##-------------------------------------------------------------
  21. # Get our current directory
  22. WORKING_DIR=$(pwd)
  23. # Get our Linux distribution
  24. DISTRO=$(cat /etc/os-release | sed -n '/PRETTY_NAME/p' | grep -o '".*"' | sed -e 's/"//g' -e s/'([^)]*)'/''/g -e 's/ .*//' -e 's/[ \t]*$//')
  25. ARCH="Arch"
  26. UBUNTU="Ubuntu"
  27. DEBIAN="Debian"
  28. OPENSUSE="openSUSE"
  29. FEDORA="Fedora"
  30. ##-------------------------------------------------------------
  31. #Post-installation instructions
  32. bold_in='\e[1m'
  33. dim_in='\e[2m'
  34. out='\e[0m'
  35. PACKAGEMANAGER_INSTALL=1
  36. PACKAGEMANAGER_REMOVE=1
  37. PACKAGE_NAME=1
  38. INSTALL_NAME=1
  39. function endtext_fail() {
  40. echo -e "\nWhoops! Something went wrong. Please check for possible error messages above.\n"
  41. }
  42. function endtext() {
  43. OPENRA_GITVERSION=git-$(git ls-remote https://github.com/OpenRA/OpenRA.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  44. RA2_GITVERSION=git-$(git ls-remote https://github.com/OpenRA/ra2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  45. echo -e "$bold_in\n***OpenRA compilation script completed.\nPlease see further instructions below.***$out"
  46. sleep 2
  47. echo -e "$bold_in\n***MANUAL INSTALLATION***$out\n\nInstall OpenRA by typing '$PACKAGEMANAGER_INSTALL $HOME/$PACKAGE_NAME' (without quotations) in a terminal window."
  48. sleep 4
  49. echo -e "$bold_in\n***TIBERIAN SUN & RED ALERT 2 - HOWTO***$out\n\nTO PLAY TIBERIAN SUN: Launch the game and download the required asset files from the web when the game asks you to do so.\n\nTO PLAY RED ALERT 2: You must install language.mix, multi.mix, ra2.mix and theme.mix into '$HOME/.openra/Content/ra2/' folder. You find these files from original RA2 installation media (CD's):\n\n-theme.mix, multi.mix = RA2 CD Root folder\n-ra2.mix, language.mix = RA2 CD Root/INSTALL/Game1.CAB (inside that archive file)$bold_in\n\n***LAUNCHING OPENRA***$out\n\nTo launch OpenRA, simply type 'openra' (without quotations) in your terminal or use a desktop shortcut file.$bold_in\n\n***UNINSTALLATION***$out\n\nIf you want to remove OpenRA, just type '$PACKAGEMANAGER_REMOVE $INSTALL_NAME' (without quotations)\n\nYou can find package of $INSTALL_NAME in '$HOME' for further usage.$bold_in\n\n***MULTIPLAYER***$out\n\nIt's recommended to build OpenRA using exactly same GIT source files for multiplayer usage to minimize possible version differences/conflicts between players. Please make sure all players have exactly same git versions of their in-game mods (RA, CNC, D2K, TS, RA2). Version numbers are formatted like 'git-e0d7445' etc. and can be found in each mod description in the mod selection menu.\n\nFor this compilation, the version numbers are as follows:\nOpenRA version: $OPENRA_GITVERSION\nRA2 version: $RA2_GITVERSION\n\nHave fun!\n"
  50. }
  51. ##-------------------------------------------------------------
  52. # If we're running Arch Linux, then execute this
  53. if [[ $DISTRO =~ "$ARCH" ]]; then
  54. echo -e "\n$bold_in***Welcome Comrade*** $out\n"
  55. echo -e "You are about to install OpenRA with Tiberian Sun & Red Alert 2 on Arch Linux.\n"
  56. read -r -p "Do you want to continue? [y/N] " response
  57. if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
  58. echo -e "\nAllright, let's continue. Do you want $bold_in\n\n1.$out manually install OpenRA after its compilation? $dim_in(manual pacman installation)$bold_in\n2.$out automatically install OpenRA after its compilation? $dim_in(pacman -U <compiled_openra_package>)$out\n"
  59. read -r -p "Please type 1 or 2 (Default: 2): " number
  60. sleep 1
  61. if [[ $number -eq 1 ]]; then
  62. echo -e "\nSelected installation method:$bold_in Manual$out"
  63. else
  64. echo -e "\nSelected installation method:$bold_in Automatic$out"
  65. fi
  66. echo -e "$bold_in\n***Starting OpenRA compilation process.***$out\n"
  67. sleep 2
  68. rm $WORKING_DIR/data/linux/arch_linux/*.patch
  69. cp ./data/patches/*.patch ./data/linux/arch_linux/
  70. cd ./data/linux/arch_linux
  71. rm -rf */
  72. updpkgsums
  73. makepkg -c
  74. if [[ -f $WORKING_DIR/data/linux/arch_linux/*.tar.xz ]]; then
  75. mv *.tar.xz $HOME
  76. else
  77. endtext_fail
  78. exit 1
  79. fi
  80. PACKAGEMANAGER_INSTALL='sudo pacman -U'
  81. PACKAGEMANAGER_REMOVE='sudo pacman -Rs'
  82. INSTALL_NAME=$(sed -n '/pkgname/{p;q;}' ./PKGBUILD | sed -n 's/^pkgname=//p')
  83. PACKAGE_NAME=$(find $HOME -maxdepth 1 -type f -iname "$INSTALL_NAME*.tar.xz" | sed -e 's/.*\///')
  84. if [[ ! $number -eq 1 ]]; then
  85. echo -e "$bold_in\n***Installing OpenRA (root password required).***$out\n"
  86. $PACKAGEMANAGER_INSTALL --noconfirm $HOME/$PACKAGE_NAME
  87. echo -e "$bold_in\n***OpenRA installation completed.***$out"
  88. fi
  89. rm -rf */
  90. rm ./*.patch
  91. cd $WORKING_DIR
  92. if [[ -z $PACKAGE_NAME ]]; then
  93. endtext_fail
  94. exit 1
  95. else
  96. endtext_ok
  97. exit 1
  98. fi
  99. else
  100. echo -e "\nCancelling OpenRA installation.\n"
  101. exit 1
  102. fi
  103. fi
  104. ##-------------------------------------------------------------
  105. # If we're running Ubuntu or Linux Mint or Debian, then execute this
  106. if [[ $DISTRO =~ "$UBUNTU" ]] || [[ $DISTRO =~ "$DEBIAN" ]]; then
  107. if [[ $DISTRO =~ "$DEBIAN" ]]; then
  108. if [[ $(dpkg-query -W sudo 2>/dev/null | wc -l) -eq 0 ]]; then
  109. echo -e "\Please install sudo and add your username to sudo group.\nRun the following commands:\nsu root\nadduser <username> sudo\n\nRe-run this script again then.\nExiting now."
  110. exit 1
  111. fi
  112. fi
  113. bash ./data/linux/openra-installscript.sh
  114. PACKAGEMANAGER_INSTALL='sudo dpkg -i'
  115. PACKAGEMANAGER_REMOVE='sudo apt-get purge --remove'
  116. INSTALL_NAME=$(sed -n '/PACKAGE_NAME/{p;q;}' ./data/linux/openra-installscript.sh | sed -n 's/^PACKAGE_NAME=//p')
  117. PACKAGE_NAME=$(find $HOME -maxdepth 1 -type f -iname "$INSTALL_NAME*.deb" | sed -e 's/.*\///')
  118. if [[ -z $PACKAGE_NAME ]]; then
  119. endtext_fail
  120. if [[ -d $HOME/openra-master ]]; then
  121. echo -e "\n"
  122. read -r -p "Found temporary OpenRA compilation files in $HOME. Remove them now? [y/N] " response2
  123. if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
  124. echo -e "\nDeleting.\n"
  125. rm -Rf $HOME/openra-master
  126. fi
  127. fi
  128. exit 1
  129. else
  130. endtext_ok
  131. exit 1
  132. fi
  133. exit 1
  134. fi
  135. ##-------------------------------------------------------------
  136. # If we're running OpenSUSE or Fedora, then execute this
  137. if [[ $DISTRO =~ "$FEDORA" ]] || [[ $DISTRO =~ "$OPENSUSE" ]]; then
  138. bash ./data/linux/openra-installscript.sh
  139. if [[ $DISTRO =~ "$OPENSUSE" ]]; then
  140. PACKAGEMANAGER_INSTALL='sudo zypper install'
  141. PACKAGEMANAGER_REMOVE='sudo zypper remove'
  142. elif [[ $DISTRO =~ "$FEDORA" ]]; then
  143. PACKAGEMANAGER_INSTALL='sudo dnf install'
  144. PACKAGEMANAGER_REMOVE='sudo dnf remove'
  145. fi
  146. INSTALL_NAME=$(sed -n '/PACKAGE_NAME/{p;q;}' ./data/linux/openra-installscript.sh | sed -n 's/^PACKAGE_NAME=//p')
  147. PACKAGE_NAME=$(find $HOME -maxdepth 1 -type f -iname "$INSTALL_NAME*.rpm" | sed -e 's/.*\///')
  148. if [[ -z $PACKAGE_NAME ]]; then
  149. endtext_fail
  150. if [[ -d $HOME/openra-master ]]; then
  151. echo -e "\n"
  152. read -r -p "Found temporary OpenRA compilation files in $HOME. Remove them now? [y/N] " response2
  153. if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
  154. echo -e "\nDeleting.\n"
  155. rm -Rf $HOME/openra-master
  156. fi
  157. fi
  158. exit 1
  159. else
  160. endtext_ok
  161. exit 1
  162. fi
  163. exit 1
  164. fi
  165. ##-------------------------------------------------------------
  166. # If we don't have any of the supported distributions
  167. if [[ ! $DISTRO =~ "$ARCH" ]] || [[ ! $DISTRO =~ "$UBUNTU" ]] || [[ ! $DISTRO =~ "$DEBIAN" ]] || [[ ! $DISTRO =~ "$OPENSUSE" ]] || [[ ! $DISTRO =~ "$FEDORA" ]]; then
  168. echo "
  169. Your Linux Distribution is not supported. Please consider making a new OpenRA installation script for it.
  170. Supported distributions are: Ubuntu, Linux Mint, Debian, OpenSUSE, Fedora and Arch Linux.
  171. "
  172. exit 1
  173. fi