source: MondoRescue/branches/2.2.10/mindi/rootfs/sbin/find-and-mount-cdrom@ 2591

Last change on this file since 2591 was 2591, checked in by Bruno Cornec, 14 years ago

r3723@localhost: bruno | 2010-03-09 23:56:51 +0100

  • No error msg if mondorestore.cfg doesn't exist (mindi alone)
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1#!/bin/sh
2
3
4TryToFindCDROM() {
5# hda1 is there for testing
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"
9 if [ -f $MINDI_CACHE/mondorestore.cfg ] && [ "`grep "using-cdstream yes" $MINDI_CACHE/mondorestore.cfg 2> /dev/null`" ]; then
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
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
33 fi
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
41 LogIt "CD-ROM found at $device"
42 mount $device -t iso9660 -o ro /mnt/cdrom 2> /tmp/mount.log
43 if [ "$?" -ne "0" ] ; then
44 LogIt "Cannot mount /dev/cdrom (type iso9660) (dev=$device)"
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
52 return 0
53 fi
54 done
55 LogIt "Failed to find CD-ROM"
56 return 1
57}
58
59
60# -------------- main ------------
61
62[ "$1" = "--second-try" ] && SECOND_TRY=yes
63if [ ! "$GROOVY" ] ; then
64 LogIt "I'm not groovy!"
65 exit 1
66fi
67
68TryToFindCDROM
69if [ "$?" -eq "0" ] ; then
70 [ "$SECOND_TRY" ] && add="At 2nd attempt, " || add=""
71 LogIt $add"CD-ROM found and mounted at $device" 3
72 echo "$device" > $MINDI_CACHE/CDROM-LIVES-HERE
73 LogIt "find-and-mount-cdrom --- leaving (0)"
74 exit 0
75fi
76[ "$1" = "--second-try" ] && exit 1;
77if [ -f $MINDI_CACHE/mondorestore.cfg ] && [ "`grep "using-cdstream yes" $MINDI_CACHE/mondorestore.cfg 2 > /dev/null`" ] ; then
78 LogIt "Because you are using cdstream, I won't try to mount CD."
79 exit 0
80fi
81
82LogIt "Unable to find and mount your CD-ROM" 1
83LogIt "You probably miss the correct driver to support your CD-ROM drive" 1
84exit 2
Note: See TracBrowser for help on using the repository browser.