[1] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | TryToFindCDROM() {
|
---|
| 5 | # hda1 is there for testing
|
---|
[1758] | 6 | LogIt "find-and-mount-cdrom --- starting"
|
---|
| 7 | for device in /dev/hd? /dev/scd? /dev/rcd? /dev/sr? /dev/cd? /dev/ide/*/*/*/*/cd /dev/scsi/*/*/*/*/cd; do
|
---|
| 8 | [ ! "$SECOND_TRY" ] && LogIt "Trying $device"
|
---|
[2591] | 9 | if [ -f $MINDI_CACHE/mondorestore.cfg ] && [ "`grep "using-cdstream yes" $MINDI_CACHE/mondorestore.cfg 2> /dev/null`" ]; then
|
---|
[1758] | 10 | pwd=`pwd`
|
---|
| 11 | cd $GROOVY
|
---|
| 12 | tar -zxf $device 2> /tmp/mount.log
|
---|
| 13 | res=$?
|
---|
| 14 | cd $pwd
|
---|
| 15 | if [ "$res" -eq "0" ] ; then
|
---|
| 16 | LogIt "Using cdstream as extended datadisk ($device). Good." 3
|
---|
| 17 | echo "Using cdstrea as extd dsk." > /tmp/TAPEDEV-HAS-DATA-DISKS
|
---|
| 18 | ln -sf $device /dev/cdrom
|
---|
| 19 | exit 0
|
---|
| 20 | fi
|
---|
| 21 | else
|
---|
| 22 | mount $device -t iso9660 -o ro /mnt/cdrom 2> /tmp/mount.log
|
---|
| 23 | res=$?
|
---|
| 24 | fi
|
---|
[1888] | 25 | if [ "$res" -ne "0" ] ; then
|
---|
| 26 | res=`cat /tmp/mount.log`
|
---|
| 27 | if [ "$res" = "mount: No medium found" ] ; then
|
---|
| 28 | [ ! "$SECOND_TRY" ] && LogIt "There is a CD-ROM drive at $device but no CD in it."
|
---|
| 29 | else
|
---|
| 30 | [ ! "$SECOND_TRY" ] && LogIt "It's not in $device; I'll keep looking"
|
---|
| 31 | fi
|
---|
| 32 | continue
|
---|
[1758] | 33 | fi
|
---|
[1888] | 34 | LogIt "$device has a CD-ROM in it"
|
---|
| 35 | umount /mnt/cdrom
|
---|
| 36 | ln -sf $device /dev/cdrom
|
---|
| 37 | if [ "$?" -ne "0" ]; then
|
---|
| 38 | LogIt "Unable to softlink $device to /dev/cdrom. That's weird."
|
---|
| 39 | continue
|
---|
| 40 | fi
|
---|
[1758] | 41 | LogIt "CD-ROM found at $device"
|
---|
[1888] | 42 | mount $device -t iso9660 -o ro /mnt/cdrom 2> /tmp/mount.log
|
---|
[1758] | 43 | if [ "$?" -ne "0" ] ; then
|
---|
[1888] | 44 | LogIt "Cannot mount /dev/cdrom (type iso9660) (dev=$device)"
|
---|
[1758] | 45 | continue
|
---|
| 46 | elif [ ! -d "/mnt/cdrom/archives" ] ; then
|
---|
| 47 | LogIt "There is a CD in $device but it's not a Mondo CD"
|
---|
| 48 | continue
|
---|
| 49 | else
|
---|
| 50 | LogIt "$device is where the Mondo CD lives."
|
---|
| 51 | which hdparm > /dev/null 2> /dev/null && hdparm -u1 -c3 -d1 $device
|
---|
[1888] | 52 | return 0
|
---|
| 53 | fi
|
---|
[1758] | 54 | done
|
---|
| 55 | LogIt "Failed to find CD-ROM"
|
---|
| 56 | return 1
|
---|
[1] | 57 | }
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | # -------------- main ------------
|
---|
| 61 |
|
---|
| 62 | [ "$1" = "--second-try" ] && SECOND_TRY=yes
|
---|
| 63 | if [ ! "$GROOVY" ] ; then
|
---|
[1758] | 64 | LogIt "I'm not groovy!"
|
---|
| 65 | exit 1
|
---|
[1] | 66 | fi
|
---|
| 67 |
|
---|
| 68 | TryToFindCDROM
|
---|
| 69 | if [ "$?" -eq "0" ] ; then
|
---|
[1758] | 70 | [ "$SECOND_TRY" ] && add="At 2nd attempt, " || add=""
|
---|
| 71 | LogIt $add"CD-ROM found and mounted at $device" 3
|
---|
[2488] | 72 | echo "$device" > $MINDI_CACHE/CDROM-LIVES-HERE
|
---|
[1758] | 73 | LogIt "find-and-mount-cdrom --- leaving (0)"
|
---|
| 74 | exit 0
|
---|
[1] | 75 | fi
|
---|
[1885] | 76 | [ "$1" = "--second-try" ] && exit 1;
|
---|
[2591] | 77 | if [ -f $MINDI_CACHE/mondorestore.cfg ] && [ "`grep "using-cdstream yes" $MINDI_CACHE/mondorestore.cfg 2 > /dev/null`" ] ; then
|
---|
[1758] | 78 | LogIt "Because you are using cdstream, I won't try to mount CD."
|
---|
| 79 | exit 0
|
---|
[1] | 80 | fi
|
---|
| 81 |
|
---|
[1885] | 82 | LogIt "Unable to find and mount your CD-ROM" 1
|
---|
| 83 | LogIt "You probably miss the correct driver to support your CD-ROM drive" 1
|
---|
| 84 | exit 2
|
---|