#!/bin/sh
# http://www.berklix.com/~jhs//bin/.sh/iso2vob	By jhs@@@berklix.com
# echo "Could add code for sighup handler to unmount & deconfig"
# See also new_cd
# Syntax:
#	iso2vob dir/film.iso
# Input:	some/path/film.iso
# Output:	video_ts/*.vob
#		video_ts/ or VIDEO_TS/ come from the .iso
# To reassemble:	mkisofs -o /usr/tmp/film.iso video_ts

# echo "Starting $1"
doit="mdconfig -a -t vnode -f $1"
# echo "Nodes before allocate: `xs mdconfig -l`."
# echo "Allocate command: $doit"
rslt=`xs $doit`
# echo "Nodes after allocate: `xs mdconfig -l`."
unit=`echo $rslt|sed -e s/md//`
# echo "Node unit ${unit}"
# echo "Node info: `xs mdconfig -l -u ${unit}`"
doit="mount -t cd9660 -r /dev/md${unit} /mnt"
# echo "Mount command: $doit" 
xs $doit
# echo "Extracting $1"
( cd /mnt ; tar cf - . ) | tar xvf - 
xs umount /mnt
# echo "Nodes before de-allocation: `xs mdconfig -l`."
doit="mdconfig -d -u ${unit}"
# echo "De-allocation command: $doit" 
xs $doit
# echo "Nodes after de-allocation: `xs mdconfig -l`."
# echo "Finished $1"
