Last active
January 18, 2016 10:04
-
-
Save jhead/4adafca841192f9cf01f to your computer and use it in GitHub Desktop.
P.S. gunfighterj - I stole your sums list ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SUMS_URL="http://s3.amazonaws.com/cubedhost-prisma/spigot/sums" | |
JENKINS_URL="http://ci.md-5.net/job/Spigot" | |
if [ -z $1 ]; then | |
echo "A tool which tries to identify hash, build #, and full version for an arbitrary Spigot jar file." | |
echo | |
echo "Usage: ./identifySpigot <spigot.jar>" | |
echo | |
exit 1 | |
fi | |
spigotFile=$1 | |
if [ ! -e $spigotFile ]; then | |
echo "File does not exist." | |
exit 1 | |
fi | |
## load checksums | |
echo -n "Loading checsksums... " | |
SUMS=$(curl -s $SUMS_URL) | |
if [ $? -ne 0 ]; then | |
echo "Failed." | |
exit 1 | |
else | |
echo "Done!" | |
fi | |
echo | |
## md5 the spigot file | |
echo -n "Checksum: " | |
hash=$(md5sum $spigotFile | awk '{ print $1 }') | |
echo $hash | |
## look up the hash in the list | |
echo -n "Build: " | |
buildNumber="unknown" | |
if [[ ! -z "$SUMS" ]]; then | |
buildNumber="#"$(echo "$SUMS" | grep $hash | awk '{ print $1 }') | |
fi | |
if [[ $buildNumber != "#" ]]; then | |
echo "$buildNumber" | |
else | |
echo "Not found. Is it newer than MC 1.7.10?" | |
fi | |
## try to find the full Spigot jar filename | |
pomProps=$(unzip -p $spigotFile META-INF/maven/org.spigotmc/spigot-api/pom.properties) | |
[ $? -ne 0 ] && echo "Failed to load version info." && exit 1 | |
echo -n "Version: " | |
version=$(echo "$pomProps" | grep version | cut -d '=' -f 2) | |
if [[ -z "$version" ]]; then | |
echo "Failed to detect." | |
else | |
echo "$version" | |
fi | |
## find Spigot/CB git commit hashes | |
manifest=$(unzip -p $spigotFile META-INF/MANIFEST.MF) | |
[ $? -ne 0 ] && echo "Failed to load extra version info." && exit 1 | |
implVersion=$(echo "$manifest" | grep 'Implementation-Version' | awk '{ print $2 }' | grep git) | |
if [[ $(echo "$implVersion" | wc -l) -ne 1 ]]; then | |
echo "Doesn't contain specific version info." | |
else | |
spigotCommit=$(echo "$implVersion" | cut -d '-' -f 3) | |
cbCommit=$(echo "$implVersion"| cut -d '-' -f 4) | |
if [[ ! -z $spigotCommit ]] && [[ -z $cbCommit ]]; then | |
echo | |
echo "This jar does not contain git commit info for Spigot/CraftBukkit." | |
else | |
echo "Spigot: $spigotCommit" | |
echo "CraftBukkit: $cbCommit" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment