blob: 6c52578b786567fe46933f4d7646603af2d6ee74 [file] [log] [blame]
#!/bin/sh
#
# Quick hack at UCD bug-report script
#
bug_reports_to=ucd-snmp-coders@ece.ucdavis.edu
# changed automagically
VersionInfo="3.4.pre1";
#
# Check how to do echo without a new line
# -n or \c
#
msg_file=/tmp/ucd-bug.$$
# remove files on signal
trap "rm -f rm ${msg_file} ${msg_file}.2; exit 1" 1 2 15
echo -n "test\c" > $msg_file
if grep c $msg_file>/dev/null
then
n="-n"
c=""
else
n=""
c="\c"
fi
echo "You are about to compose a mail message to the"
echo "ucd-snmp-coders@ece.ucdavis.edu. Please write a detailed"
echo "description of your problem. At the end you will be given"
echo "the opportunity to include optional text files, such as"
echo "patches, make output, error files, etc..."
echo ""
echo "Note: If at all possible, this should be run on the machine that"
echo " that you are having problems with. If this is not the case,"
echo " please include the architecture you are having problems on."
echo ""
#
# Ask for subject and 'From:' field
#
echo $n "Subject [none]: $c"
read answer
subject="$VersionInfo: $answer"
# attempt to figure out domain name.
domain=`grep "^domain" /etc/resolv.conf | awk '{print $2}'`;
if [ "$domain" = "" ]; then
domain=`grep "^search" /etc/resolv.conf | awk '{print $2}'`;
fi
email=`whoami`@`hostname`.$domain
echo $n "Your email address [$email]: $c"
read answer
if [ "$answer" != "" ]
then
email=$answer
fi
#
# Start to build the bug report
#
echo "UCD-SNMP version $VersionInfo bug report" > $msg_file
echo "----------------------------------------------------------" >> $msg_file
echo >> $msg_file
cp $msg_file ${msg_file}.2
echo $n "Press return to edit bug report file $c"
read pause
${EDITOR:-vi} $msg_file || exit
cmp -s $msg_file ${msg_file}.2 && echo "No description of the bug submitted. Please try again" && exit 1
#
# Start to create the mail message
#
echo "To: $bug_reports_to" > ${msg_file}.2
echo "From: $email" >> ${msg_file}.2
echo "Subject: $subject" >> ${msg_file}.2
echo "MIME-Version: 1.0" >> ${msg_file}.2
#
# Make this a multipart message
#
#boundary="`hostname`.$$.`date | tr " " .`"
boundary="temp-boundary.$$"
echo "Content-Type: multipart/mixed;" >> ${msg_file}.2
echo " boundary=\"$boundary\"" >> ${msg_file}.2
echo >> ${msg_file}.2
echo "--$boundary" >> ${msg_file}.2
#
# and add the bug report so far
#
echo "Content-Description: Bug Report" >> ${msg_file}.2
echo >> ${msg_file}.2
cat ${msg_file} >> ${msg_file}.2
echo >> ${msg_file}.2
#
# Add some potentially useful information
#
echo "--$boundary" >> ${msg_file}.2
echo "Content-Description: Version Information" >> ${msg_file}.2
echo >> ${msg_file}.2
echo "ucd-snmp Version: $VersionInfo" >> ${msg_file}.2
echo $n "System configuration: $c" >> ${msg_file}.2
uname -a >> ${msg_file}.2
if [ -f ./config.guess ]
then
echo $n "config.guess: $c" >> ${msg_file}.2
./config.guess >> ${msg_file}.2
fi
echo >> ${msg_file}.2
#
# Any other files to add?
#
echo "You may now include optional text files (patches, make -k output, etc)."
echo $n "Enter a file to include [RETURN if none]: $c"
read answer
while [ "$answer" != "" ]
do
#
# Include the specified file
#
if [ -f "$answer" ]
then
echo "--$boundary" >> ${msg_file}.2
echo "Content-Description: $answer" >> ${msg_file}.2
echo >> ${msg_file}.2
cat ${answer} >> ${msg_file}.2
echo >> ${msg_file}.2
else
echo "Cannot open file $answer"
fi
echo $n "Enter another file to include [RETURN if no more]: $c"
read answer
done
#
# Add config.cache file
#
if [ -f config.cache ]
then
echo "--$boundary" >> ${msg_file}.2
echo "Content-Description: config.cache" >> ${msg_file}.2
echo >> ${msg_file}.2
cat config.cache >> ${msg_file}.2
echo >> ${msg_file}.2
fi
#
# Finish off the message, send it and tidy up.
#
#
echo "--$boundary--" >> ${msg_file}.2
if [ -x /usr/lib/sendmail ]
then
/usr/lib/sendmail $bug_reports_to < ${msg_file}.2
else
mail $bug_reports_to < ${msg_file}.2
fi
rm ${msg_file} ${msg_file}.2