#!/bin/sh # HardwareChecker.sh for Haiku # # Copyright 2011-2014, François Revol . # # Distributed under the MIT License # # Created: 2011-10-25 # netcat=nc report_site=fake.haikuware.com report_cgi=http://haikuware.com/hwreport.php packages="dmidecode netcat" do_notify () { p="$1" m="$2" shift shift notify --type progress \ --messageID hwck_$$ \ --icon /system/apps/Devices \ --group HardwareChecker \ --title "progress:" --progress "$p" "$m" "$@" } try_install_packages () { which pkgman >/dev/null 2>&1 || return for p in $packages; do pkgman install "$p" || alert "Unable to install package '$p'" "Ok" done } start_fake_httpd () { report_port=8989 report_file="$(finddir B_DESKTOP_DIRECTORY)/hwchecker_report_$$.txt" report_ack="

Done! You can close this window now.

" report_cgi=http://127.0.0.1:$report_port/hwreport ( # force a previous instance to close $netcat 127.0.0.1 8989 < /dev/null > /dev/null echo "listening on port $report_port" # (echo -e "HTTP/1.1 100 Continue\r\n\r\n"; echo -e "HTTP/1.1 200 OK\r\nDate: $(date)\r\nContent-Type: text/html\r\nContent-Length: ${#report_ack}\r\n\r\n$report_ack") | $netcat -q 1 -l -p $report_port > "$report_file" # make sure we have something if [ -s "$report_file" ]; then open "$report_file" sleep 1 alert "A file named $(basename $report_file) has been created on your desktop. You can copy this file to an external drive to submit it with another operating system." "Ok" else rm "$report_file" fi ) & } detect_network () { ping -c 1 "$report_site" if [ "$?" -gt 0 ]; then alert --stop "Cannot contact the hardware report site ($report_site). You can continue anyway and generate a local file to submit later on, or try to configure networking." "Cancel" "Configure Network" "Continue" case "$?" in 0) exit 0 ;; 1) /system/preferences/Network detect_network ;; 2) start_fake_httpd ;; *) exit 1 ;; esac fi } check_pci () { echo "

PCI devices

" echo "
List of detected PCI devices. This does not indicate that every probed device is supported by a driver.

" devn=0 bus="pci" vendor='' device='' true; listdev | while read line; do case "$line" in device*) case "$vendor" in "") desc="${line/device /}" echo "
$desc
" ;; *) devicestr=${line#*:} device="${line%:*}" device="${device#device }" echo "
" echo "
$vendor:$device $vendorstr:$devicestr
" descline="$vendor:$device \"$vendorstr\" \"$devicestr\" $desc" echo "
Identification:
" echo "
" echo "" echo "" echo "
" echo "Status: " echo "" echo "" echo "
" #echo "
" echo "" echo "
" #echo "
" echo "" echo "
" echo "
" echo "
" echo "Is it an add-in card (not part of the motherboard) ? " echo "" echo "
" echo "
" echo "Comment: " echo "" echo "
" echo "
" echo "
" vendor='' devn=$(($devn+1)) ;; esac ;; vendor*) vendorstr=${line#*:} vendor="${line%:*}" vendor="${vendor#vendor }" ;; *) ;; esac done } check_usb () { echo "

USB devices

" echo "
List ot detected USB devices. This does not indicate that every probed device is supported by a driver.

" devn=0 bus="usb" listusb | while read vpid dev desc; do echo "
$desc
" echo "
" echo "
Identification:
" if [ "$vpid" != "0000:0000" ]; then enabled=1 id="" echo "
" echo "" echo "" echo "
" echo "Status: " echo "" echo "" echo "
" #echo "
" echo "" echo "
" #echo "
" echo "" echo "
" echo "
" echo "
" echo "Is it an external device (not part of the motherboard) ? " echo "" echo "
" echo "
" echo "Comment: " echo "" echo "
" else echo "
(virtual device)
" fi echo "
" echo "
" devn=$(($devn+1)) done echo "
" } check_dmidecode () { which dmidecode >/dev/null 2>&1 || return # make sure /dev/mem is published ls -l /dev/misc/mem > /dev/null echo "

DMIdecode output

" echo "The output of dmidecode gives exact vendor and device identification." echo "

dmidecode

" echo "(full output, stripped from the machine UUID)
" echo "" dmidecode_bios_vendor="$(dmidecode -s bios-vendor)" dmidecode_bios_version="$(dmidecode -s bios-version)" dmidecode_bios_release_date="$(dmidecode -s bios-release-date)" dmidecode_system_manufacturer="$(dmidecode -s system-manufacturer)" dmidecode_system_product_name="$(dmidecode -s system-product-name)" dmidecode_system_version="$(dmidecode -s system-version)" } check_machine () { echo "

Machine

" echo "Vendor: " echo "
" echo "Model: " echo "
" echo "Specification page: " echo "
" echo "Comments:
" echo "" echo "
" } check_haiku () { echo "

Haiku

" uname_r="$(uname -r)" uname_v="$(uname -v)" echo "Release: " echo "
" echo "Version: " echo "
" echo "Comments:
" echo "" echo "
" } check_utils () { echo "

Utilities output

" echo "The output of some system utilities gives precious informations on the processor model and other stuff..." echo "

sysinfo

" echo "(system info)
" echo "" echo "

listimage 1

" echo "(list of loaded kernel drivers)
" echo "" echo "

ifconfig

" echo "(list of network interfaces)
" echo "" echo "

pkgman list-repos

" echo "(list of configured package repositories)
" echo "" echo "

pkgman search -a

" echo "(list of installed packaged)
" echo "" echo "
" } check_syslog () { echo "

System log

" echo "
Part of the system boot log that could help developer understand why some devices are not recognized...
" echo "" } check_sender () { echo "

Sender info (optional)

" echo "Name: " echo "
" echo "Mail: " echo "
" echo "Other comments:
" echo "" echo "
" } check_all () { echo "" echo "" echo '' echo "Hardware report" #echo '' echo "" echo "" echo "" echo "
" echo "
" do_notify 0.1 "Checking for PCI hardware..." check_pci do_notify 0.2 "Checking for USB hardware..." check_usb do_notify 0.3 "Checking for utility outputs..." check_utils do_notify 0.7 "Dumping syslog output..." check_syslog do_notify 0.8 "Checking machine infos..." check_dmidecode check_machine do_notify 0.9 "Checking for Haiku version..." check_haiku check_sender do_notify 1.0 "Done!" --timeout 3 echo "
Note: this form will only send data that is visible on this page.
" echo "" echo "
" echo "
" echo "" echo "" } tf=/tmp/hw_checker_$$.html do_notify 0.0 "Checking for needed packages..." try_install_packages do_notify 0.0 "Checking for network..." detect_network check_all > "$tf" open "$tf"