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-old < prev    next >
Encoding:
Text File  |  2005-08-21  |  11.6 KB  |  318 lines

  1. #!/bin/sh
  2. #cd-burner wizard
  3. #Barry Kauler (c) copyright 2003,2004,2005
  4. #www.goosee.com/puppy
  5. #this script is for CD/DVD burning using SCSI-emulated IDE drive, whether
  6. #for k2.4 or k2.6.
  7.  
  8. #v1.0.5
  9. #note, no longer require scsi-emulation, but keep this old wizard, as
  10. #the main cdburner-wizard calls it.
  11.  
  12. #using Antonio Gallo's program...
  13. DRIVESFND="`probedisk 2>&1`"
  14. IDEDRVSFND="`test-eide 2>&1 | grep "cdrom"`"
  15.  
  16. #v1.0.0
  17. #if dvd drive is scsi-emul, screen out the ide name...
  18. TITLESTRGSCSI="`echo "$DRIVESFND" | grep "/dev/scd0" | cut -f 3 -d "|"`"
  19. if [ "$TITLESTRGSCSI" = "" ];then
  20.   MATCHINGIDE="zippittydoodah"
  21. else
  22.  #the ide and scsi strings are slightly different...
  23.  TITLESTRG1="`echo "$TITLESTRGSCSI" | cut -f 1 -d " "`"
  24.  TITLESTRG2="`echo "$TITLESTRGSCSI" | cut -f 2 -d " "`"
  25.  MATCHINGIDE="`echo "$DRIVESFND" | grep "$TITLESTRG1" | grep "$TITLESTRG2" | grep -v "/dev/scd0" | cut -f 1 -d "|"`"
  26.  if [ "$MATCHINGIDE" = "" ];then
  27.   MATCHINGIDE="zippittydoodah"
  28.  fi
  29. fi
  30. SELECTIONS="`echo "$DRIVESFND" | grep -i "cd" | grep -i "rom" | grep -v "$MATCHINGIDE" | cut -f 1,3 -d "|" | tr " " "_" | tr "|" " " | tr '$' "_"`"
  31. INVALIDIDE=""
  32. if [ ! "$MATCHINGIDE" = "" ];then
  33.  if [ ! "$MATCHINGIDE" = "zippittydoodah" ];then
  34.   INVALIDIDE="$MATCHINGIDE"
  35.  fi
  36. fi
  37.  
  38.  
  39. #number of physical cdrom/burner drives...
  40. NUMDRIVES=`echo "$DRIVESFND" | grep "cdrom" | wc -l | tr -d " " | tr -d "\n"`
  41. #note, if scsi-emul turned on, /dev/scd0 will also show up in this list, as well as
  42. #/dev/hdc (or whatever), but in the scd0 case, lists as "CD-ROM".
  43.  
  44. NUMIDEDRVS=`echo "$IDEDRVSFND" | grep "cdrom" | wc -l | tr -d " " | tr -d "\n"`
  45.  
  46. #one of these should have "RW" or "rw" if a burner...
  47. #( -i means ignore case)
  48. NUMBURNERS=`echo "$DRIVESFND" | grep -i "rw" | wc -l | tr -d " " | tr -d "\n"`
  49.  
  50. NUMCDROMS=`expr $NUMDRIVES - $NUMBURNERS`
  51.  
  52. #this is the on/off scsi-emulate ide switch...
  53. if [ ! -e /etc/scsiemul ];then
  54.  echo -n "off" > /etc/scsiemul
  55. fi
  56. FSCSIEMUL="`cat /etc/scsiemul`" #value is "on" or "off"
  57.  
  58. #ok, which one is the burner?...
  59. if [ "$FSCSIEMUL" = "on" ];then
  60.  BURNERDEV1="`echo "$DRIVESFND" | grep "scd0" | cut -f 1 -d "|" | head -n 1 | tr -d "\n"`"
  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. fi
  66.  
  67. #is there a cdrom drive without "rw" in it?...
  68. #( -v means if not found)
  69. CDROMDRVS="`echo "$DRIVESFND" | grep "cdrom" | grep -vi "rw" | cut -f 1 -d "|"`"
  70. #...if exists, has drive which is not a burner.
  71. if [ "$CDROMDRVS" = "" ];then
  72.  #nothing found. then, use the cd-burner...
  73.  CDROMDEV="$BURNERDEV1"
  74. else
  75.  #precaution if more than one cdrom ro drive...
  76.  CDROMDEV="`echo "$CDROMDRVS" | head -n 1 | tr -d "\n"`"
  77. fi
  78. #what is /dev/cdrom currently linked to?...
  79. CDROMLINK="`ls -l /dev/cdrom 2>/dev/null | tr -s " " | cut -f 11 -d " " | tr -d "\n"`"
  80. if [ "$CDROMLINK" ];then
  81.  CDROMDEV="$CDROMLINK" #override above search.
  82. fi
  83.  
  84.  
  85. #which one is dvd player...
  86. DVDDEV="`echo "$IDEDRVSFND" | grep -i "dvd" | cut -f 1 -d " " | head -n 1 | tr -d "\n"`"
  87. #what is /dev/dvd currently linked to?...
  88. DVDLINK="`ls -l /dev/dvd 2>/dev/null | tr -s " " | cut -f 11 -d " " | tr -d "\n"`"
  89. if [ "$DVDLINK" ];then
  90.  DVDDEV="$DVDLINK" #overrides the above.
  91. fi
  92.  
  93.  
  94. #PARTSFND="`probepart -k`"
  95. #BURNERSCSIDEV="`echo "$PARTSFND" | grep -i "rw" | grep "/dev/scd"
  96. #...a problem. /dev/scd0 won't show up until we reboot and ide-scsi.o
  97. #has grabbed the cd-burner drive as a scsi device.
  98. #for now, just use /dev/scd0 and verify in /etc/rc.d/rc.local0
  99. #when reboot.
  100.  
  101. if [ "$FSCSIEMUL" = "on" ];then
  102.  BUTTON0="SAVE_scsi_emul_off"
  103.  BUTTON1="$BUTTON0:14"
  104.  MSGSCSI="If you click the \"SAVE_scsi_emul_off\" button, /etc/modules.conf will
  105. be configured so that when Puppy reboots SCSI emulation is off."
  106. else
  107.  BUTTON0="SAVE_scsi_emul_on"
  108.  BUTTON1="$BUTTON0:12"
  109.  MSGSCSI="If you click the \"SAVE_scsi_emul_on\" button, /etc/modules.conf will be
  110. configured for the default IDE burner drive to be SCSI-emulated, so
  111. that when Puppy reboots Gcombust the CD-burner program will work."
  112. fi
  113.  
  114.  
  115. MSG0="Puppy CD/DVD drive Wizard"
  116. MSG1="Welcome to my CD and DVD drive wizard!"
  117. BGCOLOR1="#ffc0c0"
  118.  
  119. VALIDDRIVES="$SELECTIONS"
  120. if [ ! "$INVALIDIDE" = "" ];then
  121.  VALIDDRIVES="$SELECTIONS
  122. WARNING: the SCSI-emulated drive /dev/scd0 has IDE drive name
  123.          $INVALIDIDE but this must not be used."
  124. fi
  125.  
  126.  
  127. while :; do
  128.  
  129. xmessage -bg "$BGCOLOR1" -center -name "burnwiz" -title "$MSG0" -buttons \
  130.  Choose_burner:10,Choose_cdrom:11,Choose_dvd:20,$BUTTON1,HELP:15,EXIT:13 \
  131.  -file -<<FILETXT
  132. $MSG1
  133.  
  134. Puppy has probed your PC and found these CD/DVD drives:
  135. $VALIDDRIVES
  136.  
  137. Puppy thinks the default DVD drive is:    $DVDDEV
  138. Puppy thinks the default CDROM drive is:  $CDROMDEV
  139. Puppy thinks the default burner drive is: $BURNERDEV1
  140.  
  141. If you disagree with these choices, click the "Choose_burner" or
  142. "Choose_cdrom" or "Choose_dvd" to change the selection.
  143.  
  144. $MSGSCSI
  145.  
  146. CURRENT STATUS:
  147. /dev/dvd is currently linked to:   $DVDLINK.
  148. /dev/cdrom is currently linked to: $CDROMLINK.
  149. SCSI emulation of the IDE burner drive is currently switched $FSCSIEMUL.
  150.  
  151. WARNING: Clicking the "$BUTTON0" button will immediately reboot the
  152. PC, so please ensure all work is saved and all other windows are closed...
  153. FILETXT
  154.  
  155. XREPLY=$?
  156.  
  157. if [ $XREPLY -eq 10 ];then #choose-burner
  158.  BGCOLOR1="#c0e0ff"
  159.   #v1.0.0
  160.   BURNERD0="`Xdialog --wmclass "burnwiz" --title "CD/DVD drive Wizard" --stdout --menubox "Choose which is the burner drive:" 0 48 4 $SELECTIONS 2> /dev/null `"
  161.  
  162.  #BURNERD0="`gtk-shell -t "choose-burner" -l "Enter burner drive:" -q -qv "$BURNERDEV1"`"
  163.  #if [ "$BURNERD0" = "" ];then
  164.  if [ ! $? -eq 0 ];then
  165.   MSG1="YOU MADE NO CHOICE FOR BURNER DRIVE, KEEPING $BURNERDEV1"
  166.  else
  167.   MSG1="YOU JUST CHOSE $BURNERD0 AS THE BURNER DRIVE"
  168.   BURNERDEV1="$BURNERD0"
  169.  fi 
  170.  echo -n "$BURNERDEV1" | sed -e 's/\/dev\///g' > /etc/cdburnerdevice #v1.0.2
  171. fi
  172.  
  173. if [ $XREPLY -eq 11 ];then #choose cdrom
  174.  BGCOLOR1="#c0e0ff"
  175.   #v1.0.0
  176.   CDROMD0="`Xdialog --wmclass "burnwiz" --title "CD/DVD drive Wizard" --stdout --menubox "Choose which is the CDROM drive:" 0 48 4 $SELECTIONS 2> /dev/null `"
  177.  
  178.  #CDROMD0="`gtk-shell -t "choose-cdrom" -l "Enter cdrom drive (ex: /dev/hdc):" -q -qv "$CDROMDEV"`"
  179.  #if [ "$CDROMD0" = "" ];then
  180.  if [ ! $? -eq 0 ];then
  181.   MSG1="YOU MADE NO CHOICE FOR CDROM DRIVE, KEEPING $CDROMDEV"
  182.  else
  183.    MSG1="YOU JUST CHOSE $CDROMD0 AS THE CDROM DRIVE"
  184.    CDROMDEV="$CDROMD0"
  185.     CDROMLINK="$CDROMDEV"
  186.    #strip off the leading "/dev/"...
  187.    echo -n $CDROMLINK | cut -f 3 -d '/' | tr -d "\n" > /etc/cdromdevice
  188.    rm -f /dev/cdrom
  189.    ln -s $CDROMLINK /dev/cdrom
  190.  fi 
  191. fi
  192.  
  193. if [ $XREPLY -eq 20 ];then #choose dvd
  194.  BGCOLOR1="#c0e0ff"
  195.   #v1.0.0
  196.   DVDD0="`Xdialog --wmclass "burnwiz" --title "CD/DVD drive Wizard" --stdout --menubox "Choose which is the DVD drive:" 0 48 4 $SELECTIONS 2> /dev/null `"
  197.  
  198.  #DVDD0="`gtk-shell -t "choose-dvd" -l "Enter dvd drive (ex: /dev/hdc):" -q -qv "$DVDDEV"`"
  199.  #if [ "$DVDD0" = "" ];then
  200.  if [ ! $? -eq 0 ];then
  201.   MSG1="YOU MADE NO CHOICE FOR DVD DRIVE, KEEPING $DVDDEV"
  202.  else
  203.   MSG1="YOU JUST CHOSE $DVDD0 AS THE DVD DRIVE"
  204.   DVDDEV="$DVDD0"
  205.   DVDLINK="$DVDDEV"
  206.    #strip off the leading "/dev/"...
  207.    echo -n $DVDLINK | cut -f 3 -d '/' | tr -d "\n" > /etc/dvddevice
  208.    rm -f /dev/dvd
  209.    ln -s $DVDLINK /dev/dvd
  210.  fi 
  211. fi
  212.  
  213. if [ $XREPLY -eq 12 ];then #save, with scsi emulation on
  214.  if [ "$BURNERDEV1" = "" ];then
  215.   xmessage -bg "#ff8080" -center -name "burnwiz" -title "CD/DVD driver Wizard: ERROR" "You have not yet chosen a burner drive to be SCSI-emulated."
  216.  else
  217.   if [ ! "`echo "$BURNERDEV1" | grep "/dev/scd"`" = "" ];then
  218.    xmessage -bg "#ff8080" -center -name "burnwiz" -title "CD/DVD driver Wizard: ERROR" "Problem. You must select an IDE drive,
  219. not a SCSI-emulated drive. Drive $BURNERDEV1 is already SCSI-emulated."
  220.   else
  221.    echo -n "$BURNERDEV1" | sed -e 's/\/dev\///g' > /etc/cdburnerdevice #v1.0.2
  222.    echo -n "on" > /etc/scsiemul
  223.    xmessage -bg "#ffc0c0" -center -name "burnwiz" -title "CD/DVD driver Wizard: WARNING" "As you have chosen to turn on SCSI-emulation, which is now going to cause
  224. an automatic reboot, after the reboot run the CD/DVD drive Wizard again, 
  225. to check that the selections for CDROM and DVD drives are still valid."
  226.    #need to get rid of leading "/dev/"...
  227.    IGNOREDEV0="`echo -n $BURNERDEV1 | cut -f 3 -d '/' | tr -d "\n"`"
  228.    #want to link /dev/cdrom to /dev/scd0 or whatever...
  229.    #so, save it in /etc/cdromdevice and rc.local0 can read it...
  230.    rm -f /etc/cdromdevice
  231.    rm -f /etc/dvddevice
  232.    #strip off the leading "/dev/"...
  233.    if [ "$CDROMDEV" = "$BURNERDEV1" ];then
  234.     echo -n "scd0" > /etc/cdromdevice
  235.    else
  236.     echo -n $CDROMDEV | cut -f 3 -d '/' | tr -d "\n" > /etc/cdromdevice
  237.    fi
  238.    if [ "$DVDDEV" = "$BURNERDEV1" ];then
  239.     echo -n "scd0" > /etc/dvddevice
  240.    else
  241.     echo -n $DVDDEV | cut -f 3 -d '/' | tr -d "\n" > /etc/dvddevice
  242.    fi
  243.  
  244.    sync
  245.    #/etc/rc.d/rc.local0 will read /etc/cdburnerdevice and /etc/scsiemul and will append
  246.    #appropriate stuff onto end of /etc/modules.conf or /etc/modprobe.conf (used by modprobe)...
  247.    #now reboot...
  248.    exec /sbin/reboot
  249.   fi
  250.  fi
  251. fi
  252.  
  253. if [ $XREPLY -eq 14 ];then #save, with scsi emulation off
  254.  xmessage -bg "#ffc0c0" -center -name "burnwiz" -title "CD/DVD driver Wizard: WARNING" "As you have chosen to turn off SCSI-emulation, which is now going to cause
  255. an automatic reboot, after the reboot run the CD/DVD drive Wizard again, 
  256. to check that the selections for CDROM and DVD drives are still valid."
  257.  echo -n "$BURNERDEV1" | sed -e 's/\/dev\///g' > /etc/cdburnerdevice #v1.0.2
  258.  echo -n "off" > /etc/scsiemul
  259.  rm -f /etc/cdromdevice
  260.  rm -f /etc/dvddevice
  261.    if [ "$CDROMDEV" = "$BURNERDEV1" ];then
  262.     echo -n "$INVALIDIDE" | cut -f 3 -d '/' > /etc/cdromdevice
  263.    else
  264.     echo -n $CDROMDEV | cut -f 3 -d '/' | tr -d "\n" > /etc/cdromdevice
  265.    fi
  266.    if [ "$DVDDEV" = "$BURNERDEV1" ];then
  267.     echo -n "$INVALIDIDE" | cut -f 3 -d '/' > /etc/dvddevice
  268.    else
  269.     echo -n $DVDDEV | cut -f 3 -d '/' | tr -d "\n" > /etc/dvddevice
  270.    fi
  271.  
  272.  #now restore /etc/modules.conf, without scsi-emul...
  273.  sync
  274.  #/etc/rc.d/rc.local0 will read /etc/cdburnerdevice and /etc/scsiemul and will append
  275.  #appropriate stuff onto end of /etc/modules.conf or /etc/modprobe.conf (used by modprobe),
  276.  #if scsi-emul is turned on, not if scsi-emul turned off...
  277.  #now reboot...
  278.  exec /sbin/reboot
  279. fi
  280.  
  281. if [ $XREPLY -eq 15 ];then #help
  282.  xmessage -bg "purple" -center -name "burnwiz" -title "CD/DVD driver Wizard: HELP" "Puppy is currently only designed to SCSI-emulate one IDE drive, so if you have
  283. two burner-drives, chose just one to burn from. Probably if one of them burns
  284. to both CD and DVD that would be the one to choose.
  285.  
  286. /dev/dvd and /dev/cdrom are links to the actual devices, for example, a link
  287. to /dev/hdc. These should point to the drives that you want to read from.
  288. For example, my PC has two drives, a DVD read-only drive and a CD-burner
  289. drive. I point *both* /dev/dvd and /dev/cdrom to the DVD drive, although I
  290. could have pointed /dev/cdrom to the burner drive.
  291.  
  292. If you have an IDE drive, say /dev/hdc, and you turn on SCSI-emulation for it,
  293. it then becomes /dev/scd0. Although the /dev/hdc device still exists, you
  294. should *not* use it as it won't work properly.
  295.  
  296. Puppy has two applications for burning, TkDVD and Gcombust. The latter will
  297. burn to both CD and DVDs, whereas TkDVD is for burning to DVDs only.
  298. You need to be sure that the IDE drive you want to burn to is SCSI-emulated
  299. and that the burner application can find it.
  300.  
  301. Technical note: IDE drives are the internal CD/DVD/hard drives in most PCs.
  302. A few rare PCs may have an actual real SCSI drive.
  303. USB CD/DVD drives are currently not supported by the Puppy scripts."
  304. fi
  305.  
  306. if [ $XREPLY -eq 13 ];then #exit
  307.  break
  308. fi
  309. if [ $XREPLY -eq 0 ];then #exit
  310.  break
  311. fi
  312. if [ $XREPLY -eq 1 ];then #exit
  313.  break
  314. fi
  315.  
  316. done
  317. ##END##
  318.