Advertisement
Guest User

mkbluray

a guest
Jan 3rd, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.03 KB | None | 0 0
  1. #!/bin/bash
  2. # orig: http://changelog.complete.org/archives/1172-how-to-record-high-definition-mythtv-files-to-dvd
  3. # changes: bbdo
  4.  
  5. set -e
  6.  
  7. if [ ! -d "$1" -o -e "$2" -o -z "$2" ]; then
  8.    echo "Syntax: $0 srcdir destimage"
  9.    exit 1
  10. fi
  11.  
  12. if [ "`id -u`" != "0" ]; then
  13.    echo "This program must run as root."
  14.    exit 1
  15. fi
  16.  
  17. EXTRAARGS=""
  18. if [ ! -z "$3" ]; then
  19.    EXTRAARGS="--vid=$3"
  20. fi
  21.  
  22. SECSIZE=1024
  23.  
  24. SIZE=`du -s $1|awk '{print $1}'`
  25.  
  26. # Add some padding
  27. SECTORS=`expr ${SIZE} + 8192`
  28.  
  29. echo "Allocating image..."
  30.  
  31. dd if=/dev/zero "of=$2" bs=$SECSIZE "seek=$SECTORS" count=1
  32.  
  33. echo "Creating filesystem..."
  34.  
  35. mkudffs --blocksize=2048 --vid "$2" $EXTRAARGS "$2"
  36.  
  37. mkdir "$2.mnt"
  38.  
  39. mount -o rw,loop -t udf "$2" "$2.mnt"
  40.  
  41. trap "echo 'CTRL-C, cleaing up' ; sleep 3 ; umount -f $2.mnt ; rm -rf $2.mnt ; rm $2" SIGINT SIGTERM
  42.  
  43. # rsync to give OCD people something to watch.
  44. (cd $1 && /usr/bin/rsync --recursive --progress --stats --size-only . "../$2.mnt/")
  45. echo "finishing.."
  46. umount "$2.mnt"
  47. rmdir "$2.mnt"
  48.  
  49. echo "done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement