Advertisement
Guest User

Fixed Script

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