#!/bin/sh

case "$@" in
  *--asked*) ;;
  *)
    echo -n 'This program reports to Red Hat via email that you have encountered
a bug with ACPI on your system.  To do so, it will send some information
from your system to hardwarebugs-list@redhat.com.  That information will
include the ACPI implementation in your BIOS, and the DMI tables.

If your system is not connected to the internet, this program cannot
report the bug.  Instead, you will need to manually report the bug
using our bugzilla at
    http://bugzilla.redhat.com/bugzilla/
Please include in that bug report the output of two programs, run as
root:
    /usr/sbin/dmidecode
    /usr/sbin/acpidmp
In addition, if you wish for an explicit response to your bug report,
you may choose to file your bug
    
Do you wish to continue, automatically mailing your bug report to
Red Hat?  [Y/n]: '
    read answer
    case $answer in 
        n*|N*) exit; ;;
    esac
    ;;
esac

if [ $(id -u) -ne 0 ] ; then
    echo 'The programs we need to run to report this bug require root access.
Please enter your root password'
    exec su -c "$0 --asked"
    # should never be reached, but can't run these programs as non-root
    echo "report not sent"
    exit 1
fi

(echo 'DMI:' ; /usr/sbin/dmidecode;
 echo
 echo
 echo 'AML:' ; /usr/sbin/acpidmp) | \
    mail -s 'ACPI failure report' hardwarebugs-list@redhat.com
