Advertisement
Guest User

WINE minimal install for ARMA 2 OA headless server

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