burniso2cd 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #!/bin/sh
  2. #(c) Copyright 2006, 2007 Barry Kauler.
  3. #Lesser GPL licence v2 (/usr/share/doc/legal). 2007 www.puppylinux.com
  4. #simple script to burn an iso file to cd, using cdrecord.
  5. #7Sept2007: cdecord -scanbus bugfix, plus overall improvements.
  6. #v3.02 2Nov2007 BK: bugfix. v3.94 24dec2007: no /dev/hd*
  7. #w482 change -pad to padsize=300k, recommended by xorriso developer.
  8. #w482 migrate to using xorriso.
  9. #v431 rerwin: Add wait for drive lights to stop flashing before verifying and log the verify dd messages.
  10. #110205 previous probedisk script removed.
  11. #120201 rodin.s: internationalized.
  12. #120323 replace 'xmessage' with 'pupmessage'.
  13. #120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
  14. #130203 change probedisk2 to probedisk.
  15. export TEXTDOMAIN=burniso2cd
  16. export TEXTDOMAINDIR=/usr/share/locale
  17. export OUTPUT_CHARSET=UTF-8
  18. eval_gettext () {
  19. local myMESSAGE=$(gettext "$1")
  20. eval echo \"$myMESSAGE\"
  21. }
  22. export LANGORG=$LANG
  23. Yes_lbl="$(gettext 'Yes')"
  24. No_lbl="$(gettext 'No')"
  25. CDRECORD='cdrecord'
  26. if [ "`which xorriso`" != "" ];then
  27. CDRECORD='xorrecord'
  28. export MKISOFS='xorrisofs' #growisofs reads this variable.
  29. fi
  30. MEDIATYPE="`Xdialog --wmclass "mini-cd" --title "Burniso2cd" --stdout --menubox "$(gettext "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 "$(gettext 'CD-R or CD-RW (must be blank)')" DVD "$(gettext 'DVD-R or DVD-RW (must be blank)')"`"
  31. [ ! $? -eq 0 ] && exit
  32. SELECTIONS="`probedisk | grep '|optical|' | grep '/dev/' | cut -f 1,3 -d '|' | tr " " '_' | tr -s '_'`" #110205
  33. SELECTIONX="`echo "$SELECTIONS" | tr '|' " " | tr "\n" " "`"
  34. if [ "$SELECTIONX" = "" ];then
  35. pupmessage -bg '#FF8080' "$(gettext 'Sorry, no CD/DVD drive detected')"
  36. exit
  37. fi
  38. BURNERDRIVE="`Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Choose burner drive')" --stdout --menubox "$(gettext 'Choose the CD/DVD drive to burn to')" 400x200 5 $SELECTIONX 2> /dev/null`"
  39. [ ! $? -eq 0 ] && exit
  40. [ ! -f /etc/cdburnerdevice ] && echo -n "$BURNERDRIVE" | sed -e 's/\/dev\///g' > /etc/cdburnerdevice
  41. ISOFILE="`Xdialog --wmclass "mini-cd" --backtitle "$(gettext 'Please choose the iso file...')" --title "$(gettext 'Burniso2cd: Choose iso file')" --stdout --no-buttons --fselect "*.iso" 0 0`"
  42. if [ ! $? -eq 0 ];then
  43. exit
  44. fi
  45. CDR="$BURNERDRIVE"
  46. CDDESCR="`echo "$SELECTIONS" | grep "$CDR" | cut -f 2 -d '|'`"
  47. while [ ! "`mount | grep "$CDR"`" = "" ];do
  48. pupmessage -bg "#ff8080" -center -name "burniso2cd" -title "Burniso2cd: ERROR" "The $CDR CD/DVD drive, described as:
  49. $CDDESCR
  50. is currently mounted.
  51. Use MUT or Pmount to unmount it.
  52. Please unmount CD drive, then click OK button..."
  53. done
  54. if [ "$MEDIATYPE" = "CD" ];then
  55. Xdialog --wmclass "mini-cd" --title "Burniso2cd" --stdout --ok-label "$(gettext 'NORMAL')" --cancel-label "$(gettext 'MULTI')" --yesno "$(gettext 'You have selected iso file:')
  56. $ISOFILE
  57. $(gettext 'Do you want to burn a multi-session CD?
  58. A multi-session CD is one that is left "open" so that further
  59. tracks may be burnt later. The iso file that you have selected
  60. will be burnt now as the first track.
  61. Note, this is an experimental option for the Puppy live-CD, to
  62. allow burning of sessions back to CD, thus personal data is saved
  63. to CD and a hard drive or usb stick is not required.')
  64. $(gettext "Please choose 'NORMAL' unless you have some special reason to burn
  65. the CD multi-session (such as the iso is specifically for multisession).
  66. Click 'NORMAL' button for normal burn...
  67. Click 'MULTI' button for multi-session...")" 0 0
  68. RETVAL=$?
  69. else
  70. RETVAL=12
  71. fi
  72. case $RETVAL in
  73. 0) #normal cd
  74. BURNMULTI="-dao" #v2.02 added -dao
  75. BURNMSG=""
  76. ;;
  77. 1) #multi cd
  78. #BURNMULTI="-multi -tao -pad" #v2.02 added -tao -pad
  79. BURNMULTI="-multi -tao padsize=300k" #w482
  80. BURNMSG=""
  81. ;;
  82. 12) #multi dvd
  83. BURNMULTI="yes"
  84. BURNMSG="$(gettext '(blank DVD-R. A DVD+/-RW will be fast-wiped if it has data)')"
  85. ;;
  86. *)
  87. exit
  88. ;;
  89. esac
  90. RECHECK="yes"
  91. BURNSPEED="10"
  92. while [ 1 ];do #burn-again-loop
  93. BURNSPEED="`Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Burn') $MEDIATYPE" --stdout --spinbox "$(eval_gettext "Please insert blank \\\$MEDIATYPE into \\\$CDR")
  94. $BURNMSG
  95. $(gettext '(which is described as:') ${CDDESCR})
  96. $(gettext 'Then click 'OK' button...')" 0 0 4 32 $BURNSPEED "$(gettext 'Set burn speed')"`"
  97. [ ! $? -eq 0 ] && exit
  98. sync
  99. if [ "$MEDIATYPE" = "CD" ];then
  100. DEVDEV="$CDR" #w482
  101. echo "$(gettext 'Now executing:')"
  102. echo " $CDRECORD $BURNMULTI -data -eject -v speed=$BURNSPEED dev=$DEVDEV $ISOFILE"
  103. rxvt -name burniso2cd -bg orange -geometry 80x10 -e $CDRECORD $BURNMULTI -data -eject -v speed=$BURNSPEED dev=$DEVDEV "$ISOFILE"
  104. else #dvd
  105. echo "$(gettext 'Now executing:')"
  106. echo " growisofs -speed=$BURNSPEED -Z $CDR=$ISOFILE"
  107. rxvt -name burniso2cd -bg orange -geometry 80x10 -e growisofs -speed=$BURNSPEED -Z $CDR="$ISOFILE"
  108. fi
  109. sync
  110. echo "$(gettext '...done')"
  111. #v2.10 kirk contributed this...
  112. # ******Verify burn******
  113. DEVNAME="`echo -n "$CDR" | grep '/dev' | cut -f 3 -d '/'`"
  114. if [ ! "$DEVNAME" = "" -a "$RECHECK" = "yes" ];then
  115. Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Finished')" --stdout --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$(gettext 'Would you like to verify that the burn was successful?
  116. This may take a while depending on the size of the iso file.')" 0 0
  117. if [ "$?" = "0" ] ;then
  118. pupmessage -bg "#80ff80" -center -name "burniso2cd" -title "$(gettext 'Burniso2cd: Burn Verify')" "$(gettext 'Make sure the CD/DVD drive is closed,
  119. then click OK')"
  120. echo "Waiting 15 seconds to allow drive lights to finish blinking" > /tmp/burniso2cd.log #v431
  121. sleep 15 #v431
  122. if [ "$( md5sum $ISOFILE | cut -f 1 -d " " )" = "$(dd if=$CDR 2>> /tmp/burniso2cd.log | head -c `stat --format=%s $ISOFILE` | md5sum | cut -f 1 -d " " )" ] ;then #v431
  123. pupmessage -bg "#80ff80" -center -name "burniso2cd" -title "$(gettext 'Burniso2cd: Burn Verify')" "$(gettext 'The burn has been verified as good!')"
  124. else
  125. pupmessage -bg "#ffc0c0" -center -name "burniso2cd" -title "$(gettext 'Burniso2cd: Burn Verify')" "$(gettext 'The burn was not verified. See details in /tmp/burniso2cd.log. You should start over.')"
  126. fi
  127. else
  128. RECHECK="no" #do not check if doing repeat burns.
  129. fi
  130. fi
  131. eject $CDR
  132. Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Finished')" --stdout --ok-label "$(gettext 'FINISHED')" --cancel-label "$(gettext 'REPEAT')" --yesno "$(gettext 'If all went well, you have now burnt iso file')
  133. $ISOFILE
  134. $(gettext 'to a') $MEDIATYPE!
  135. $(gettext 'If you want to burn the iso file to another') $MEDIATYPE,
  136. $(gettext "click 'REPEAT' button...")
  137. $(gettext "Otherwise, click 'FINISHED' to quit...")" 0 0
  138. [ $? -ne 1 ] && break
  139. done #burn-again-loop
  140. ###END###