home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # FIXME: UDF fs support?
- RDIR=/dev/tty4
- NDIR=/dev/null
- TMP=/var/log/setup/tmp
- export TEXTDOMAIN=INSCD
- if [ ! -d $TMP ]; then
- mkdir -p $TMP
- fi
- T_PX="`cat $TMP/SeTT_PX`"
- rm -f $TMP/SeTmount $TMP/SeTDS $TMP/SeTCDdev $TMP/reply
-
- dialog --title "`gettext "SCANNING FOR CD or DVD DRIVE"`" --no-cancel --menu \
- "`gettext "Make sure the KateOS disc is in your CD/DVD drive, \
- and then press ENTER to begin the scanning process. \
- Or, if you'd rather specify the device name manually \
- (experts only), choose that option below."`" \
- 11 72 2 \
- "`gettext "auto"`" "`gettext "Scan for the CD or DVD drive (recommended)"`" \
- "`gettext "manual"`" "`gettext "Manually specify CD or DVD by device name"`" \
- 2> $TMP/reply
-
- if [ ! "`cat $TMP/reply`" = "`gettext "manual"`" ]; then
- if [ ! "`cat $TMP/reply`" = "`gettext "auto"`" ]; then
- # cancel or esc
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
- exit
- fi
- fi
-
- if [ "`cat $TMP/reply`" = "`gettext "manual"`" ]; then
- dialog --title "`gettext "MANUAL CD/DVD DEVICE SELECTION"`" --menu \
- "`gettext "Please select your CD/DVD device from the list below. \
- If you don't see your device listed, choose 'custom'. \
- This will let you type in any device name. (and if necessary, \
- will create the device)"`" \
- 18 70 9 \
- "`gettext "custom"`" "`gettext "Type in the CD or DVD device to use"`" \
- "/dev/hdb" "`gettext "CD/DVD slave on first IDE bus"`" \
- "/dev/hda" "`gettext "CD/DVD master on first IDE bus (unlikely)"`" \
- "/dev/hdc" "`gettext "CD/DVD master on second IDE bus"`" \
- "/dev/hdd" "`gettext "CD/DVD slave on second IDE bus"`" \
- "/dev/hde" "`gettext "CD/DVD master on third IDE bus"`" \
- "/dev/hdf" "`gettext "CD/DVD slave on third IDE bus"`" \
- "/dev/hdg" "`gettext "CD/DVD master on fourth IDE bus"`" \
- "/dev/hdh" "`gettext "CD/DVD slave on fourth IDE bus"`" \
- "/dev/sr0" "`gettext "First SCSI CD/DVD drive"`" \
- "/dev/sr1" "`gettext "Second SCSI CD/DVD drive"`" \
- "/dev/sr2" "`gettext "Third SCSI CD/DVD drive"`" \
- "/dev/sr3" "`gettext "Fourth SCSI CD/DVD drive"`" \
- "/dev/pcd0" "`gettext "First parallel port ATAPI CD"`" \
- "/dev/pcd1" "`gettext "Second parallel port ATAPI CD"`" \
- "/dev/pcd2" "`gettext "Third parallel port ATAPI CD"`" \
- "/dev/pcd3" "`gettext "Fourth parallel port ATAPI CD"`" \
- "/dev/aztcd" "`gettext "Non-IDE Aztech CD/DVD"`" \
- "/dev/cdu535" "`gettext "Sony CDU-535 CD/DVD"`" \
- "/dev/gscd" "`gettext "Non-IDE GoldStar CD/DVD"`" \
- "/dev/sonycd" "`gettext "Sony CDU-31a CD/DVD"`" \
- "/dev/optcd" "`gettext "Optics Storage CD/DVD"`" \
- "/dev/sjcd" "`gettext "Sanyo non-IDE CD/DVD"`" \
- "/dev/mcdx0" "`gettext "Non-IDE Mitsumi drive 1"`" \
- "/dev/mcdx1" "`gettext "Non-IDE Mitsumi drive 2"`" \
- "/dev/sbpcd" "`gettext "Old non-IDE SoundBlaster CD/DVD"`" \
- "/dev/cm205cd" "`gettext "Philips LMS CM-205 CD/DVD"`" \
- "/dev/cm206cd" "`gettext "Philips LMS CM-206 CD/DVD"`" \
- "/dev/mcd" "`gettext "Old non-IDE Mitsumi CD/DVD"`" \
- 2> $TMP/reply
- if [ ! -r $TMP/reply ]; then
- # cancel or esc
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
- exit
- fi
- REPLY="`cat $TMP/reply`"
- if [ "$REPLY" = "`gettext "custom"`" ]; then
- dialog --title "`gettext "ENTER CD/DVD DEVICE MANUALLY"`" --inputbox \
- "`gettext "Please enter the name of the CD/DVD device (such as /dev/hdc) that \
- you wish to use to mount the KateOS CD/DVD:"`" \
- 9 70 2> $TMP/reply
- if [ ! -r $TMP/reply ]; then
- # cancel or esc
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
- exit
- fi
- DRIVE_FOUND="`cat $TMP/reply`"
- if [ ! -r $DRIVE_FOUND ]; then # no such device
- rm -f $TMP/majorminor
- dialog --title "`gettext "MKNOD CD/DVD DEVICE"`" --inputbox \
- "`gettext "There doesn't seem to be a device by the name of"` $DRIVE_FOUND `gettext "in the \
- /dev directory, so we will have to create it using the major and minor \
- numbers for the device. If you're using a bootdisk with a custom CD/DVD \
- driver on it, you should be able to find these numbers in the \
- documentation. Also, see the 'devices.txt' file that comes with the \
- Linux kernel source. If you don't know the numbers, you'll have to hit \
- Esc to abort. Enter the major and minor numbers for the new device, \
- separated by one space:"`" \
- 15 72 2> $TMP/majorminor
- if [ ! -r $TMP/majorminor ]; then
- # cancel or esc
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
- exit
- fi
- MAJOR="`cat $TMP/majorminor`"
- dialog --title "`gettext "MAKING DEVICE IN /dev"`" --infobox \
- "mknod $DRIVE_FOUND b $MAJOR" 3 40
- mknod $DRIVE_FOUND b $MAJOR 2> $RDIR
- sleep 3
- if [ ! -r $DRIVE_FOUND ]; then
- dialog --title "`gettext "MKNOD FAILED"`" --msgbox \
- "`gettext "Sorry, but the mknod command failed to make the device. You'll need to \
- go back and try selecting your source media again. Press ENTER to abort \
- the source media selection process."`" 8 60
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
- exit
- fi
- fi
- else
- DRIVE_FOUND=$REPLY
- fi
- fi
-
- # Search the IDE interfaces:
- if [ "$DRIVE_FOUND" = "" ]; then
-
- dialog --title "`gettext "SCANNING"`" --infobox "`gettext "Scanning for an IDE \
- CD/DVD drive containing a KateOS disc..."`" 4 56
- sleep 3
- for device in \
- /dev/hdd /dev/hdc /dev/hdb /dev/hda \
- /dev/hde /dev/hdf /dev/hdg /dev/hdh \
- /dev/hdi /dev/hdj /dev/hdk /dev/hdl \
- /dev/hdm /dev/hdn /dev/hdo /dev/hdp \
- ; do
- mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
- if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
- if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
- DRIVE_FOUND=$device
- umount /var/log/mount
- break
- fi
- fi
- done
- fi
-
- # Search for SCSI CD/DVD drives:
- if [ "$DRIVE_FOUND" = "" ]; then
- dialog --title "`gettext "SCANNING"`" --infobox "`gettext "Scanning for a SCSI \
- CD/DVD drive containing a KateOS disc..."`" 4 50
- sleep 3
- for device in \
- /dev/sr0 /dev/sr1 /dev/sr2 /dev/sr3 \
- ; do
- mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
- if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
- if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
- DRIVE_FOUND=$device
- umount /var/log/mount
- break
- fi
- fi
- done
- fi
-
- # Search for parallel port ATAPI CD/DVD drives:
- if [ "$DRIVE_FOUND" = "" ]; then
- dialog --title "`gettext "SCANNING"`" --infobox "`gettext "Scanning for a parallel port \
- ATAPI CD/DVD drive containing a KateOS disc..."`" 4 52
- sleep 3
- for device in \
- /dev/pcd0 /dev/pcd1 /dev/pcd2 /dev/pcd3 \
- ; do
- mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
- if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
- if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
- DRIVE_FOUND=$device
- umount /var/log/mount
- break
- fi
- fi
- done
- fi
-
- # Still not found? OK, we will search for CD/DVD drives on old, pre-ATAPI
- # proprietary interfaces. There aren't too many of these still around, and
- # the scan won't actually work unless a bootdisk that supports the drive is
- # used, and any necessary parameters have been passed to the kernel.
- if [ "$DRIVE_FOUND" = "" ]; then
- dialog --title "`gettext "SCANNING"`" --msgbox "`gettext "No IDE/SCSI drive, so we will try \
- scanning for CD drives on \
- old proprietary interfaces, such as SoundBlaster pre-IDE CD drives, \
- Sony CDU-31a, Sony 535, old Mitsumi pre-IDE, old Optics, etc. Please press \
- ENTER to begin this last-chance scan for old, obsolete hardware."`" 11 60
- for device in \
- /dev/sonycd /dev/gscd /dev/optcd /dev/sjcd /dev/mcdx0 /dev/mcdx1 \
- /dev/cdu535 /dev/sbpcd /dev/aztcd /dev/cm205cd /dev/cm206cd \
- /dev/bpcd /dev/mcd \
- ; do
- mount -o ro -t iso9660 $device /var/log/mount 1> $RDIR 2> $RDIR
- if [ $? = 0 ] && [ -d /var/log/mount/kate ] ; then
- if [ -f /var/log/mount/cd1 ] || [ -f /var/log/mount/dvd ] || [ -f /var/log/mount/miniiso ] ; then
- DRIVE_FOUND=$device
- umount /var/log/mount
- break
- fi
- fi
- done
- fi
-
- if [ "$DRIVE_FOUND" = "" ]; then
- dialog --title "`gettext "CD/DVD DRIVE NOT FOUND"`" --msgbox \
- "`gettext -e "A CD/DVD drive could not be found on any of the devices that were \
- scanned. Possible reasons include failing to pass parameters needed by some \
- drives to the kernel, not having the KateOS disc in your CD/DVD \
- drive, or using a drive connected to a Plug and Play soundcard (in this \
- case, connecting the drive directly to the IDE interface often helps). \
- \n\
- You will now be returned to the main menu. If you want to try looking \
- for the CD again, you may skip directly to the SOURCE menu selection."`" \
- 0 0
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
- exit
- fi
-
- while [ 0 ]; do # time to try to mount the CD/DVD device:
- mount -o ro -t iso9660 $DRIVE_FOUND /var/log/mount 1> $RDIR 2> $RDIR
- if [ $? = 0 ]; then # mounted successfully
- dialog --title "`gettext "CD/DVD DRIVE FOUND"`" --sleep 3 --infobox \
- "`gettext "A KateOS disc was found in device"` $DRIVE_FOUND." 4 50
- break
- else # failed to mount
- dialog --title "`gettext "MOUNT ERROR"`" --menu "`gettext "There was an error \
- attempting to mount the CD/DVD on"` $DRIVE_FOUND. \
- `gettext "Maybe the device name is incorrect, the disc is not in the drive. \
- What would you like to do now?"`" \
- 13 70 3 \
- "1" "`gettext "Abort CD installation"`" \
- "2" "`gettext "Attempt to mount the CD/DVD device again"`" \
- "3" "`gettext "Ignore the error and continue"`" 2> $TMP/errordo
- if [ ! $? = 0 ]; then
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev $TMP/errordo
- exit;
- fi
- DOWHAT="`cat $TMP/errordo`"
- rm -f $TMP/errordo
- if [ $DOWHAT = 1 ]; then
- rm -f $TMP/SeTDS $TMP/SeTmount $TMP/SeTCDdev
- exit
- elif [ $DOWHAT = 2 ]; then
- dialog --title "`gettext "ATTEMPTING TO MOUNT CD/DVD on"` $DRIVE_FOUND" \
- --infobox "`gettext "Attempting to mount your CD/DVD again with the \
- following command:"` mount -o ro -t iso9660 $DRIVE_FOUND \
- /var/log/mount" 4 69
- umount /var/log/mount 1> $NDIR 2> $NDIR
- sleep 5
- elif [ $DOWHAT = 3 ]; then
- # Ignore error, really bad plan but whatever
- break
- fi
- fi
- done
- # since we should have mounted successfully, let's refresh
- # the link for /dev/cdrom on the target partition:
- if [ ! -d $T_PX/dev ]; then
- mkdir $T_PX/dev
- chown root.root $T_PX/dev
- chmod 755 $T_PX/dev
- fi
- ( cd $T_PX/dev ; ln -sf $DRIVE_FOUND cdrom )
-
- # Pass information about the source directory to the next install stage:
- echo "/var/log/mount/kate/" > $TMP/SeTDS
- echo "/var/log/mount/kate/model" > $TMP/SeTmodel
- echo "-source_mounted" > $TMP/SeTmount
- echo "$DRIVE_FOUND" > $TMP/SeTCDdev
- echo "/dev/null" > $TMP/SeTsource
-