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.

160 lines
6.5 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. out='\e[0m'
  34. PACKAGEMANAGER_INSTALL=1
  35. PACKAGEMANAGER_REMOVE=1
  36. PACKAGE_NAME=1
  37. INSTALL_NAME=1
  38. function endtext() {
  39. OPENRA_GITVERSION=git-$(git ls-remote https://github.com/OpenRA/OpenRA.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  40. RA2_GITVERSION=git-$(git ls-remote https://github.com/OpenRA/ra2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  41. echo -e "\n***OpenRA compilation script completed.\nPlease see further instructions below.***"
  42. sleep 2
  43. echo -e "$bold_in\n***MANUAL INSTALLATION***$out\n\nInstall OpenRA by typing '$PACKAGEMANAGER_INSTALL $HOME/$PACKAGE_NAME' (without quotations) in a terminal window."
  44. sleep 4
  45. 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"
  46. }
  47. ##-------------------------------------------------------------
  48. # If we're running Arch Linux, then execute this
  49. if [[ $DISTRO =~ "$ARCH" ]]; then
  50. echo -e "\nYou are about to install OpenRA with Tiberian Sun & Red Alert 2.\n"
  51. read -r -p "Do you want to continue? [y/N] " response
  52. if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
  53. echo -e "\nStarting OpenRA compilation process.\n"
  54. sleep 2
  55. cp ./data/patches/*.patch ./data/linux/arch_linux/
  56. cd ./data/linux/arch_linux
  57. updpkgsums
  58. makepkg -c
  59. mv *.tar.xz $HOME
  60. PACKAGEMANAGER_INSTALL='sudo pacman -U'
  61. PACKAGEMANAGER_REMOVE='sudo pacman -Rs'
  62. INSTALL_NAME=$(sed -n '/pkgname/{p;q;}' ./data/linux/arch_linux/PKGBUILD | sed -n 's/^pkgname=//p')
  63. PACKAGE_NAME=$(find $HOME -maxdepth 1 -type f -iname "$INSTALL_NAME*.tar.xz" | sed -e 's/.*\///')
  64. rm -r */
  65. rm ./*.patch
  66. cd $WORKING_DIR
  67. if [[ $PACKAGE_NAME =~ '^[0-9]+$' ]]; then
  68. exit 1
  69. else
  70. endtext
  71. exit 1
  72. fi
  73. else
  74. echo -e "\nCancelling OpenRA installation.\n"
  75. exit 1
  76. fi
  77. fi
  78. ##-------------------------------------------------------------
  79. # If we're running Ubuntu or Linux Mint or Debian, then execute this
  80. if [[ $DISTRO =~ "$UBUNTU" ]] || [[ $DISTRO =~ "$DEBIAN" ]]; then
  81. if [[ $DISTRO =~ "$DEBIAN" ]]; then
  82. if [[ $(dpkg-query -W sudo 2>/dev/null | wc -l) -eq 0 ]]; then
  83. 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."
  84. exit 1
  85. fi
  86. fi
  87. bash ./data/linux/openra-installscript.sh
  88. PACKAGEMANAGER_INSTALL='sudo dpkg -i'
  89. PACKAGEMANAGER_REMOVE='sudo apt-get purge --remove'
  90. INSTALL_NAME=$(sed -n '/PACKAGE_NAME/{p;q;}' ./data/linux/openra-installscript.sh | sed -n 's/^PACKAGE_NAME=//p')
  91. PACKAGE_NAME=$(find $HOME -maxdepth 1 -type f -iname "$INSTALL_NAME*.deb" | sed -e 's/.*\///')
  92. if [[ $PACKAGE_NAME =~ '^[0-9]+$' ]]; then
  93. exit 1
  94. else
  95. endtext
  96. exit 1
  97. fi
  98. exit 1
  99. fi
  100. ##-------------------------------------------------------------
  101. # If we're running OpenSUSE or Fedora, then execute this
  102. if [[ $DISTRO =~ "$FEDORA" ]] || [[ $DISTRO =~ "$OPENSUSE" ]]; then
  103. bash ./data/linux/openra-installscript.sh
  104. if [[ $DISTRO =~ "$OPENSUSE" ]]; then
  105. PACKAGEMANAGER_INSTALL='sudo zypper install'
  106. PACKAGEMANAGER_REMOVE='sudo zypper remove'
  107. elif [[ $DISTRO =~ "$FEDORA" ]]; then
  108. PACKAGEMANAGER_INSTALL='sudo dnf install'
  109. PACKAGEMANAGER_REMOVE='sudo dnf remove'
  110. fi
  111. INSTALL_NAME=$(sed -n '/PACKAGE_NAME/{p;q;}' ./data/linux/openra-installscript.sh | sed -n 's/^PACKAGE_NAME=//p')
  112. PACKAGE_NAME=$(find $HOME -maxdepth 1 -type f -iname "$INSTALL_NAME*.rpm" | sed -e 's/.*\///')
  113. if [[ $PACKAGE_NAME =~ '^[0-9]+$' ]]; then
  114. exit 1
  115. else
  116. endtext
  117. exit 1
  118. fi
  119. exit 1
  120. fi
  121. ##-------------------------------------------------------------
  122. # If we don't have any of the supported distributions
  123. if [[ ! $DISTRO =~ "$ARCH" ]] || [[ ! $DISTRO =~ "$UBUNTU" ]] || [[ ! $DISTRO =~ "$DEBIAN" ]] || [[ ! $DISTRO =~ "$OPENSUSE" ]] || [[ ! $DISTRO =~ "$FEDORA" ]]; then
  124. echo "
  125. Your Linux Distribution is not supported. Please consider making a new OpenRA installation script for it.
  126. Supported distributions are: Ubuntu, Linux Mint, Debian, OpenSUSE, Fedora and Arch Linux.
  127. "
  128. exit 1
  129. fi