Skip to content

Instantly share code, notes, and snippets.

@maaatts
Last active October 6, 2015 19:49
Show Gist options
  • Save maaatts/8eaa0a35379d7e77aa85 to your computer and use it in GitHub Desktop.
Save maaatts/8eaa0a35379d7e77aa85 to your computer and use it in GitHub Desktop.
8BitMMO Gamepack Archiver
#!/bin/bash
pushd `dirname $0` > /dev/null
ARCHIVELOC="$(pwd)/archive"
popd > /dev/null
download() {
if hash curl 2>/dev/null; then
curl -silent -O "$@"
elif hash wget 2>/dev/null; then
wget -quiet "$@" > /dev/null;
else
echo "Unable to locate cURL or wget. Quitting."
echo "Try # apt-get install curl"
exit 1
fi
}
if ! hash unzip 2>/dev/null; then
echo "Unable to locate unzip. Quitting."
echo "Try # apt-get install unzip"
exit 1
fi
if ! hash strings 2>/dev/null; then
echo "Unable to locate strings. Quitting."
echo "Try # apt-get install binutils"
exit 1
fi
echo "8BitMMO Client Archival Script by mallard"
echo "Starting at `date` as `whoami`"
echo "Archiving at $ARCHIVELOC"
pushd $(mktemp -d) > /dev/null
download "https://s3.amazonaws.com/8BitMMO/HTMudWeb.jar"
if [ ! -f "HTMudWeb.jar" ]; then
echo "Whoops! Failed to download jar."
exit 1
fi
unzip -qq HTMudWeb.jar 2> /dev/null
VERSION=$(strings HTMud/MainMenu.class | grep -oP "(?<=vSprint8.0/)[0-9]+" | head -1)
echo "The latest 8BitMMO version is $VERSION"
FILENAME="${ARCHIVELOC}/HTMudWeb_${VERSION}.jar"
if [ -f "$FILENAME" ]; then
echo "${VERSION} already exists. Quitting.";
else
if [ ! -d "$ARCHIVELOC" ]; then
mkdir -p "$ARCHIVELOC"
fi
echo "Archiving version $VERSION"
mv HTMudWeb.jar "$FILENAME"
fi
echo "Done! Bye."
rm -r "$(pwd)" > /dev/null
popd > /dev/null
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment