Example class HWCD

From FAIWiki
Revision as of 16:35, 23 August 2005 by Juri (talk | contribs) (creation, initial version of script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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"

  1. !/bin/sh
  2. (c) Thomas Lange, 2002-2005, lange@informatik.uni-koeln.de
  1. the output of this program will define hardware related classes.
  1. try to detect "shiney plastic disc" drives.
  1. 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