Example class HWCD: Difference between revisions

From FAIWiki
Jump to navigation Jump to search
(spaces on the left of comments.)
m (correct copyright.)
 
(2 intermediate revisions by 2 users not shown)
Line 6: Line 6:
the four classes are "HWCDROM HWDVDROM HWCDBURN HWDVDBURN"
the four classes are "HWCDROM HWDVDROM HWCDBURN HWDVDBURN"


#!/bin/sh
<pre>
#(c) Thomas Lange, 2002-2005, lange@informatik.uni-koeln.de
#!/bin/sh
#(c) Julia Longtin, 2005-2008, risc@volumehost.com


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


#try to detect "shiney plastic disc" drives.
#try to detect "shiney plastic disc" drives.


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


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>

Latest revision as of 15:46, 31 October 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) Julia Longtin, 2005-2008, risc@volumehost.com

#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