Ignore:
Timestamp:
Oct 31, 2007, 5:31:37 PM (16 years ago)
Author:
Bruno Cornec
Message:

Formating improvement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi/rootfs/sbin/find-and-mount-cdrom

    r273 r1758  
    44TryToFindCDROM() {
    55# 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" /tmp/mondo-restore.cfg`" ]; 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         clear
    17                LogIt "Using cdstream as extended datadisk ($device). Good." 3
    18         echo "Using cdstrea as extd dsk." > /tmp/TAPEDEV-HAS-DATA-DISKS
    19                 ln -sf $device /dev/cdrom
    20                 exit 0
    21         fi
    22         else
    23             mount $device -t iso9660 -o ro /mnt/cdrom 2> /tmp/mount.log
    24         res=$?
    25         fi
     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" /tmp/mondo-restore.cfg`" ]; 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                clear
     17                LogIt "Using cdstream as extended datadisk ($device). Good." 3
     18                echo "Using cdstrea as extd dsk." > /tmp/TAPEDEV-HAS-DATA-DISKS
     19                ln -sf $device /dev/cdrom
     20                exit 0
     21            fi
     22        else
     23            mount $device -t iso9660 -o ro /mnt/cdrom 2> /tmp/mount.log
     24            res=$?
     25        fi
    2626    if [ "$res" -ne "0" ] ; then
    27         res=`cat /tmp/mount.log`
    28         if [ "$res" = "mount: No medium found" ] ; then
    29                [ ! "$SECOND_TRY" ] && LogIt "There is a CD-ROM drive at $device but no CD in it."
    30         else
    31                [ ! "$SECOND_TRY" ] && LogIt "It's not in $device; I'll keep looking"
    32         fi
    33         continue
     27        res=`cat /tmp/mount.log`
     28        if [ "$res" = "mount: No medium found" ] ; then
     29               [ ! "$SECOND_TRY" ] && LogIt "There is a CD-ROM drive at $device but no CD in it."
     30        else
     31               [ ! "$SECOND_TRY" ] && LogIt "It's not in $device; I'll keep looking"
     32        fi
     33        continue
    3434    fi
    3535    LogIt "$device has a CD-ROM in it"
     
    3737    ln -sf $device /dev/cdrom
    3838    if [ "$?" -ne "0" ]; then
    39         LogIt "Unable to softlink $device to /dev/cdrom. That's weird."
    40         continue
     39        LogIt "Unable to softlink $device to /dev/cdrom. That's weird."
     40        continue
    4141    fi
    42         LogIt "CD-ROM found at $device"
     42        LogIt "CD-ROM found at $device"
    4343    mount /mnt/cdrom
    44         if [ "$?" -ne "0" ] ; then
    45         LogIt "Cannot mount /dev/cdrom (type $format) (dev=$device)"
    46             continue
    47         elif [ ! -d "/mnt/cdrom/archives" ] ; then
    48         LogIt "There is a CD in $device but it's not a Mondo CD"
    49             continue
    50         else
    51         LogIt "$device is where the Mondo CD lives."
    52             which hdparm > /dev/null 2> /dev/null && hdparm -u1 -c3 -d1 $device
    53         return 0
     44        if [ "$?" -ne "0" ] ; then
     45            LogIt "Cannot mount /dev/cdrom (type $format) (dev=$device)"
     46            continue
     47        elif [ ! -d "/mnt/cdrom/archives" ] ; then
     48            LogIt "There is a CD in $device but it's not a Mondo CD"
     49            continue
     50        else
     51            LogIt "$device is where the Mondo CD lives."
     52            which hdparm > /dev/null 2> /dev/null && hdparm -u1 -c3 -d1 $device
     53        return 0
    5454    fi
    55     done
    56     LogIt "Failed to find CD-ROM"
    57     return 1
     55    done
     56    LogIt "Failed to find CD-ROM"
     57    return 1
    5858}
    5959
     
    6363[ "$1" = "--second-try" ] && SECOND_TRY=yes
    6464if [ ! "$GROOVY" ] ; then
    65     LogIt "I'm not groovy!"
    66     exit 1
     65    LogIt "I'm not groovy!"
     66    exit 1
    6767fi
    6868
    6969TryToFindCDROM
    7070if [ "$?" -eq "0" ] ; then
    71     [ "$SECOND_TRY" ] && add="At 2nd attempt, " || add=""
    72     LogIt $add"CD-ROM found and mounted at $device" 3
    73     echo "$device" > /tmp/CDROM-LIVES-HERE
    74     LogIt "find-and-mount-cdrom --- leaving (0)"
    75     exit 0
     71    [ "$SECOND_TRY" ] && add="At 2nd attempt, " || add=""
     72    LogIt $add"CD-ROM found and mounted at $device" 3
     73    echo "$device" > /tmp/CDROM-LIVES-HERE
     74    LogIt "find-and-mount-cdrom --- leaving (0)"
     75    exit 0
    7676fi
    7777#mount /dev/fd0u1722 -t ext2 /mnt/floppy
    7878[ "$1" = "--second-try" ] && exit 1; # don't try to mount floppy drive
    7979if [ "`grep "using-cdstream yes" /tmp/mondo-restore.cfg`" ] ; then
    80     LogIt "Because you are using cdstream, I won't try to mount CD."
    81     exit 0
     80    LogIt "Because you are using cdstream, I won't try to mount CD."
     81    exit 0
    8282fi
    8383mount /dev/fd0 -t ext2 -o ro /mnt/floppy 2> /dev/null
    8484if [ "$?" -eq "0" ] ; then
    85     umount /mnt/floppy 2> /dev/null
    86     exit 1
     85    umount /mnt/floppy 2> /dev/null
     86    exit 1
    8787else
    88     LogIt "Please go to another PC, mount this CD and copy the data disk images" 1
    89     LogIt "from the CD's /images directory to blank 1.44MB floppy disks. You should" 1
    90     LogIt "use something like 'dd if=/mnt/cdrom/images/mindi-data-1.img of=/dev/fd0'" 1
    91     LogIt "for the first data disk, mindi-data-2.img for the second, and so on." 1
    92     LogIt "(If you are already booting from a floppy, please ignore this message.)" 1
    93     exit 2
     88    LogIt "Please go to another PC, mount this CD and copy the data disk images" 1
     89    LogIt "from the CD's /images directory to blank 1.44MB floppy disks. You should" 1
     90    LogIt "use something like 'dd if=/mnt/cdrom/images/mindi-data-1.img of=/dev/fd0'" 1
     91    LogIt "for the first data disk, mindi-data-2.img for the second, and so on." 1
     92    LogIt "(If you are already booting from a floppy, please ignore this message.)" 1
     93    exit 2
    9494fi
    9595
Note: See TracChangeset for help on using the changeset viewer.