home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 October / Enter 10 2006.iso / boot / isolinux / initrd / in / usr / lib / setup / INSCD < prev    next >
Encoding:
Text File  |  2006-07-31  |  10.4 KB  |  275 lines

  1. #!/bin/sh
  2. # FIXME: UDF fs support?
  3. RDIR=/dev/tty4
  4. NDIR=/dev/null
  5. TMP=/var/log/setup/tmp
  6. export TEXTDOMAIN=INSCD
  7. if [ ! -d $TMP ]; then
  8.   mkdir -p $TMP
  9. fi
  10. T_PX="`cat $TMP/SeTT_PX`"
  11. rm -f $TMP/SeTmount $TMP/SeTDS $TMP/SeTCDdev $TMP/reply
  12.  
  13. dialog --title "`gettext "SCANNING FOR CD or DVD DRIVE"`" --no-cancel --menu \
  14. "`gettext "Make sure the KateOS disc is in your CD/DVD drive, \
  15. and then press ENTER to begin the scanning process. \
  16. Or, if you'd rather specify the device name manually \
  17. (experts only), choose that option below."`" \
  18. 11 72 2 \
  19. "`gettext "auto"`" "`gettext "Scan for the CD or DVD drive (recommended)"`" \
  20. "`gettext "manual"`" "`gettext "Manually specify CD or DVD by device name"`" \
  21. 2> $TMP/reply
  22.  
  23. if [ ! "`cat $TMP/reply`" = "`gettext "manual"`" ]; then
  24.     if [ ! "`cat $TMP/reply`" = "`gettext "auto"`" ]; then
  25.      # cancel or esc
  26.     rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
  27.     exit
  28.     fi
  29. fi
  30.  
  31. if [ "`cat $TMP/reply`" = "`gettext "manual"`" ]; then
  32.  dialog --title "`gettext "MANUAL CD/DVD DEVICE SELECTION"`" --menu \
  33.  "`gettext "Please select your CD/DVD device from the list below.  \
  34. If you don't see your device listed, choose 'custom'.  \
  35. This will let you type in any device name. (and if necessary, \
  36. will create the device)"`" \
  37.  18 70 9 \
  38.  "`gettext "custom"`" "`gettext "Type in the CD or DVD device to use"`" \
  39.  "/dev/hdb" "`gettext "CD/DVD slave on first IDE bus"`" \
  40.  "/dev/hda" "`gettext "CD/DVD master on first IDE bus (unlikely)"`" \
  41.  "/dev/hdc" "`gettext "CD/DVD master on second IDE bus"`" \
  42.  "/dev/hdd" "`gettext "CD/DVD slave on second IDE bus"`" \
  43.  "/dev/hde" "`gettext "CD/DVD master on third IDE bus"`" \
  44.  "/dev/hdf" "`gettext "CD/DVD slave on third IDE bus"`" \
  45.  "/dev/hdg" "`gettext "CD/DVD master on fourth IDE bus"`" \
  46.  "/dev/hdh" "`gettext "CD/DVD slave on fourth IDE bus"`" \
  47.  "/dev/sr0" "`gettext "First SCSI CD/DVD drive"`" \
  48.  "/dev/sr1" "`gettext "Second SCSI CD/DVD drive"`" \
  49.  "/dev/sr2" "`gettext "Third SCSI CD/DVD drive"`" \
  50.  "/dev/sr3" "`gettext "Fourth SCSI CD/DVD drive"`" \
  51.  "/dev/pcd0" "`gettext "First parallel port ATAPI CD"`" \
  52.  "/dev/pcd1" "`gettext "Second parallel port ATAPI CD"`" \
  53.  "/dev/pcd2" "`gettext "Third parallel port ATAPI CD"`" \
  54.  "/dev/pcd3" "`gettext "Fourth parallel port ATAPI CD"`" \
  55.  "/dev/aztcd" "`gettext "Non-IDE Aztech CD/DVD"`" \
  56.  "/dev/cdu535" "`gettext "Sony CDU-535 CD/DVD"`" \
  57.  "/dev/gscd" "`gettext "Non-IDE GoldStar CD/DVD"`" \
  58.  "/dev/sonycd" "`gettext "Sony CDU-31a CD/DVD"`" \
  59.  "/dev/optcd" "`gettext "Optics Storage CD/DVD"`" \
  60.  "/dev/sjcd" "`gettext "Sanyo non-IDE CD/DVD"`" \
  61.  "/dev/mcdx0" "`gettext "Non-IDE Mitsumi drive 1"`" \
  62.  "/dev/mcdx1" "`gettext "Non-IDE Mitsumi drive 2"`" \
  63.  "/dev/sbpcd" "`gettext "Old non-IDE SoundBlaster CD/DVD"`" \
  64.  "/dev/cm205cd" "`gettext "Philips LMS CM-205 CD/DVD"`" \
  65.  "/dev/cm206cd" "`gettext "Philips LMS CM-206 CD/DVD"`" \
  66.  "/dev/mcd" "`gettext "Old non-IDE Mitsumi CD/DVD"`" \
  67.  2> $TMP/reply
  68.  if [ ! -r $TMP/reply ]; then
  69.   # cancel or esc
  70.   rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
  71.   exit
  72.  fi
  73.  REPLY="`cat $TMP/reply`"
  74.  if [ "$REPLY" = "`gettext "custom"`" ]; then
  75.   dialog --title "`gettext "ENTER CD/DVD DEVICE MANUALLY"`" --inputbox \
  76. "`gettext "Please enter the name of the CD/DVD device (such as /dev/hdc) that \
  77. you wish to use to mount the KateOS CD/DVD:"`" \
  78. 9 70 2> $TMP/reply
  79.   if [ ! -r $TMP/reply ]; then
  80.    # cancel or esc
  81.    rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
  82.    exit
  83.   fi
  84.   DRIVE_FOUND="`cat $TMP/reply`"
  85.   if [ ! -r $DRIVE_FOUND ]; then # no such device
  86.    rm -f $TMP/majorminor
  87.    dialog --title "`gettext "MKNOD CD/DVD DEVICE"`" --inputbox \
  88.    "`gettext "There doesn't seem to be a device by the name of"` $DRIVE_FOUND `gettext "in the \
  89. /dev directory, so we will have to create it using the major and minor \
  90. numbers for the device.  If you're using a bootdisk with a custom CD/DVD \
  91. driver on it, you should be able to find these numbers in the \
  92. documentation.  Also, see the 'devices.txt' file that comes with the \
  93. Linux kernel source.  If you don't know the numbers, you'll have to hit \
  94. Esc to abort. Enter the major and minor numbers for the new device, \
  95. separated by one space:"`" \
  96.    15 72 2> $TMP/majorminor
  97.    if [ ! -r $TMP/majorminor ]; then
  98.     # cancel or esc
  99.     rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
  100.     exit
  101.    fi
  102.    MAJOR="`cat $TMP/majorminor`"
  103.    dialog --title "`gettext "MAKING DEVICE IN /dev"`" --infobox \
  104.    "mknod $DRIVE_FOUND b $MAJOR" 3 40
  105.    mknod $DRIVE_FOUND b $MAJOR 2> $RDIR
  106.    sleep 3
  107.    if [ ! -r $DRIVE_FOUND ]; then
  108.     dialog --title "`gettext "MKNOD FAILED"`" --msgbox \
  109.     "`gettext "Sorry, but the mknod command failed to make the device.  You'll need to \
  110. go back and try selecting your source media again.  Press ENTER to abort \
  111. the source media selection process."`" 8 60
  112.     rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
  113.     exit
  114.    fi
  115.   fi
  116.  else
  117.   DRIVE_FOUND=$REPLY
  118.  fi
  119. fi
  120.  
  121. # Search the IDE interfaces:
  122. if [ "$DRIVE_FOUND" = "" ]; then
  123.  
  124.  dialog --title "`gettext "SCANNING"`" --infobox "`gettext "Scanning for an IDE \
  125. CD/DVD drive containing a KateOS disc..."`" 4 56
  126.  sleep 3
  127.  for device in \
  128.   /dev/hdd /dev/hdc /dev/hdb /dev/hda \
  129.   /dev/hde /dev/hdf /dev/hdg /dev/hdh \
  130.   /dev/hdi /dev/hdj /dev/hdk /dev/hdl \
  131.   /dev/hdm /dev/hdn /dev/hdo /dev/hdp \
  132.   ; do
  133.   mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
  134.   if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
  135.    if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
  136.    DRIVE_FOUND=$device
  137.    umount /var/log/mount
  138.    break
  139.    fi
  140.   fi
  141.  done
  142. fi
  143.  
  144. # Search for SCSI CD/DVD drives:
  145. if [ "$DRIVE_FOUND" = "" ]; then
  146.  dialog --title "`gettext "SCANNING"`" --infobox "`gettext "Scanning for a SCSI \
  147. CD/DVD drive containing a KateOS disc..."`" 4 50
  148.  sleep 3
  149.  for device in \
  150.   /dev/sr0 /dev/sr1 /dev/sr2 /dev/sr3 \
  151.   ; do
  152.   mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
  153.   if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
  154.    if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
  155.    DRIVE_FOUND=$device
  156.    umount /var/log/mount
  157.    break
  158.    fi
  159.   fi
  160.  done
  161. fi
  162.  
  163. # Search for parallel port ATAPI CD/DVD drives:
  164. if [ "$DRIVE_FOUND" = "" ]; then
  165.  dialog --title "`gettext "SCANNING"`" --infobox "`gettext "Scanning for a parallel port \
  166. ATAPI CD/DVD drive containing a KateOS disc..."`" 4 52
  167.  sleep 3
  168.  for device in \
  169.   /dev/pcd0 /dev/pcd1 /dev/pcd2 /dev/pcd3 \
  170.   ; do
  171.   mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
  172.   if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
  173.    if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
  174.    DRIVE_FOUND=$device
  175.    umount /var/log/mount
  176.    break
  177.    fi
  178.   fi
  179.  done
  180. fi
  181.  
  182. # Still not found?  OK, we will search for CD/DVD drives on old, pre-ATAPI
  183. # proprietary interfaces.  There aren't too many of these still around, and
  184. # the scan won't actually work unless a bootdisk that supports the drive is
  185. # used, and any necessary parameters have been passed to the kernel.
  186. if [ "$DRIVE_FOUND" = "" ]; then
  187.  dialog --title "`gettext "SCANNING"`" --msgbox "`gettext "No IDE/SCSI drive, so we will try \
  188. scanning for CD drives on \
  189. old proprietary interfaces, such as SoundBlaster pre-IDE CD drives, \
  190. Sony CDU-31a, Sony 535, old Mitsumi pre-IDE, old Optics, etc. Please press \
  191. ENTER to begin this last-chance scan for old, obsolete hardware."`" 11 60
  192.  for device in \
  193.   /dev/sonycd /dev/gscd /dev/optcd /dev/sjcd /dev/mcdx0 /dev/mcdx1 \
  194.   /dev/cdu535 /dev/sbpcd /dev/aztcd /dev/cm205cd /dev/cm206cd \
  195.   /dev/bpcd /dev/mcd \
  196.   ; do
  197.   mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
  198.   if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
  199.    if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
  200.    DRIVE_FOUND=$device
  201.    umount /var/log/mount
  202.    break
  203.    fi
  204.   fi
  205.  done
  206. fi
  207.  
  208. if [ "$DRIVE_FOUND" = "" ]; then
  209.  dialog --title "`gettext "CD/DVD DRIVE NOT FOUND"`" --msgbox \
  210.  "`gettext -e "A CD/DVD drive could not be found on any of the devices that were \
  211. scanned.  Possible reasons include failing to pass parameters needed by some \
  212. drives to the kernel, not having the KateOS disc in your CD/DVD \
  213. drive, or using a drive connected to a Plug and Play soundcard (in this \
  214. case, connecting the drive directly to the IDE interface often helps). \
  215. \n\
  216. You will now be returned to the main menu.  If you want to try looking \
  217. for the CD again, you may skip directly to the SOURCE menu selection."`" \
  218.  0 0
  219.  rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
  220.  exit
  221. fi
  222.  
  223. while [ 0 ]; do # time to try to mount the CD/DVD device:
  224.  mount -o ro -t iso9660 $DRIVE_FOUND /var/log/mount 1> $RDIR 2> $RDIR
  225.  if [ $? = 0 ]; then # mounted successfully
  226.   dialog --title "`gettext "CD/DVD DRIVE FOUND"`" --sleep 3 --infobox \
  227.   "`gettext "A KateOS disc was found in device"` $DRIVE_FOUND." 4 50
  228.   break
  229.  else # failed to mount
  230.   dialog --title "`gettext "MOUNT ERROR"`" --menu "`gettext "There was an error \
  231. attempting to mount the CD/DVD on"` $DRIVE_FOUND.  \
  232. `gettext "Maybe the device name is incorrect, the disc is not in the drive. \
  233. What would you like to do now?"`" \
  234.   13 70 3 \
  235.   "1" "`gettext "Abort CD installation"`" \
  236.   "2" "`gettext "Attempt to mount the CD/DVD device again"`" \
  237.   "3" "`gettext "Ignore the error and continue"`" 2> $TMP/errordo
  238.   if [ ! $? = 0 ]; then
  239.    rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
  240.    exit;
  241.   fi
  242.   DOWHAT="`cat $TMP/errordo`"
  243.   rm -f $TMP/errordo
  244.   if [ $DOWHAT = 1 ]; then
  245.    rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev
  246.    exit
  247.   elif [ $DOWHAT = 2 ]; then
  248.    dialog --title "`gettext "ATTEMPTING TO MOUNT CD/DVD on"` $DRIVE_FOUND" \
  249.    --infobox "`gettext "Attempting to mount your CD/DVD again with the \
  250. following command:"` mount -o ro -t iso9660 $DRIVE_FOUND \
  251. /var/log/mount" 4 69 
  252.    umount /var/log/mount 1> $NDIR 2> $NDIR
  253.    sleep 5
  254.   elif [ $DOWHAT = 3 ]; then
  255.    # Ignore error, really bad plan but whatever
  256.    break
  257.   fi
  258.  fi
  259. done
  260. # since we should have mounted successfully, let's refresh 
  261. # the link for /dev/cdrom on the target partition:
  262. if [ ! -d $T_PX/dev ]; then
  263.  mkdir $T_PX/dev
  264.  chown root.root $T_PX/dev
  265.  chmod 755 $T_PX/dev
  266. fi
  267. ( cd $T_PX/dev ; ln -sf $DRIVE_FOUND cdrom )
  268.  
  269. # Pass information about the source directory to the next install stage:
  270. echo "/var/log/mount/kate/" > $TMP/SeTDS
  271. echo "/var/log/mount/kate/model" > $TMP/SeTmodel
  272. echo "-source_mounted" > $TMP/SeTmount
  273. echo "$DRIVE_FOUND" > $TMP/SeTCDdev
  274. echo "/dev/null" > $TMP/SeTsource
  275.