home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / burniso2cd < prev    next >
Encoding:
Text File  |  2006-06-27  |  5.9 KB  |  166 lines

  1. #!/bin/sh
  2. #simple script to burn an iso file to cd, using cdrecord.
  3.  
  4. #while [ ! -f /etc/cdburnerdevice ];do
  5. # xmessage -bg "#ff8080" -center -name "burniso2cd" -title "Burniso2cd: No CD burner" -buttons "CD_Wizard:10,EXIT:11" "A problem...
  6. #You have not yet run the Puppy CD/DVD drive Wizard, to choose
  7. #which CD/DVD drive will be the burner drive.
  8. #I know that it seems somewhat academic if your PC only has one
  9. #CD/DVD drive, but you have to do it.
  10. #Click \"CD_Wizard\" button now to run the Wizard, then click on
  11. #\"Choose burner\" then click on \"EXIT\", which will bring you back
  12. #to this script.
  13. #
  14. #Click \"CD_Wizard\" button to run CD/DVD Wizard..."
  15. # case $? in
  16. #  10)
  17. #   /usr/sbin/cdburner-wizard
  18. #   ;;
  19. #  *)
  20. #   exit
  21. #   ;;
  22. # esac
  23. #done
  24.  
  25. #if [ "`cat /etc/scsiemul 2> /dev/null`" = "on"  ];then
  26. # xmessage -bg "#ff8080" -center -name "burniso2cd" -title "Burniso2cd: ERROR" -buttons "EXIT:11" "This script is setup to do ATAPI CD burning, but you have
  27. #SCSI-emulation turned on. Therefore this script cannot burn
  28. #the iso file to CD and you will have to do it in a CD-burner
  29. #program such as Gcombust or Xcdroast.
  30. #So, no choice now but to exit script."
  31. # exit
  32. #fi
  33.  
  34. #v2.0.0
  35. MEDIATYPE="`Xdialog --title "Burniso2cd" --stdout --menubox "Welcome to our little CD/DVD burner program!\nPlease choose whether you want to burn to a CD or DVD media.\nNote that DVDs are always burnt 'open' so can be used by Puppy\nas normal or multisession, whereas for CD you will be given\nthe choice further on whether to burn as closed or open." 0 0 5 CD "CD-R or CD-RW (must be blank)" DVD "DVD-R or DVD-RW (must be blank)"`"
  36. [ ! $? -eq 0 ] && exit
  37.  
  38.  
  39. #v2.0.0
  40. if [ "$MEDIATYPE" = "CD" ];then
  41.  SCSIDRIVES="`cdrecord -scanbus 2>&1 | grep '[0-9],[0-9],[0-9]' | grep -v '*$' | tr '|' " " | tr '\t' '|' | cut -f 2,3 -d '|' | tr -s " " | tr "'" '_' | tr " " '_' | tr -s '_'`" #'
  42.  ATAPIDRIVES="`probedisk | grep '|cdrom|' | grep '/dev/hd' | cut -f 1,3 -d '|' | tr " " '_' | tr -s '_'`"
  43. else
  44.  ATAPIDRIVES="`probedisk | grep '|cdrom|' | grep '/dev/hd' | cut -f 1,3 -d '|' | tr " " '_' | tr -s '_'`"
  45.  SCSIDRIVES="`probedisk | grep '/dev/scd' | cut -f 1,3 -d '|' | tr " " '_' | tr -s '_'`"
  46. fi
  47. SELECTIONS="$ATAPIDRIVES
  48. $SCSIDRIVES"
  49. SELECTIONX="`echo "$SELECTIONS" | tr '|' " " | tr "\n" " "`"
  50.  
  51. BURNERDRIVE="`Xdialog --title "Burniso2cd: Choose burner drive" --stdout --menubox "Choose the CD/DVD drive to burn to\n(/dev/scd0 or 0,0,0 format are SCSI drives,\n/dev/hda format are IDE/ATAPI drives)" 0 0 5 $SELECTIONX 2> /dev/null`"
  52. [ ! $? -eq 0 ] && exit
  53.  
  54. if [ ! "`echo -n "$BURNERDRIVE" | grep '/dev/'`" = "" ];then
  55.  #better not write 0,0,0 format...
  56.  [ ! -f /etc/cdburnerdevice ] && echo -n "$BURNERDRIVE" | sed -e 's/\/dev\///g' > /etc/cdburnerdevice
  57. fi
  58.  
  59. ISOFILE="`Xdialog --backtitle "Please choose the iso file..." --title "Burniso2cd: Choose iso file" --stdout --no-buttons --fselect "*.iso" 0 0`"
  60. if [ ! $? -eq 0 ];then
  61.  exit
  62. fi
  63.  
  64. #BURNERDRIVE="/dev/`cat /etc/cdburnerdevice`" #set by CD/DVD Wizard.
  65. CDR="$BURNERDRIVE"
  66. #CDDESCR="`probedisk | grep "$CDR" | cut -f 3 -d '|'`"
  67. CDDESCR="`echo "$SELECTIONS" | grep "$CDR" | cut -f 2 -d '|'`"
  68.  
  69. while [ ! "`mount | grep "$CDR"`" = "" ];do
  70.  xmessage -bg "#ff8080" -center -name "burniso2cd" -title "Burniso2cd: ERROR" "The $CDR CD/DVD drive, described as:
  71.  $CDDESCR
  72. is currently mounted.
  73. Use MUT to unmount it.
  74.  
  75. Please unmount CD drive, then click OK button..."
  76. done
  77.  
  78. if [ "$MEDIATYPE" = "CD" ];then
  79. xmessage -bg "#ffc0c0" -center -name "burniso2cd" -title "Burniso2cd" -buttons "NORMAL-CD:10,MULTI-CD:11" "You have selected iso file:
  80.  $ISOFILE
  81.  
  82. Do you want to burn a multi-session CD?
  83. A multi-session CD is one that is left \"open\" so that further
  84. tracks may be burnt later. The iso file that you have selected
  85. will be burnt now as the first track.
  86.  
  87. Note, this is an experimental option for the Puppy live-CD, to
  88. allow burning of sessions back to CD, thus personal data is saved
  89. to CD and a hard drive or usb stick is not required. If you choose
  90. MULTI-CD, you will be burning to a CD-R or CD-RW.
  91.  
  92. Please choose NORMAL unless you have some special reason to burn the
  93. CD multi-session (such as the iso is specifically for multisession).
  94.  
  95. Click MULTI-CD button for multi-session...
  96. Click NORMAL-CD button for normal burn..."
  97.  RETVAL=$?
  98. else
  99.  RETVAL=12
  100. fi
  101.  
  102. case $RETVAL in
  103.  10) #normal cd
  104.   BURNMULTI="-dao" #v2.02 added -dao
  105.   BURNMSG=""
  106.   ;;
  107.  13) #normal dvd
  108.   BURNMULTI=""
  109.   BURNMSG="(blank DVD-R. A DVD-RW will be fast-wiped if it already has data)"
  110.   ;;
  111.  11) #multi cd
  112.   BURNMULTI="-multi -tao -pad" #v2.02 added -tao -pad
  113.   BURNMSG=""
  114.   ;;
  115.  12) #multi dvd
  116.   BURNMULTI="yes"
  117.   BURNMSG="(blank DVD-R. A DVD+/-RW will be fast-wiped if it has data)"
  118.   ;;
  119.  *)
  120.   exit
  121.   ;;
  122. esac
  123.  
  124. while [ 1 ];do #burn-again-loop
  125. xmessage -bg "#ffc0c0" -center -name "burniso2cd" -title "Burniso2cd: Burn $MEDIATYPE" -buttons "OKAY:10" "Please insert blank $MEDIATYPE into $CDR
  126. $BURNMSG
  127. (which is described as: ${CDDESCR})
  128.  
  129. Then click OKAY button..."
  130. if [ ! $? -eq 10 ];then
  131.  exit
  132. fi
  133.  
  134. if [ "$MEDIATYPE" = "CD" ];then
  135.  #echo "Now executing:"
  136.  #echo " cdrecord $BURNMULTI -data -eject -v speed=4 dev=ATAPI:$CDR $ISOFILE"
  137.  sync
  138.  if [ ! "`echo "$CDR" | grep '/dev/hd'`" = "" ];then
  139.   DEVDEV="ATAPI:$CDR"
  140.  else
  141.   DEVDEV="$CDR"
  142.  fi
  143.  echo "Now executing:"
  144.  echo " cdrecord $BURNMULTI -data -eject -v speed=4 dev=$DEVDEV $ISOFILE"
  145.  rxvt -name burniso2cd -bg orange -geometry 80x10 -e cdrecord $BURNMULTI -data -eject -v speed=4 dev=$DEVDEV "$ISOFILE"
  146. else #dvd
  147.  echo "Now executing:"
  148.  echo " growisofs -speed=4 -Z $CDR=$ISOFILE"
  149.  rxvt -name burniso2cd -bg orange -geometry 80x10 -e growisofs -speed=4 -Z $CDR="$ISOFILE"
  150. fi
  151. sync
  152. echo "...done"
  153. eject $CDR
  154. xmessage -bg "#80ff80" -center -name "burniso2cd" -title "Burniso2cd: Finished" -buttons "FINISHED:10,REPEAT:11" "If all went well, you have now burnt iso file
  155. $ISOFILE
  156. to a $MEDIATYPE!
  157.  
  158. If you want to burn the iso file to another $MEDIATYPE,
  159. click REPEAT button...
  160.  
  161. Otherwise, click FINISHED to quit..."
  162. [ $? -lt 11 ] && break
  163. done #burn-again-loop
  164.  
  165. ###END###
  166.