Advertisement
Guest User

20XX-4.0.3-convert.sh

a guest
Nov 25th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1.  
  2. #!/bin/sh
  3.  
  4. version=03
  5. vanillamd5="0e63d4223b01d9aba596259dc155a174"
  6. modmd5="f79a61286f2c845f72975bcdaafca6aa"
  7.  
  8. infile="$1"
  9. outfile="20XX 4.0 Beta${version}.iso"
  10. delta="20XX 4.0 Beta${version} xdelta patch.xdelta"
  11.  
  12. # not doing checking, so make sure you have these binaries installed somewhere
  13. xdelta=xdelta3
  14. md5sum=md5sum
  15.  
  16.  
  17. checkhash () {
  18.     printf "    This will take a few moments...."
  19.     filehash=$(${md5sum} -b "$1" |cut -d' ' -f1)
  20.     if [ "$filehash" != "$2" ]; then
  21.         printf "FAIL\n"
  22.         printf "Hashes don't match. Continue? (y/n) "
  23.         read cont;
  24.         if [ "$cont" != "y" ]; then
  25.             exit
  26.         fi
  27.     fi
  28.     printf "SUCCESS\n"
  29. }
  30.  
  31. build () {
  32.     if [ -f "$outfile" ]; then
  33.         printf "File $outfile already exists. Overwrite? (y/n) "
  34.         read overwrite
  35.         if [ "$overwrite" != "y" ]; then
  36.             exit
  37.         fi
  38.     fi
  39.     printf "Constructing 20XX 4.0 Beta${version}.\n"
  40.     printf "    Please stand by...."
  41.  
  42.     $xdelta -f -d -s "$infile" "$delta" "$outfile" 2>/dev/null && printf "SUCCESS\n" || printf "FAIL\n"
  43. }
  44.  
  45. if [ "$infile" = "" ]; then
  46.     printf "usage: 20XX-4.0.3-convert.sh FILE\n"
  47.     exit
  48. fi
  49. printf "Verifying that the given file is a vanilla v1.02 copy of SSBM.\n"
  50. checkhash "$infile" "$vanillamd5"
  51. printf "The ISO has been verified!\n\n"
  52.  
  53. build
  54. test $? -eq 0 || exit
  55. printf "Conversion complete!\n\n"
  56.  
  57. printf "Would you like to check the hash of your new 20XX copy? (y/n): "
  58. read check;
  59. if [ "$check" = "y" ]; then
  60.     checkhash "$outfile" "$modmd5"
  61. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement