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

Last change on this file since 2462 was 2462, checked in by Bruno Cornec, 15 years ago

r3548@localhost: bruno | 2009-10-16 19:18:27 +0200

  • mindi now boots in a QEMU VM without busybox
  • mindi is now noarch as a consequence
  • MINDI_LIB becomes MINDI_DATA for coherency and as a consequence
  • CACHEDIR becomes MINDI_CACHE for coherency and it's a build parameter and not hardcoded anymore in mindi
  • THat variable is also used at restore time for mondorestore.cfg e.g.
  • FAILSAFE kernel is gone. Just use another kernel of your choice. Most std kernels work anyway
  • TurnTgzIntoRdz rewritten and now really computes data disk size and not suppose its size
  • Interface mondo/mindi changed again => incompatible
  • Non-bootable media not supported anymore.
  • Mondorescue adapted to these changes but not tested yet
  • Doc updated as well
  • Property svn:keywords set to Id
File size: 2.4 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 [ "`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" > /tmp/CDROM-LIVES-HERE
73 LogIt "find-and-mount-cdrom --- leaving (0)"
74 exit 0
75fi
76[ "$1" = "--second-try" ] && exit 1;
77if [ "`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.