Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ##
- ## -------------------------------------------------
- ## | WINE minimal install for ARMA2 servers |
- ## | Author: Vaerraent |
- ## -------------------------------------------------
- ##
- sudoequiv() {
- if type -p sudo >/dev/null; then
- echo "sudo"
- else
- echo "su -c"
- fi
- }
- installdeps() {
- echo "Please enter root password when prompted to install required packages."
- echo "Using $(sudoequiv) for permissions."
- if [ "$(sudoequiv)" == "sudo" ]; then
- echo "Ensure the current user ($USER) has permission to install packages via sudo (man sudo) and type in their password when prompted."
- else
- echo "Use the root account's password when prompted."
- fi
- if [ "$DISTRO" == "Debian" ]; then
- $(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; }
- elif [ "$DISTRO" == "Ubuntu" ]; then
- $(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; }
- elif [ "$DISTRO" == "CentOS" ]; then
- $(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; }
- fi
- echo ""
- }
- buildinstall() {
- CORECOUNT=$(cat /proc/cpuinfo | grep processor | wc -l)
- CORECOUNT=$(($CORECOUNT + 1))
- if [[ $CORECOUNT < 2 ]]; then
- echo "There has been an error reading the number of processor cores."
- exit;
- else
- echo "The script will have make use of $CORECOUNT threads to speed up the compile operation."
- fi
- echo "Downloading and extracting WINE sources..."
- if [ ! -f "$HOME/wine-1.5.9.tar.bz2" ]; then
- 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; }
- else
- echo "$HOME/wine-1.5.9.tar.bz2 found."
- fi
- if [ -f "$HOME/wine-1.5.9" ]; then
- echo "Found an older wine-1.5.9 directory, deleting it."
- rm -r "$HOME/wine-1.5.9"
- fi
- 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; }
- cd "$HOME/wine-1.5.9" && ./configure --prefix="$HOME"
- echo ""
- echo "!=============================================================================================!"
- echo "If you see any errors or warnings about X11, Freetype or libpng libraries here, complain to me."
- echo "!=============================================================================================!"
- echo ""
- echo "Starting compile. This'll take a while, go have a cuppa :)"
- cd "$HOME/wine-1.5.9" && make "-j$CORECOUNT" >"$HOME/wine-1.5.9/makelog.log" || { echo "Error running compile operation, aborting!"; exit; }
- echo ""
- echo "All done compiling! Installing..."
- cd "$HOME/wine-1.5.9" && make install >"$HOME/wine-1.5.9/makeinstalllog.log" || { echo "Error running install operation, aborting!"; exit; }
- echo ""
- echo "Install complete."
- }
- winetricksxact() {
- echo "Installing cabextract to satisfy winetricks dependancy..."
- if [ "$DISTRO" == "Debian" -o "$DISTRO" == "Ubuntu" ]; then
- $(sudoequiv) apt-get install cabextract
- elif [ "$DISTRO" == "CentOS" ]; then
- if [ ! $(rpm -q cabextract) ]; then
- 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; }
- fi
- fi
- echo ""
- echo "Installing required libraries using winetricks..."
- echo ""
- if ! type -p winetricks; then
- wget "http://winetricks.org/winetricks" -O $HOME/winetricks
- chmod +x "$HOME/winetricks"
- "$HOME/winetricks" xact
- else
- winetricks xact
- fi
- echo ""
- echo "You can clear the winetricks cached DirectX download with 'rm $HOME/.cache/winetricks/directx9/*'"
- }
- xvfbinstall() {
- echo "Installing Xvfb, xdotool and screen..."
- if [ "$DISTRO" == "Debian" -o "$DISTRO" == "Ubuntu" ]; then
- $(sudoequiv) apt-get install xvfb xdotool screen
- elif [ "$DISTRO" == "CentOS" ]; then
- $(sudoequiv) yum install xorg-x11-server-Xvfb screen
- if [ ! $(rpm -q xdotool) ]; then
- 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; }
- fi
- fi
- }
- createstartscript() {
- if [ -a $HOME/bin/wine ]; then
- WINELOC="$HOME/bin/wine"
- elif [-a $HOME/usr/bin/wine ]; then
- WINELOC="$HOME/usr/bin/wine"
- elif [-a $HOME/usr/local/bin/wine ]; then
- WINELOC="$HOME/usr/local/bin/wine"
- else
- echo "Error detecting WINE path: was make install run globally or even at all?"; exit;
- fi
- echo "#!/bin/bash
- export PATH=\"\$PATH:\$HOME/bin\"
- if ! ps aux | grep -v grep | grep arma2 >/dev/null; then
- wineserver -k
- \$HOME/a2serv.sh
- fi" > "$HOME/a2check.sh"
- echo "#!/bin/bash
- screen -S arma -D -m $HOME/arma2.sh" > "$HOME/a2serv.sh"
- echo "#!/bin/bash
- export PATH=\"\$PATH:\$HOME/bin\"
- 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"
- echo "#!/bin/bash
- export PATH=\"\$PATH:\$HOME/bin\"
- 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"
- chmod +x "$HOME/a2*.sh"
- chmod +x "$HOME/arma2*.sh"
- 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."
- 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'"
- 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."
- }
- if [ "$USER" == "root" ]; then
- echo "Do not run this script as root. Use the account you wish to use for WINE."; exit;
- fi
- echo "This script will download, compile and install a headless WINE server for use with the Windows ARMA 2 server software."
- echo""
- echo""
- UBUNTU=$(cat /etc/issue | grep Ubuntu)
- DEBIAN=$(cat /etc/issue | grep Debian)
- CENTOS=$(cat /etc/issue | grep CentOS)
- if [ -n "$DEBIAN" ]; then
- DISTRO="Debian"
- elif [ -n "$UBUNTU" ]; then
- DISTRO="Ubuntu"
- elif [ -n "$CENTOS" ]; then
- DISTRO="CentOS"
- else
- DISTRO=""
- echo "Unsupported distro"
- exit;
- fi
- echo "Your distribution has been detected as $DISTRO, is this correct?"
- select yn in "Yes" "No"; do
- case $yn in
- Yes ) installdeps
- buildinstall
- winetricksxact
- winetricksxact
- xvfbinstall
- createstartscript
- break;;
- No ) exit;;
- esac
- done
- echo ""
- echo "Script has completed, hopefully everything works!"
- echo ""
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement