Example class HWCD: Difference between revisions

From FAIWiki
Jump to navigation Jump to search
(spaces on the left of comments.)
m (put everithing into a pre - tag)
Line 6: Line 6:
the four classes are "HWCDROM HWDVDROM HWCDBURN HWDVDBURN"
the four classes are "HWCDROM HWDVDROM HWCDBURN HWDVDBURN"


<pre>
  #!/bin/sh
  #!/bin/sh
  #(c) Thomas Lange, 2002-2005, lange@informatik.uni-koeln.de
  #(c) Thomas Lange, 2002-2005, lange@informatik.uni-koeln.de
Line 73: Line 74:
     echo "WARNING: no cdrom detected, and i was written for fai-cd! continuing anyways!"
     echo "WARNING: no cdrom detected, and i was written for fai-cd! continuing anyways!"
fi
fi
</pre>

Revision as of 15:41, 23 August 2005

this is an example of a detection routine for "shiney plastic disc drives". it uses an internal table to check what drive has what capability, as a central discover database for this info does not exist (that i know of).

first, it checks to see if a cdrom driver is loaded, then checks what device its loaded for. the only results of this script should be a jhwdetect.var (for debugging), and one of four classes, depending on what the drive can do. the four classes are "HWCDROM HWDVDROM HWCDBURN HWDVDBURN"

 #!/bin/sh
 #(c) Thomas Lange, 2002-2005, lange@informatik.uni-koeln.de

 #the output of this program will define hardware related classes.

 #try to detect "shiney plastic disc" drives.

 #first, see if theres a cdrom driver loaded
driver=`cat /proc/ide/drivers | grep cdrom`

if [ -n "$driver" ]
    then
    {
        #a cdrom driver was loaded, a cdrom device is likely
        cdroms=`grep -R ide-cdrom /proc/ide/ide* | sed "s/\(.*\)\/.*:.*/\1/"`
        for cdrom in $cdroms; # try to detect the "shiney metal disc drive"
          do {
              compaqdvd=`grep "COMPAQ DVD-ROM" $cdrom/model`
              [ -n "$compaqdvd" ] && dvdroms=`echo $dvdroms $cdrom`
              atapiburner=`grep "ATAPI CD-RW" $cdrom/model`
              [ -n "$atapiburner" ] && cdburners=`echo $atapiburners $cdrom`
              gwburner=`grep "CR-48X9TE" $cdrom/model`
              [ -n "$gwburner" ] && cdburners=`echo $cdburners $cdrom`
              sonydvd=`grep "SONY DVD-ROM" $cdrom/model`
              [ -n "$sonydvd" ] && dvdroms=`echo $dvdroms $cdrom`
              sonyburner=`grep "SONY DVD RW" $cdrom/model`
              [ -n "$sonyburner" ] && dvdburners=`echo $dvdburners $cdrom`
              i8kdvd=`grep "TOSHIBA DVD-ROM" $cdrom/model`
              [ -n "$i8kdvd" ] && dvdroms=`echo $dvdroms $cdrom`
          }
        done;
        if [ -n "$cdburners" ]
            then
            {
                echo "cdburners=$cdburners" >> $LOGDIR/jhwdetect.log
                newclasses=`echo $newclasses HWCDROM HWCDBURN`
            }
        else
            {
                if [ -n "$dvdburners" ]
                    then
                    {
                        echo "dvdburners=$dvdburners" >> $LOGDIR/jhwdetect.log
                        newclasses=`echo $newclasses HWCDROM HWCDBURN HWDVDROM HWDVDBURN`
                    }
                else
                    {
                        if [ -n "$dvdroms" ]
                            then
                            {
                                echo "dvdroms=$dvdroms" >> $LOGDIR/jhwdetect.log
                                newclasses=`echo $newclasses HWCDROM HWDVDROM`
                            }
                        else
                            {
                                echo "cdroms=$cdroms" >> $LOGDIR/jhwdetect.log
                                newclasses=`echo $newclasses HWCDROM`
                            }
                        fi
                    }
                fi
            }
        fi
    }
else
    echo "WARNING: no cdrom detected, and i was written for fai-cd! continuing anyways!"
fi