home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 October / PCWELT_10_2006.ISO / pcwsoft / pcwhwid < prev    next >
Encoding:
Text File  |  2006-08-03  |  2.6 KB  |  108 lines

  1. #!/bin/bash
  2. #
  3. #
  4. # Variablen
  5. BASEURL=http:\\/\\/pcwelt-wiki.de\\/wiki\\/
  6.  
  7. function getutil() {
  8.   unset X
  9.   X_PATH="/bin /usr/bin /sbin /usr/sbin"
  10.   for I in $X_PATH
  11.   do
  12.     if [ -x $I/$1 ];
  13.     then
  14.       X=$I/$1
  15.     fi
  16.   done
  17.   if [ -z $X ];
  18.   then
  19.     echo "Fatal: $1 nicht gefunden, Abbruch."
  20.     exit 1
  21.   fi
  22. }
  23.  
  24. function writehtml() {
  25.   echo '<a href="'$1'">'$2'</a><br>' >>$OUTPUT
  26. }
  27.  
  28. getutil "lsusb"; LSUSB=$X
  29. getutil "lspci"; LSPCI=$X
  30.  
  31. # PCI
  32. PCIDEVS=($($LSPCI |cut -d' ' -f2- |sed -e 's/ /\ /g'))
  33. if [ "$($LSPCI --version)" = "lspci version 2.1.11" ] && [ "$(cat /etc/debian_version 2>/dev/null)" = "3.1" ] ;
  34. then
  35.   PCIURLS=($($LSPCI -mn \
  36.   |awk 'OFS=":" {print $3,$4,$7,$8}'\
  37.   |sed -e s/^/"$BASEURL"/g))
  38. else
  39. PCIURLS=($($LSPCI -mn |cut -d' ' -f2- |sed \
  40.   -e 's/Class//g'\
  41.   -e 's/-[r\|p][0-f]\{2\}//g'\
  42.   -e 's/""/"0000"/g'\
  43.   -e 's/ //g'\
  44.   -e 's/""/:/g'\
  45.   -e 's/"//g'\
  46.   -e 's/^.\{5\}//g'\
  47.   -e s/^/"$BASEURL"/g))
  48. fi
  49.  
  50. #USB
  51. USBDEVS=($($LSUSB \
  52.   |grep -v 0000:0000 \
  53.   |cut -d' ' -f7-\
  54.   |sed -e 's/ /\ /g'))
  55. USBURLS=($($LSUSB \
  56.   |grep -v 0000:0000 \
  57.   |cut -d' ' -f6\
  58.   |sed -e s/^/"$BASEURL"/g))
  59.  
  60. OUTPUT='./pcwhwid.html'
  61. if [ -f $OUTPUT ]; then rm $OUTPUT; fi
  62.  
  63. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">'>> $OUTPUT
  64. echo '<html>' >> $OUTPUT
  65. echo '<head>' >> $OUTPUT
  66. echo '<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">' >> $OUTPUT
  67. echo '<title>Gerätekonfiguration für '$(hostname)'</title>' >>$OUTPUT
  68. echo '</head>' >> $OUTPUT
  69. echo '<body>' >>$OUTPUT
  70. echo '<h1>Gerätekonfiguration für '$(hostname)'</h1>' >>$OUTPUT
  71. echo '<style type="text/css">' >>$OUTPUT
  72. echo 'body { font-family: sans-serif;}' >>$OUTPUT
  73. echo ':link {text-decoration: none}' >>$OUTPUT
  74. echo ':visited {text-decoration: none}' >>$OUTPUT
  75. echo ':hover {text-decoration: underline overline; color: red;}' >>$OUTPUT
  76. echo '</style>' >> $OUTPUT
  77. echo 'Die Links führen jeweils zur Hardware-Datenbank im <a href="http://pcwelt-wiki.de/wiki/">PC-WELT-Praxis-Wiki</a>.' >>$OUTPUT
  78.  
  79. if [ ${#PCIURLS} -eq 0 ];
  80. then
  81.   echo '<h2><Keine PCI-Geräte.</h2>' >>$OUTPUT
  82. else
  83.   echo '<h2>PCI-Geräte:</h2>' >>$OUTPUT
  84.   I=0
  85.   while [ $I -lt ${#PCIURLS[@]} ]; do
  86.     writehtml ${PCIURLS[$I]} ${PCIDEVS[$I]}
  87.     I=$(expr $I + 1)
  88.   done
  89. fi
  90.  
  91. if [ ${#USBURLS} -eq 0 ];
  92. then
  93.   echo '<h2>Keine USB-Geräte.</h2>' >>$OUTPUT
  94. else
  95.   echo '<h2>USB-Geräte:</h2>' >>$OUTPUT
  96.   I=0
  97.   while [ $I -lt ${#USBURLS[@]} ]; do
  98.     writehtml ${USBURLS[$I]} ${USBDEVS[$I]}
  99.     I=$(expr $I + 1)
  100.   done
  101. fi
  102.  
  103. echo '</body>' >>$OUTPUT
  104. echo '</html>' >>$OUTPUT
  105. echo 'Die Datei '$OUTPUT' wurde erstellt.'
  106.  
  107. # vim:set shiftwidth=2 smarttab smartindent:
  108.