Advertisement
Guest User

dvd1_to_memstick.sh

a guest
Dec 16th, 2013
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.41 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  4. export PATH
  5.  
  6. if [ -z "$*" ]; then
  7.     echo `basename $0 [dvd1 img] [dvd1 dir] [memstick img] [memstick dir]`
  8.     echo '  [dvd1 img] is the dvd1 image to convert'
  9.     echo '  [dvd1 dir] is the mountpoint for the dvd1 image'
  10.     echo '  [memstick img] is name of the memstick image file to create'
  11.     echo '  [memstick dir] is temporary working directory for the memstick contents'
  12.     exit 1
  13. fi
  14.  
  15. if [ ! -f $1 ]; then
  16.     echo "Source dvd1 image does not exist."
  17.     exit 1
  18. fi
  19.  
  20. if [ ! -d $2 ]; then
  21.     echo "Mountpoint must be a directory."
  22.     exit 1
  23. fi
  24.  
  25. if [ -e $3 ]; then
  26.     echo "Memstick file already exists."
  27.     exit 1
  28. fi
  29.  
  30. if [ ! -d $4 ]; then
  31.     echo "Memstick directory does not exist or is not a directory."
  32.     exit 1
  33. fi
  34.  
  35. unit=`mdconfig -a -t vnode -f $1`
  36. if [ $? -ne 0 ]; then
  37.     echo "dvd1 image mdconfig failed"
  38.     exit 1
  39. fi
  40. mount_cd9660 /dev/$unit $2
  41. tar cf - -C $2 . | tar xpf - -C $4
  42. umount $2
  43. if [ $? -eq 0 ]; then
  44.     mdconfig -d -u $unit
  45. else
  46.     echo "Did not unmount dvd1."
  47. fi
  48.  
  49. echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > $4/etc/fstab
  50. makefs -B little -o label=FreeBSD_Install $3 $4
  51. if [ $? -ne 0 ]; then
  52.   echo "makefs failed"
  53.   exit 1
  54. fi
  55.  
  56. unit=`mdconfig -a -t vnode -f $3`
  57. if [ $? -ne 0 ]; then
  58.   echo "mdconfig failed"
  59.   exit 1
  60. fi
  61. gpart create -s BSD $unit
  62. gpart bootcode -b $4/boot/boot $unit
  63. gpart add -t freebsd-ufs $unit
  64. mdconfig -d -u $unit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement