Advertisement
Kindling

WINE minimal install for ARMA2 servers

Aug 1st, 2012
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.94 KB | None | 0 0
  1. #!/bin/bash
  2. ##
  3. ##  -------------------------------------------------
  4. ## | WINE minimal install for ARMA2 servers           |
  5. ## |                                Author: Vaerraent |
  6. ##  -------------------------------------------------
  7. ##
  8.  
  9. sudoequiv() {
  10. if type -p sudo >/dev/null; then
  11.     echo "sudo"
  12. else
  13.     echo "su -c"
  14. fi
  15. }
  16.  
  17. installdeps() {
  18. echo "Please enter root password when prompted to install required packages."
  19. echo "Using $(sudoequiv) for permissions."
  20. if [ "$(sudoequiv)" == "sudo" ]; then
  21.     echo "Ensure the current user ($USER) has permission to install packages via sudo (man sudo) and type in their password when prompted."
  22. else
  23.     echo "Use the root account's password when prompted."
  24. fi
  25. if [ "$DISTRO" == "Debian" ]; then
  26.     $(sudoequiv) apt-get install build-essential ia32-libs ia32-libs-dev lib32z1-dev libc6-dev-i386 libncurses5-dev libncurses5-dev libfreetype6-dev libx11-dev lib32ncurses5-dev  libxcursor-dev flex bison prelink libjpeg62-dev libpng12-dev || { echo "Error installing dependencies, add your user to sudoers and make sure to use the correct password."; exit; }
  27. elif [ "$DISTRO" == "Ubuntu" ]; then
  28.     $(sudoequiv) apt-get install build-essential libc6-dev-i386 libncurses5-dev libncurses5-dev libx11-dev lib32ncurses5-dev libfreetype6-dev libxcursor-dev flex bison prelink libjpeg62-dev libpng12-dev lib32z1-dev libc6 libX11-dev:i386 libpng12:i386 libjpeg62:i386 libfreetype6:i386 zlib1g:i386 || { echo "Error installing dependencies, add your user to sudoers and make sure to use the correct password."; exit; }
  29. elif [ "$DISTRO" == "CentOS" ]; then
  30.     $(sudoequiv) yum install gcc autoconf automake make glibc-devel.i686 libstdc++-devel.i686 flex bison libX11-devel.i686 freetype-devel.i686 freetype-devel libjpeg-devel.i686 libpng-devel.i686 prelink libXcursor-devel.i686 ncurses-devel.i686 zlib-devel.i686 || { echo "Error installing dependencies, add your user to sudoers and make sure to use the correct password."; exit; }
  31. fi
  32. echo ""
  33. }
  34.  
  35. buildinstall() {
  36. CORECOUNT=$(cat /proc/cpuinfo | grep processor | wc -l)
  37. CORECOUNT=$(($CORECOUNT + 1))
  38.  
  39. if [[ $CORECOUNT < 2 ]]; then
  40.     echo "There has been an error reading the number of processor cores."
  41.     exit;
  42. else
  43.     echo "The script will have make use of $CORECOUNT threads to speed up the compile operation."
  44. fi
  45.  
  46. echo "Downloading and extracting WINE sources..."
  47. if [ ! -f "$HOME/wine-1.5.9.tar.bz2" ]; then
  48.     wget "http://mirrors.ibiblio.org/wine/source/1.5/wine-1.5.9.tar.bz2" -O "$HOME/wine-1.5.9.tar.bz2" || { echo "Error downloading wine-1.5.9.tar.bz2!"; exit; }
  49. else
  50.     echo "$HOME/wine-1.5.9.tar.bz2 found."
  51. fi
  52. if [ -f "$HOME/wine-1.5.9" ]; then
  53.     echo "Found an older wine-1.5.9 directory, deleting it."
  54.     rm -r "$HOME/wine-1.5.9"
  55. fi
  56. tar xf "$HOME/wine-1.5.9.tar.bz2" -C "$HOME" || { echo "Could not extract $HOME/wine-1.5.9.tar.bz2 to $HOME!"; exit; }
  57. cd "$HOME/wine-1.5.9" && ./configure --prefix="$HOME"
  58. echo ""
  59. echo "!=============================================================================================!"
  60. echo "If you see any errors or warnings about X11, Freetype or libpng libraries here, complain to me."
  61. echo "!=============================================================================================!"
  62. echo ""
  63.  
  64. echo "Starting compile. This'll take a while, go have a cuppa :)"
  65. cd "$HOME/wine-1.5.9" && make "-j$CORECOUNT" >"$HOME/wine-1.5.9/makelog.log" || { echo "Error running compile operation, aborting!"; exit; }
  66. echo ""
  67. echo "All done compiling! Installing..."
  68. cd "$HOME/wine-1.5.9" && make install >"$HOME/wine-1.5.9/makeinstalllog.log" || { echo "Error running install operation, aborting!"; exit; }
  69. echo ""
  70. echo "Install complete."
  71. }
  72.  
  73. winetricksxact() {
  74. echo "Installing cabextract to satisfy winetricks dependancy..."
  75. if [ "$DISTRO" == "Debian" -o "$DISTRO" == "Ubuntu" ]; then
  76.     $(sudoequiv) apt-get install cabextract
  77. elif [ "$DISTRO" == "CentOS" ]; then
  78.     if [ ! $(rpm -q cabextract) ]; then
  79.         wget "http://pkgs.repoforge.org/cabextract/cabextract-1.4-1.el6.rf.x86_64.rpm" && $(sudoequiv) rpm -i cabextract-1.4-1.el6.rf.x86_64.rpm || { echo "Error installing cabextract."; exit; }
  80.     fi
  81. fi
  82. echo ""
  83. echo "Installing required libraries using winetricks..."
  84. echo ""
  85. if ! type -p winetricks; then
  86.     wget "http://winetricks.org/winetricks" -O $HOME/winetricks
  87.     chmod +x "$HOME/winetricks"
  88.     "$HOME/winetricks" xact
  89. else
  90.     winetricks xact
  91. fi
  92. echo ""
  93. echo "You can clear the winetricks cached DirectX download with 'rm $HOME/.cache/winetricks/directx9/*'"
  94. }
  95.  
  96. xvfbinstall() {
  97. echo "Installing Xvfb, xdotool and screen..."
  98. if [ "$DISTRO" == "Debian" -o "$DISTRO" == "Ubuntu" ]; then
  99.     $(sudoequiv) apt-get install xvfb xdotool screen
  100. elif [ "$DISTRO" == "CentOS" ]; then
  101.     $(sudoequiv) yum install xorg-x11-server-Xvfb screen
  102.     if [ ! $(rpm -q xdotool) ]; then
  103.         wget "http://www.openfusion.com.au/mrepo/centos6-x86_64/RPMS.all/xdotool-2.20110530.1-1.of.el6.x86_64.rpm" && $(sudoequiv) rpm -i xdotool-2.20110530.1-1.of.el6.x86_64.rpm || { echo "Error installing xdotool."; exit; }
  104.     fi
  105. fi
  106. }
  107.  
  108. createstartscript() {
  109. if [ -a $HOME/bin/wine ]; then
  110.     WINELOC="$HOME/bin/wine"
  111. elif [-a $HOME/usr/bin/wine ]; then
  112.     WINELOC="$HOME/usr/bin/wine"
  113. elif [-a $HOME/usr/local/bin/wine ]; then
  114.     WINELOC="$HOME/usr/local/bin/wine"
  115. else
  116.     echo "Error detecting WINE path: was make install run globally or even at all?"; exit;
  117. fi
  118. echo "#!/bin/bash
  119. export PATH=\"\$PATH:\$HOME/bin\"
  120. if ! ps aux | grep -v grep | grep arma2 >/dev/null; then
  121.     wineserver -k
  122.     \$HOME/a2serv.sh
  123. fi" > "$HOME/a2check.sh"
  124. echo "#!/bin/bash
  125. screen -S arma -D -m $HOME/arma2.sh" > "$HOME/a2serv.sh"
  126. echo "#!/bin/bash
  127. export PATH=\"\$PATH:\$HOME/bin\"
  128. cd \$HOME/.wine/drive_c/arma2oa && xvfb-run wine \$HOME/.wine/drive_c/arma2oa/Expansion/beta/arma2oaserver.exe -mod=\"C:\\\\arma2;EXPANSION;ca\" -mod=\"Expansion/beta;Expansion/beta/expansion\" -malloc=system -config=C:\\\\server.cfg" > "$HOME/arma2-beta.sh"
  129. echo "#!/bin/bash
  130. export PATH=\"\$PATH:\$HOME/bin\"
  131. cd \$HOME/.wine/drive_c/arma2oa && xvfb-run wine \$HOME/.wine/drive_c/arma2oa/arma2oaserver.exe -mod=\"C:\\\\arma2\" -malloc=system -config=C:\\\\server.cfg" > "$HOME/arma2.sh"
  132. chmod +x "$HOME/a2*.sh"
  133. chmod +x "$HOME/arma2*.sh"
  134. echo "First, edit $HOME/arma2.sh and $HOME/arma2-beta.sh to point to the correct location of your arma2oaserver.exe versions - it defaults to C:/arma2oa for OA and C:/arma2 for ARMA2."
  135. echo "To start the server, use a2check.sh in your home directory (add all your switches to arma2.sh and arma2-beta.sh, be sure to edit a2serv.sh to point to which one you want). Ensure you give the application some time to start. You can check that it's running with 'ps aux | grep arma2oa'"
  136. echo "You can add the server to a cronjob (the server will automatically be restarted within a minute if it crashes or exits). To do this, type 'crontab -e' as your WINE/ARMA2 user and add an entry like \"* * * * * $HOME/a2check.sh\" without the quotes. This will check every minute if ARMA 2 is running and start it if it isn't. You can read the ARMA 2 WINE debug messages by typing 'screen -r arma' as the ARMA 2 user."
  137. }
  138.  
  139.  
  140.  
  141. if [ "$USER" == "root" ]; then
  142.     echo "Do not run this script as root. Use the account you wish to use for WINE."; exit;
  143. fi
  144.  
  145. echo "This script will download, compile and install a headless WINE server for use with the Windows ARMA 2 server software."
  146. echo""
  147. echo""
  148. UBUNTU=$(cat /etc/issue | grep Ubuntu)
  149. DEBIAN=$(cat /etc/issue | grep Debian)
  150. CENTOS=$(cat /etc/issue | grep CentOS)
  151.  
  152. if [ -n "$DEBIAN" ]; then
  153.     DISTRO="Debian"
  154. elif [ -n "$UBUNTU" ]; then
  155.     DISTRO="Ubuntu"
  156. elif [ -n "$CENTOS" ]; then
  157.     DISTRO="CentOS"
  158. else
  159.     DISTRO=""
  160.     echo "Unsupported distro"
  161.     exit;
  162. fi
  163.  
  164. echo "Your distribution has been detected as $DISTRO, is this correct?"
  165. select yn in "Yes" "No"; do
  166. case $yn in
  167.     Yes ) installdeps
  168.     buildinstall
  169.     winetricksxact
  170.     winetricksxact
  171.     xvfbinstall
  172.     createstartscript
  173.     break;;
  174.     No ) exit;;
  175. esac
  176. done
  177.  
  178. echo ""
  179. echo "Script has completed, hopefully everything works!"
  180. echo ""
  181. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement