home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / cdburner-wizard < prev    next >
Encoding:
Text File  |  2005-09-26  |  7.8 KB  |  226 lines

  1. #!/bin/sh
  2. #cd-burner wizard
  3. #Barry Kauler (c) copyright 2003,2004,2005
  4. #www.goosee.com/puppy
  5.  
  6. #updated for v1.0.5
  7.  
  8.  
  9. #make this optional feature...
  10. #this is the on/off scsi-emulate ide switch...
  11. FSCSIEMUL=""
  12. if [ ! -e /etc/scsiemul ];then
  13.  echo -n "off" > /etc/scsiemul
  14. fi
  15. FSCSIEMUL="`cat /etc/scsiemul`" #value is "on" or "off"
  16.  
  17. if [ "$FSCSIEMUL" = "on" ];then
  18.  xmessage -bg "orange" -center -name "burnwiz" -title "CD/DVD drive Wizard" -buttons "OK:10" "SCSI emulation of an IDE CD/DVD burner drive is currently switched on.
  19. Puppy is now using a modern Linux kernel that does not need SCSI-emulation.
  20.  
  21. When you click the OK button, you will be taken to the \"old\" CD/DVD Wizard,
  22. which is designed to handle SCSI-emulated CD/DVD burning.
  23. The old Wizard also has a button for turning off SCSI-emulation, and it
  24. is probably best that you do this.
  25.  
  26. Note however, that SCSI-emulated burning of CD/DVD IDE (internal) drives
  27. is considered to be more reliable, though I personally have not had any
  28. trouble with ATAPI (non-SCSI-emulated) CD burning."
  29.  
  30.  XREPLY=$?
  31.  case $XREPLY in
  32.   10) #scsi
  33.    exec /usr/sbin/cdburner-wizard-old
  34.    ;;
  35.   *)
  36.    exit
  37.    ;;
  38.  esac
  39. fi
  40.  
  41.  
  42. #using Antonio Gallo's program...
  43. DRIVESFND="`probedisk 2>&1`"
  44. IDEDRVSFND="`test-eide 2>&1 | grep "cdrom"`"
  45.  
  46. SELECTIONS="`echo "$DRIVESFND" | grep -i "cd" | grep -i "rom" | cut -f 1,3 -d "|" | tr " " "_" | tr "|" " " | tr '$' "_"`"
  47.  
  48. #number of physical cdrom/burner drives...
  49. NUMDRIVES=`echo "$DRIVESFND" | grep "cdrom" | wc -l | tr -d " " | tr -d "\n"`
  50. NUMIDEDRVS=`echo "$IDEDRVSFND" | grep "cdrom" | wc -l | tr -d " " | tr -d "\n"`
  51.  
  52. #one of these should have "RW" or "rw" if a burner...
  53. #( -i means ignore case)
  54. NUMBURNERS=`echo "$DRIVESFND" | grep -i "rw" | wc -l | tr -d " " | tr -d "\n"`
  55.  
  56. NUMCDROMS=`expr $NUMDRIVES - $NUMBURNERS`
  57.  
  58. #ok, which one is the burner?...
  59. if [ -f /etc/cdburnerdevice ];then
  60.  BURNERDEV1="/dev/`cat /etc/cdburnerdevice`"
  61. else
  62.  #careful, delimiter for IDEDRVSFND is spaces, not "|"...
  63.  BURNERDEV1="`echo "$IDEDRVSFND" | grep -i "cd" | grep -i "rw" | cut -f 1 -d " " | head -n 1 | tr -d "\n"`"
  64.  #...if there is a burner, this will now have "/dev/hdc" or whatever.
  65.  echo -n "$BURNERDEV1" | cut -f 3 -d '/' > /etc/cdburnerdevice
  66. fi
  67.  
  68. #which is the cdrom reader?...
  69. #note, /dev/cdrom created by rc.local0 if /etc/cdromdevice exists.
  70. #is there a cdrom drive without "rw" in it?...
  71. #( -v means if not found)
  72. CDROMDRVS="`echo "$DRIVESFND" | grep "cdrom" | grep -vi "rw" | cut -f 1 -d "|"`"
  73. #...if exists, has drive which is not a burner.
  74. if [ "$CDROMDRVS" = "" ];then
  75.  #nothing found. then, use the cd-burner...
  76.  CDROMDEV="$BURNERDEV1"
  77. else
  78.  #precaution if more than one cdrom ro drive...
  79.  CDROMDEV="`echo "$CDROMDRVS" | head -n 1 | tr -d "\n"`"
  80. fi
  81. #what is /dev/cdrom currently linked to?...
  82. CDROMLINK="`ls -l /dev/cdrom 2>/dev/null | tr -s " " | cut -f 11 -d " " | tr -d "\n"`"
  83. if [ "$CDROMLINK" ];then
  84.  CDROMDEV="$CDROMLINK" #override above search.
  85. fi
  86.  
  87. #which one is dvd player...
  88. #note, /dev/dvd created by rc.local0 if /etc/dvddevice exists.
  89. DVDDEV="`echo "$IDEDRVSFND" | grep -i "dvd" | cut -f 1 -d " " | head -n 1 | tr -d "\n"`"
  90. #what is /dev/dvd currently linked to?...
  91. DVDLINK="`ls -l /dev/dvd 2>/dev/null | tr -s " " | cut -f 11 -d " " | tr -d "\n"`"
  92. if [ "$DVDLINK" ];then
  93.  DVDDEV="$DVDLINK" #overrides the above.
  94. fi
  95.  
  96.  
  97. MSG0="Puppy CD/DVD drive Wizard"
  98. MSG1="Welcome to my CD and DVD drive wizard!"
  99. BGCOLOR1="#ffc0c0"
  100. VALIDDRIVES="$SELECTIONS"
  101.  
  102.  
  103. while :; do
  104.  
  105. xmessage -bg "$BGCOLOR1" -center -name "burnwiz" -title "$MSG0" -buttons \
  106.  Choose_cdrom:11,Choose_dvd:20,Choose_burner:10,HELP:15,EXIT:13 \
  107.  -file -<<FILETXT
  108. $MSG1
  109.  
  110. Puppy has probed your PC and found these CD/DVD drives:
  111. $VALIDDRIVES
  112.  
  113. Puppy thinks the default CDROM reader drive is:  $CDROMDEV
  114. Puppy thinks the default DVD reader drive is:    $DVDDEV
  115. Puppy thinks the default burner drive is:        $BURNERDEV1
  116.  
  117. DEVICE LINKS:
  118. /dev/cdrom is currently linked to: $CDROMLINK.
  119. /dev/dvd is currently linked to:   $DVDLINK.
  120.  
  121. If you disagree with these choices, click the "Choose_burner"
  122. or "Choose_cdrom" or "Choose_dvd" to change the selection.
  123. FILETXT
  124.  
  125. XREPLY=$?
  126.  
  127. if [ $XREPLY -eq 10 ];then #choose-burner
  128.  BGCOLOR1="#c0e0ff"
  129.   #v1.0.0
  130.   BURNERD0="`Xdialog --wmclass "burnwiz" --title "CD/DVD drive Wizard" --stdout --menubox "Choose which is the burner drive:" 0 48 4 $SELECTIONS 2> /dev/null `"
  131.  if [ ! $? -eq 0 ];then
  132.   MSG1="YOU MADE NO CHOICE FOR BURNER DRIVE, KEEPING $BURNERDEV1"
  133.  else
  134.   MSG1="YOU JUST CHOSE $BURNERD0 AS THE BURNER DRIVE"
  135.   BURNERDEV1="$BURNERD0"
  136.   echo -n "$BURNERDEV1" | cut -f 3 -d '/' > /etc/cdburnerdevice
  137.  fi 
  138. fi
  139.  
  140. if [ $XREPLY -eq 11 ];then #choose cdrom
  141.  BGCOLOR1="#c0e0ff"
  142.   #v1.0.0
  143.   CDROMD0="`Xdialog --wmclass "burnwiz" --title "CD/DVD drive Wizard" --stdout --menubox "Choose which is the CDROM drive:" 0 48 4 $SELECTIONS 2> /dev/null `"
  144.  if [ ! $? -eq 0 ];then
  145.   MSG1="YOU MADE NO CHOICE FOR CDROM DRIVE, KEEPING $CDROMDEV"
  146.  else
  147.    MSG1="YOU JUST CHOSE $CDROMD0 AS THE CDROM READER DRIVE"
  148.    CDROMDEV="$CDROMD0"
  149.     CDROMLINK="$CDROMDEV"
  150.    #strip off the leading "/dev/"...
  151.    echo -n $CDROMLINK | cut -f 3 -d '/' > /etc/cdromdevice
  152.    rm -f /dev/cdrom
  153.    ln -s $CDROMLINK /dev/cdrom
  154.  fi 
  155. fi
  156.  
  157. if [ $XREPLY -eq 20 ];then #choose dvd
  158.  BGCOLOR1="#c0e0ff"
  159.  #v1.0.0
  160.  DVDD0="`Xdialog --wmclass "burnwiz" --title "CD/DVD drive Wizard" --stdout --menubox "Choose which is the DVD drive:" 0 48 4 $SELECTIONS 2> /dev/null `"
  161.  if [ ! $? -eq 0 ];then
  162.   MSG1="YOU MADE NO CHOICE FOR DVD DRIVE, KEEPING $DVDDEV"
  163.  else
  164.   MSG1="YOU JUST CHOSE $DVDD0 AS THE DVD READER DRIVE"
  165.   DVDDEV="$DVDD0"
  166.   DVDLINK="$DVDDEV"
  167.    #strip off the leading "/dev/"...
  168.    echo -n $DVDLINK | cut -f 3 -d '/' > /etc/dvddevice
  169.    rm -f /dev/dvd
  170.    ln -s $DVDLINK /dev/dvd
  171.  fi 
  172. fi
  173.  
  174.  
  175.  
  176. if [ $XREPLY -eq 15 ];then #help
  177.  xmessage -bg "purple" -center -name "burnwiz" -title "CD/DVD driver Wizard: HELP" "/dev/dvd and /dev/cdrom are links to the actual devices, for example, a link
  178. to /dev/hdc. These should point to the drives that you want to read from.
  179. For example, my PC has two drives, a DVD read-only drive and a CD-burner
  180. drive. I point *both* /dev/dvd and /dev/cdrom to the DVD drive, although I
  181. could have pointed /dev/cdrom to the burner drive (a DVD drive can also read
  182. CDs, so I chose it as my default for reading both CDs and DVDs).
  183.  
  184. There are various applications for reading from CD or DVD. For example, Gxine
  185. can play audio CDs and video DVDs. Most of these applications require that
  186. /dev/cdrom or /dev/dvd point to the correct devices.
  187.  
  188. Puppy has two applications for burning, TkDVD and Graveman. The latter will
  189. burn to both CD and DVDs, whereas TkDVD is for burning to DVDs only.
  190. TkDVD defaults to using /dev/dvd to tell it what drive to use, whereas
  191. Graveman will scan the hardware directly so is not dependent on the /dev/dvd
  192. and /dev/cdrom settings -- nor do you have to choose the burner drive in
  193. this Wizard as it is done from within the program.
  194.  
  195. Note that Gcombust is an older application designed for the 2.4 kernel and
  196. hence thinks in terms of SCSI-emulation, however it does still work without
  197. a SCSI-emulated burner drive. Gcombust is available as a PupGet package if
  198. not on the live-CD -- note that Gcombust used to be on the CD up until
  199. Puppy version 1.0.4, after which I replaced it with Graveman.
  200.  
  201. Note also, there is another CD/DVD burner program called Xcdroast, available
  202. via the PupGet package manager. It also auto-detects the drives.
  203.  
  204. if you want to turn on SCSI-emulation of the burner drive, run the \"old\"
  205. Wizard by executing \"cdburner-wizard-old\" from the commandline. if you do
  206. not know what SCSI-emulation is, no problem, no need to know about it.
  207. SCSI-emulation is no longer required for burning CD/DVDs in Puppy, although
  208. it does have a historical reputation of being more reliable.
  209.  
  210. Note that this Wizard stores the settings in /etc/cdromdevice, /etc/dvddevice,
  211. and /etc/cdburnerdevice."
  212. fi
  213.  
  214. if [ $XREPLY -eq 13 ];then #exit
  215.  break
  216. fi
  217. if [ $XREPLY -eq 0 ];then #exit
  218.  break
  219. fi
  220. if [ $XREPLY -eq 1 ];then #exit
  221.  break
  222. fi
  223.  
  224. done
  225. ##END##
  226.