Last active
July 10, 2017 06:45
-
-
Save keyz/acd3fb15003f5295bae57434a01eaf79 to your computer and use it in GitHub Desktop.
20xx 4.06 conversion script for Mac
This file contains 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/sh | |
version=4.07 | |
vanillamd5="0e63d4223b01d9aba596259dc155a174" | |
modmd5="c8ccc5cd8788fe0cf8f24bca123e4a2e" | |
infile="$1" | |
outfile="SSBM, 20XXHP ${version}.iso" | |
delta="SSBM, 20XXHP ${version} xdelta patch.xdelta" | |
which -s brew | |
if [[ $? != 0 ]] ; then | |
# Install Homebrew | |
printf "The script requires Homebrew.\n" | |
printf "See https://brew.sh/ for installation instructions.\n" | |
exit 1 | |
else | |
brew install xdelta | |
fi | |
xdelta=xdelta3 | |
md5sum=md5 | |
checkhash () { | |
printf " This will take a few moments...." | |
filehash=$(${md5sum} -q "$1") | |
if [ "$filehash" != "$2" ]; then | |
printf "FAIL\n" | |
printf "Hashes don't match. Continue? (y/n) " | |
read cont; | |
if [ "$cont" != "y" ]; then | |
exit | |
fi | |
fi | |
printf "SUCCESS\n" | |
} | |
build () { | |
if [ -f "$outfile" ]; then | |
printf "File $outfile already exists. Overwrite? (y/n) " | |
read overwrite | |
if [ "$overwrite" != "y" ]; then | |
exit | |
fi | |
fi | |
printf "Constructing 20XXHP ${version}.\n" | |
printf " Please stand by...." | |
$xdelta -f -d -s "$infile" "$delta" "$outfile" 2>/dev/null && printf "SUCCESS\n" || printf "FAIL\n" | |
} | |
if [ "$infile" = "" ]; then | |
printf "usage: 20xx-${version}-convert.sh FILE\n" | |
exit | |
fi | |
printf "Verifying that the given file is a vanilla v1.02 copy of SSBM.\n" | |
checkhash "$infile" "$vanillamd5" | |
printf "The ISO has been verified!\n\n" | |
build | |
test $? -eq 0 || exit | |
printf "Conversion complete!\n\n" | |
printf "Would you like to check the hash of your new 20XX copy? (y/n): " | |
read check; | |
if [ "$check" = "y" ]; then | |
checkhash "$outfile" "$modmd5" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment