Skip to content

Instantly share code, notes, and snippets.

@grepwood
Created July 14, 2014 21:20
Show Gist options
  • Save grepwood/a81ff559dd715dba66c5 to your computer and use it in GitHub Desktop.
Save grepwood/a81ff559dd715dba66c5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Hi I am grepwood, this is OpenTTD, and this - is Jackass
# Before we begin proper, let's define ourselves some functions because we like to keep it simple
function compile {
DESIRED_VERSION=$1
TARBALL_FILE="openttd-$DESIRED_VERSION-source.tar.xz" # XZ, because we like our bandwidth
TARBALL_LINK="http://binaries.openttd.org/releases/$DESIRED_VERSION/$TARBALL_FILE"
COMPILE_OPTIONS="--prefix-dir=/usr/local --enable-profiling --enable-lto --enable-dedicated --with-liblzma --without-liblzo2 --with-threads"
CFLAGS="-march=native -O2 -pipe"
OBS=`cat /proc/cpuinfo | grep vendor_id | wc -l`
STEVE="-j$OBS"
wget $TARBALL_LINK
tar -xf $TARBALL_FILE
cd openttd-$DESIRED_VERSION
$CFLAGS ./configure $COMPILE_OPTIONS
make $STEVE install
}
# Now we're talking
ARGUMENT_COUNT=$# # We need at least 1 argument
DESIRED_VERSION=$1 # This is the version we want to install
OPENTTD_PATH="/usr/local/games" # This is where we EXPECT to find openttd.
OPENTTD_EXE="openttd" # Do not EVER change this UNLESS you notify
# SUCS staff about it
# If we don't say what version to install, we do nothing
if [ "$ARGUMENT_COUNT" -ne "1" ]; then
echo "We need to know what version to install!"
exit
fi
# Now we must check if we actually have OpenTTD
if [ ! -f "$OPENTTD_PATH/$OPENTTD_EXE" ]; then
echo "We don't have OpenTTD installed!"
compile $DESIRED_VERSION
echo "Installed $DESIRED_VERSION!"
else
CURRENT_VERSION=`openttd --help | head -n1 | awk '{print $2}'` # This is the current version we have
if [ "$CURRENT_VERSION" != "$DESIRED_VERSION" ]; then
compile $DESIRED_VERSION
echo "Replaced $CURRENT_VERSION with $DESIRED_VERSION!"
else
echo "We already have this version installed!"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment