source: branches/3.3/mindi/rootfs/usr/sbin/find-and-mount-cdrom @ 3697

Last change on this file since 3697 was 3697, checked in by bruno, 16 months ago

Remove usage of groovy word to clarify what is done

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1#!/bin/sh
2#
3# $Id: find-and-mount-cdrom 3697 2018-01-07 13:52:31Z bruno $
4#
5
6
7TryToFindCDROM() {
8# hda1 is there for testing
9    LogIt "find-and-mount-cdrom --- starting"
10    for device in /dev/hd? /dev/scd? /dev/rcd? /dev/sr? /dev/cd? /dev/ide/*/*/*/*/cd /dev/scsi/*/*/*/*/cd; do
11        [ ! "$SECOND_TRY" ] && LogIt "Trying $device"
12        if [ "`grep "using-cdstream yes" /tmp/mondorestore.cfg 2> /dev/null`" ]; then
13            pwd=`pwd`
14            cd $EXTRACTDIR
15            tar -zxf $device 2> /tmp/mount.log
16            res=$?
17            cd $pwd
18            if [ "$res" -eq "0" ] ; then
19                clear
20                LogIt "Using cdstream as extended datadisk ($device). Good." 3
21                echo "Using cdstrea as extd dsk." > /tmp/TAPEDEV-HAS-DATA-DISKS
22                ln -sf $device /dev/cdrom
23                exit 0
24            fi
25        else
26            mount $device -t iso9660 -o ro /mnt/cdrom 2> /tmp/mount.log
27            res=$?
28        fi
29        if [ "$res" -ne "0" ] ; then
30            res=`cat /tmp/mount.log`
31            if [ "$res" = "mount: No medium found" ] ; then
32                [ ! "$SECOND_TRY" ] && LogIt "There is a CD-ROM drive at $device but no CD in it."
33            else
34                [ ! "$SECOND_TRY" ] && LogIt "It's not in $device; I'll keep looking"
35            fi
36            continue
37        fi
38        LogIt "$device has a CD-ROM in it"
39        umount -d /mnt/cdrom
40        ln -sf $device /dev/cdrom
41        if [ "$?" -ne "0" ]; then
42            LogIt "Unable to softlink $device to /dev/cdrom. That's weird."
43            continue
44        fi
45        LogIt "CD-ROM found at $device"
46        mount $device -t iso9660 -o ro /mnt/cdrom 2> /tmp/mount.log
47        if [ "$?" -ne "0" ] ; then
48            LogIt "Cannot mount /dev/cdrom (type iso9660) (dev=$device)"
49            continue
50        elif [ ! -d "/mnt/cdrom/archives" ] ; then
51            LogIt "There is a CD in $device but it's not a Mondo CD"
52            continue
53        else
54            LogIt "$device is where the Mondo CD lives."
55            which hdparm > /dev/null 2> /dev/null && hdparm -u1 -c3 -d1 $device
56            return 0
57        fi
58    done
59    LogIt "Failed to find CD-ROM"
60    return 1
61}
62
63
64# -------------- main ------------
65
66[ "$1" = "--second-try" ] && SECOND_TRY=yes
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" /tmp/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.