OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.8 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/misc/iso2stick.sh
  6. # Copyright (C) 2008 The OpenSDE Project
  7. # Copyright (C) 2006 The T2 SDE Project
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. set -e
  17. usage()
  18. {
  19. echo "Usage iso2stick [ -fs file-system ] iso-image stick-device [ files ]"
  20. exit
  21. }
  22. fs="vfat -F 32"
  23. while [ "$1" ]; do
  24. case "$1" in
  25. -fs) fs="$2" ; shift ;;
  26. -*) usage ;;
  27. *) break ;;
  28. esac
  29. shift
  30. done
  31. if [ -z "$1" -o -z "$2" ]; then
  32. usage
  33. fi
  34. file="$1" ; shift
  35. dev="$1" ; shift
  36. # # ceate fresh image
  37. # size=`du --block-size=1000000 $1 | cut -f 1`
  38. # size=$(( size + 20 )) # just to be sure
  39. #
  40. # dd if=/dev/zero of=hd.img bs=1000000 count=$size
  41. # loop=`losetup -f`
  42. # losetup $loop hd.img
  43. case "$fs" in
  44. vfat*) ptype=b ;;
  45. *) ptype=83 ;;
  46. esac
  47. sfdisk $dev << EOT
  48. ,,$ptype
  49. EOT
  50. # losetup -d $loop
  51. mkfs.$fs ${dev}1
  52. # losetup /dev/loop0 -o 512 hd.img
  53. mkdir -p /mnt/source /mnt/target
  54. mount -o loop $file /mnt/source
  55. mount ${dev}1 /mnt/target
  56. rsync -arvH --inplace --exclude TRANS.TBL /mnt/source/ /mnt/target/
  57. # copy additional content specified in arguments
  58. for x ; do
  59. cp -arv $x /mnt/target/
  60. done
  61. sed -i 's/(cd)/(hd0,0)/g' /mnt/target/boot/grub/menu.lst
  62. umount /mnt/source
  63. umount /mnt/target
  64. echo -e "(hd0) /dev/sda" > device.map
  65. echo -e "root (hd0,0)\ninstall /boot/grub/stage1 (hd0) (hd0,0)/boot/grub/stage2 (hd0,0)/boot/grub/menu.lst\nquit" | grub --batch --device-map=./device.map
  66. rm ./device.map