home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- #
- #
- # Variablen
- BASEURL=http:\\/\\/pcwelt-wiki.de\\/wiki\\/
-
- function getutil() {
- unset X
- X_PATH="/bin /usr/bin /sbin /usr/sbin"
- for I in $X_PATH
- do
- if [ -x $I/$1 ];
- then
- X=$I/$1
- fi
- done
- if [ -z $X ];
- then
- echo "Fatal: $1 nicht gefunden, Abbruch."
- exit 1
- fi
- }
-
- function writehtml() {
- echo '<a href="'$1'">'$2'</a><br>' >>$OUTPUT
- }
-
- getutil "lsusb"; LSUSB=$X
- getutil "lspci"; LSPCI=$X
-
- # PCI
- PCIDEVS=($($LSPCI |cut -d' ' -f2- |sed -e 's/ /\ /g'))
- if [ "$($LSPCI --version)" = "lspci version 2.1.11" ] && [ "$(cat /etc/debian_version 2>/dev/null)" = "3.1" ] ;
- then
- PCIURLS=($($LSPCI -mn \
- |awk 'OFS=":" {print $3,$4,$7,$8}'\
- |sed -e s/^/"$BASEURL"/g))
- else
- PCIURLS=($($LSPCI -mn |cut -d' ' -f2- |sed \
- -e 's/Class//g'\
- -e 's/-[r\|p][0-f]\{2\}//g'\
- -e 's/""/"0000"/g'\
- -e 's/ //g'\
- -e 's/""/:/g'\
- -e 's/"//g'\
- -e 's/^.\{5\}//g'\
- -e s/^/"$BASEURL"/g))
- fi
-
- #USB
- USBDEVS=($($LSUSB \
- |grep -v 0000:0000 \
- |cut -d' ' -f7-\
- |sed -e 's/ /\ /g'))
- USBURLS=($($LSUSB \
- |grep -v 0000:0000 \
- |cut -d' ' -f6\
- |sed -e s/^/"$BASEURL"/g))
-
- OUTPUT='./pcwhwid.html'
- if [ -f $OUTPUT ]; then rm $OUTPUT; fi
-
- echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">'>> $OUTPUT
- echo '<html>' >> $OUTPUT
- echo '<head>' >> $OUTPUT
- echo '<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">' >> $OUTPUT
- echo '<title>Gerätekonfiguration für '$(hostname)'</title>' >>$OUTPUT
- echo '</head>' >> $OUTPUT
- echo '<body>' >>$OUTPUT
- echo '<h1>Gerätekonfiguration für '$(hostname)'</h1>' >>$OUTPUT
- echo '<style type="text/css">' >>$OUTPUT
- echo 'body { font-family: sans-serif;}' >>$OUTPUT
- echo ':link {text-decoration: none}' >>$OUTPUT
- echo ':visited {text-decoration: none}' >>$OUTPUT
- echo ':hover {text-decoration: underline overline; color: red;}' >>$OUTPUT
- echo '</style>' >> $OUTPUT
- echo 'Die Links führen jeweils zur Hardware-Datenbank im <a href="http://pcwelt-wiki.de/wiki/">PC-WELT-Praxis-Wiki</a>.' >>$OUTPUT
-
- if [ ${#PCIURLS} -eq 0 ];
- then
- echo '<h2><Keine PCI-Geräte.</h2>' >>$OUTPUT
- else
- echo '<h2>PCI-Geräte:</h2>' >>$OUTPUT
- I=0
- while [ $I -lt ${#PCIURLS[@]} ]; do
- writehtml ${PCIURLS[$I]} ${PCIDEVS[$I]}
- I=$(expr $I + 1)
- done
- fi
-
- if [ ${#USBURLS} -eq 0 ];
- then
- echo '<h2>Keine USB-Geräte.</h2>' >>$OUTPUT
- else
- echo '<h2>USB-Geräte:</h2>' >>$OUTPUT
- I=0
- while [ $I -lt ${#USBURLS[@]} ]; do
- writehtml ${USBURLS[$I]} ${USBDEVS[$I]}
- I=$(expr $I + 1)
- done
- fi
-
- echo '</body>' >>$OUTPUT
- echo '</html>' >>$OUTPUT
- echo 'Die Datei '$OUTPUT' wurde erstellt.'
-
- # vim:set shiftwidth=2 smarttab smartindent:
-