Advertisement
Guest User

WINE minimal install for ARMA 2 servers

a guest
Jul 21st, 2012
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.66 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 which 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. if [ "$DISTRO" == "Debian" ]; then
  20. $(sudoequiv) 'apt-get install build-essential ia32-libs ia32-libs-dev libc6-dev-i386 libncurses5-dev libncurses5-dev libfreetype6-dev libx11-dev lib32ncurses5-dev  libxcursor-dev flex bison prelink libjpeg62-dev libpng12-dev'
  21. $(sudoequiv) 'ln -s /usr/lib32/libz.so.1 /usr/lib32/libz.so'
  22. elif [ "$DISTRO" == "Ubuntu"]; then
  23. $(sudoequiv) 'apt-get install build-essential libc6-dev-i386 libncurses5-dev libncurses5-dev libx11-dev lib32ncurses5-dev libfreetype6-dev libxcursor-dev flex bison prelink cabextract libjpeg62-dev libpng12-dev lib32z1-dev libc6 libX11-dev:i386 libpng12:i386 libjpeg62:i386 libfreetype6:i386 zlib1g:i386'
  24. fi
  25. }
  26.  
  27. buildinstall() {
  28. CORECOUNT=$(cat /proc/cpuinfo | grep processor | wc -l)
  29. CORECOUNT=$(($CORECOUNT + 1))
  30.  
  31. if [[ $CORECOUNT < 2 ]]; then
  32.     echo "There has been an error reading the number of processor cores."
  33.     exit;
  34. else
  35.     echo "The script will have make use of $CORECOUNT threads to speed up the compile operation."
  36. fi
  37.  
  38. echo "Downloading and extracting WINE sources..."
  39.  
  40. wget http://mirrors.ibiblio.org/wine/source/1.5/wine-1.5.9.tar.bz2 -O $HOME/wine-1.5.9.tar.bz2
  41. tar xf "$HOME/wine-1.5.9.tar.bz2" -C "$HOME"
  42. cd "$HOME/wine-1.5.9" && ./configure --prefix="$HOME"
  43. echo ""
  44. echo "!=============================================================================================!"
  45. echo "If you see any errors or warnings about X11, Freetype or libpng libraries here, complain to me."
  46. echo "!=============================================================================================!"
  47. echo ""
  48.  
  49. echo "Starting compile. This'll take a while, go have a cuppa :)"
  50. cd "$HOME/wine-1.5.9" && make "-j$CORECOUNT" >$HOME/wine-1.5.9/makelog.log
  51. echo ""
  52. echo "All done compiling! Installing..."
  53. cd "$HOME/wine-1.5.9" && make install >$HOME/wine-1.5.9/makeinstalllog.log
  54. echo ""
  55. echo "Install complete."
  56. }
  57.  
  58. winetricksxact() {
  59. echo "Installing cabextract to satisfy winetricks dependancy..."
  60. $(sudoequiv) 'apt-get install cabextract'
  61. echo ""
  62. echo "Installing required libraries using winetricks..."
  63. echo ""
  64. wget http://winetricks.org/winetricks -O $HOME/winetricks
  65. chmod +x "$HOME/winetricks"
  66. "$HOME/winetricks" xact
  67. echo ""
  68. echo "Clearing winetricks cache for directx..."
  69. rm "$HOME/.cache/winetricks/directx9/*"
  70. }
  71.  
  72. xvfbinstall() {
  73. echo "Installing Xvfb, xdotool and screen..."
  74. $(sudoequiv) 'apt-get install xvfb xdotool screen'
  75. }
  76.  
  77. createstartscript() {
  78. if [ -a $HOME/bin/wine ]; then
  79.     WINELOC=$HOME/bin/wine
  80. elif [-a $HOME/usr/bin/wine ]; then
  81.     WINELOC=$HOME/usr/bin/wine
  82. elif [-a $HOME/usr/local/bin/wine ]; then
  83.     WINELOC=$HOME/usr/local/bin/wine
  84. else
  85.     echo "Error detecting WINE path: was make install run globally or even at all?"; exit;
  86. fi
  87. echo "#!/bin/bash\\
  88. screen -S arma2server xvfb-run $WINELOC \"$HOME/.wine/drive_c/arma2oaserver.exe\" $@ &\\
  89. (sleep 20 && xdotool key Return) &" > $HOME/startserver.sh
  90. chmod +x $HOME/startserver.sh
  91. echo "First, edit $HOME/startserver.sh to point to the correct location of your arma2oaserver.exe - it defaults to the wine C drive root."
  92. echo "To start the server, use startserver.sh in your home directory (you can pass switches through that script like you would for the binary). Be sure to give the application some time to start. You can check it's running with 'ps aux | grep arma2oa'"
  93. }
  94.  
  95.  
  96.  
  97. if [ "$USER" == "root" ]; then
  98.     echo "Do not run this script as root. Use the account you wish to use for WINE."; exit;
  99. fi
  100.  
  101. echo "This script will download, compile and install a headless WINE server for use with the Windows ARMA 2 server software."
  102. echo""
  103. echo""
  104. UBUNTU=$(cat /etc/issue | grep Ubuntu)
  105. DEBIAN=$(cat /etc/issue | grep Debian)
  106.  
  107. if [ -n "$DEBIAN" ]; then
  108.     DISTRO="Debian"
  109. elif [ -n "$UBUNTU" ]; then
  110.     DISTRO="Ubuntu"
  111. else
  112.     DISTRO=""
  113.     echo "Unsupported distro"
  114.     exit;
  115. fi
  116.  
  117. echo "Your distribution has been detected as $DISTRO, is this correct?"
  118. select yn in "Yes" "No"; do
  119.     case $yn in
  120.         Yes ) installdeps
  121.         buildinstall
  122.         winetricksxact
  123.         winetricksxact
  124.         xvfbinstall
  125.         createstartscript
  126.         break;;
  127.         No ) exit;;
  128.     esac
  129. done
  130.  
  131. echo ""
  132. echo "Script has completed, hopefully everything works!"
  133. echo ""
  134. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement