Metropoli BBS
VIEWER: cdset MODE: TEXT (ASCII)
#!/bin/sh

if mount | grep -F iso9660 1> /dev/null 2> /dev/null ; then # CD is mounted
  DEVICE=`mount | fgrep iso9660 | cut -d ' ' -f 1`
  ( cd /dev ; ln -sf $DEVICE cdrom )
  echo "Cdrom is mounted, there's a link in: /dev/cdrom -> $DEVICE"
  echo "If you want to change the link, do this first. ~# umount /dev/cdrom"
  exit
fi
dialog --title "CONFIGURE CD-ROM?" --yesno "\n    Do you have a CD-ROM?" 7 35
if [ $? = 1 -o $? = 255 ]; then
 echo 
 exit
fi
dialog --title "Configuring CD-ROM link (/dev/cdrom)" \
--menu "\nWhat type of CD-ROM drive do you have?" 15 66 7 \
"1" "SCSI (/dev/scd0 or /dev/scd1)" \
"2" "Sony CDU31A (/dev/sonycd)" \
"3" "Sony 531/535 (/dev/cdu535)" \
"4" "Mitsumi (/dev/mcd)" \
"5" "Sound Blaster Pro/Panasonic (/dev/sbpcd)" \
"6" "Aztech/Orchid/Okano/Wearnes with interface card" \
"7" "Most IDE-interface CD drives" 2> /tmp/cdtype
if [ $? = 1 -o $? = 255 ]; then
 rm -f /tmp/cdtype
 echo
 exit
fi
CD_ROM_TYPE="`cat /tmp/cdtype`"
rm -f /tmp/cdtype
if [ "$CD_ROM_TYPE" = "1" ]; then
 dialog --title "SELECT SCSI DEVICE" --menu "Which SCSI CD-ROM are you \
using? (If you're not sure, select /dev/scd0)" 10 60 2 \
"/dev/scd0" "SCSI CD 0" \
"/dev/scd1" "SCSI CD 1" 2> /tmp/whichscsi
 if [ $? = 1 -o $? = 255 ]; then
  rm -f /tmp/tmpmsg /tmp/cdtype /tmp/whichscsi
  echo  
  exit
 fi
 CD_DEVICE="`cat /tmp/whichscsi`"
 rm -f /tmp/whichscsi
elif [ "$CD_ROM_TYPE" = "2" ]; then
 CD_DEVICE="/dev/sonycd"
elif [ "$CD_ROM_TYPE" = "3" ]; then
 CD_DEVICE="/dev/cdu535"
elif [ "$CD_ROM_TYPE" = "4" ]; then
 CD_DEVICE="/dev/mcd"
elif [ "$CD_ROM_TYPE" = "5" ]; then
 CD_DEVICE="/dev/sbpcd"
elif [ "$CD_ROM_TYPE" = "6" ]; then
 CD_DEVICE="/dev/aztcd"
elif [ "$CD_ROM_TYPE" = "7" ]; then
  dialog --title "SELECT IDE DEVICE" --menu \
"Which IDE device is your CD-ROM drive connected to? \
Devices hda and hdb are the possible drives on the \
primary IDE interface, and hdc and hdd are the drives \
on the secondary IDE interface. If you're not sure, we can try to \
scan for your drive." \
15 70 5 \
"scan" "Try to scan for your drive" \
"/dev/hda" "Primary IDE drive 1 (unlikely)" \
"/dev/hdb" "Primary IDE drive 2 (common)" \
"/dev/hdc" "Secondary IDE drive 1 (common)" \
"/dev/hdd" "Secondary IDE drive 2" 2> /tmp/idecd
 if [ ! "`cat /tmp/idecd`" = "scan" ]; then
 CD_DEVICE="`cat /tmp/idecd`"
 else
   mkdir -p /tmp/cdrom
   for device in /dev/hdb /dev/hdc /dev/hdd /dev/hda ; do
   dialog --infobox "Scanning $device ..." 3 30
   mount -o ro -t iso9660 $device /tmp/cdrom 1> /dev/null 2> /dev/null
   if [ $? = 0 ]; then
    DRIVE_FOUND=$device
    break
   fi
  done
  if [ "$DRIVE_FOUND" = "" ]; then
   dialog --title "DRIVE NOT FOUND" --msgbox \
"An IDE CD-ROM drive could not be found on any of the devices that \
were scanned." 6 55
  else
   dialog --title "IDE CD-ROM DRIVE DETECTED SUCCESSFULLY" --msgbox \
"An IDE CD-ROM drive was found on device $DRIVE_FOUND." 5 65
   CD_DEVICE="$DRIVE_FOUND"
  fi
 fi
fi
if [ ! "$CD_DEVICE" = "" ]; then
( cd /dev ; ln -sf $CD_DEVICE cdrom )
fi
umount /tmp/cdrom 2>/dev/null
rm -rf /tmp/cdrom
rm -f /tmp/idecd
echo
[ RETURN TO DIRECTORY ]