Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # orig: http://changelog.complete.org/archives/1172-how-to-record-high-definition-mythtv-files-to-dvd
- # changes: bbdo
- set -e
- if [ ! -d "$1" -o -e "$2" -o -z "$2" ]; then
- echo "Syntax: $0 srcdir destimage"
- exit 1
- fi
- if [ "`id -u`" != "0" ]; then
- echo "This program must run as root."
- exit 1
- fi
- EXTRAARGS=""
- if [ ! -z "$3" ]; then
- EXTRAARGS="--vid=$3"
- fi
- SECSIZE=1024
- SIZE=`du -s $1|awk '{print $1}'`
- # Add some padding
- SECTORS=`expr ${SIZE} + 8192`
- echo "Allocating image..."
- dd if=/dev/zero "of=$2" bs=$SECSIZE "seek=$SECTORS" count=1
- echo "Creating filesystem..."
- mkudffs --blocksize=2048 --vid "$2" $EXTRAARGS "$2"
- mkdir "$2.mnt"
- mount -o rw,loop -t udf "$2" "$2.mnt"
- trap "echo 'CTRL-C, cleaing up' ; sleep 3 ; umount -f $2.mnt ; rm -rf $2.mnt ; rm $2" SIGINT SIGTERM
- # rsync to give OCD people something to watch.
- (cd $1 && /usr/bin/rsync --recursive --progress --stats --size-only . "../$2.mnt/")
- echo "finishing.."
- umount "$2.mnt"
- rmdir "$2.mnt"
- echo "done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement