[5] | 1 | #!/bin/sh |
---|
[19702] | 2 | # $Id: sendbug.sh,v 1.21 2003-07-30 19:16:12 zacheiss Exp $ |
---|
[8670] | 3 | |
---|
[23088] | 4 | visual=false |
---|
[25414] | 5 | |
---|
| 6 | help () { |
---|
| 7 | echo "Usage: $0 [program]" |
---|
| 8 | echo "Assist a user in sending an accurate and useful bug report." |
---|
| 9 | } |
---|
| 10 | |
---|
| 11 | TEMP="$(getopt -n "$0" -o '' -l gnome,help -- "$@")" || exit $? |
---|
| 12 | eval set -- "$TEMP" |
---|
| 13 | |
---|
| 14 | while true; do |
---|
| 15 | case "$1" in |
---|
| 16 | # This is how we are invoked from the panel menu |
---|
| 17 | --gnome) gnome=true; shift;; |
---|
| 18 | --help) help; exit;; |
---|
| 19 | --) shift; break;; |
---|
| 20 | esac |
---|
| 21 | done |
---|
| 22 | |
---|
[23088] | 23 | subject=$1 |
---|
| 24 | bugs_address=bugs@mit.edu |
---|
| 25 | sendmail="/usr/sbin/sendmail -t -oi" |
---|
| 26 | report_file=$(mktemp -t "sendbug.$USER.XXXX") |
---|
| 27 | machtype=$(machtype) |
---|
| 28 | cpu=$(machtype -c) |
---|
| 29 | hostname=$(hostname) |
---|
| 30 | dpy=$(machtype -d) |
---|
[13018] | 31 | |
---|
[13428] | 32 | shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null` |
---|
[13018] | 33 | case $shell in |
---|
| 34 | $SHELL) |
---|
[23088] | 35 | ;; |
---|
[13018] | 36 | "") |
---|
[23088] | 37 | shell="$SHELL (?)" |
---|
| 38 | ;; |
---|
[13018] | 39 | *) |
---|
[23088] | 40 | shell="$shell ($SHELL?)" |
---|
| 41 | ;; |
---|
[13018] | 42 | esac |
---|
| 43 | |
---|
[18057] | 44 | if [ -z "$subject" ]; then |
---|
[23088] | 45 | text="Please enter the name of the program or locker with which you are" |
---|
| 46 | text="$text having problems." |
---|
| 47 | if [ true = "$gnome" ]; then |
---|
[23633] | 48 | if ! subject=$(zenity --entry --text="$text"); then |
---|
| 49 | exit |
---|
| 50 | fi |
---|
[23088] | 51 | else |
---|
| 52 | echo "$text" || fmt |
---|
| 53 | echo -n ' --> ' |
---|
| 54 | read subject |
---|
| 55 | fi |
---|
[18057] | 56 | fi |
---|
| 57 | |
---|
[2433] | 58 | cat > $report_file << EOF |
---|
| 59 | To: $bugs_address |
---|
[23924] | 60 | Subject: Debathena: $subject |
---|
[23088] | 61 | |
---|
[2433] | 62 | System name: $hostname |
---|
[23088] | 63 | Type: $cpu |
---|
| 64 | Display type: $dpy |
---|
[2447] | 65 | |
---|
[13018] | 66 | Shell: $shell |
---|
| 67 | Window manager: ${WINDOW_MANAGER:-unknown} |
---|
| 68 | |
---|
[2433] | 69 | What were you trying to do? |
---|
[2447] | 70 | [Please replace this line with your information.] |
---|
[5] | 71 | |
---|
[2433] | 72 | What's wrong: |
---|
[2447] | 73 | [Please replace this line with your information.] |
---|
[2433] | 74 | |
---|
| 75 | What should have happened: |
---|
[2447] | 76 | [Please replace this line with your information.] |
---|
[2433] | 77 | |
---|
| 78 | Please describe any relevant documentation references: |
---|
[2447] | 79 | [Please replace this line with your information.] |
---|
[2433] | 80 | EOF |
---|
| 81 | |
---|
[23088] | 82 | if [ true = "$gnome" ]; then |
---|
| 83 | text="After you click OK, an editor window will appear with the bug report" |
---|
| 84 | text="$text contents. Please fill out the form, then save and exit. If" |
---|
| 85 | text="$text you change your mind, you will have a chance to cancel before" |
---|
| 86 | text="$text the bug report is sent." |
---|
| 87 | zenity --info --text="$text" |
---|
| 88 | gnome-text-editor "$report_file" |
---|
| 89 | # zenity doesn't let us specify the buttons on a question, and the |
---|
| 90 | # list dialog is awkward. So while we'd like to do something more |
---|
| 91 | # like what we do in the terminal case, we'll compromise a bit. |
---|
| 92 | question="Do you still want to send the bug report?" |
---|
| 93 | if ! zenity --question --text="$question"; then |
---|
| 94 | text="Cancelled. Your text is in $report_file if you wish to recover it." |
---|
| 95 | zenity --info --no-wrap --text="$text" |
---|
| 96 | exit |
---|
| 97 | fi |
---|
[2433] | 98 | |
---|
[23088] | 99 | if $sendmail < $report_file; then |
---|
| 100 | text="Thank you for your bug report." |
---|
| 101 | zenity --info --text="$text" |
---|
| 102 | else |
---|
| 103 | text="Failed to send the bug report! Please contact x3-4435 for" |
---|
| 104 | text="$text\nassistance. Your text is in $report_file" |
---|
| 105 | text="$text\nif you wish to recover it." |
---|
| 106 | zenity --error --no-wrap --text="$text" |
---|
| 107 | fi |
---|
| 108 | else |
---|
| 109 | fmt << EOF |
---|
| 110 | |
---|
[2433] | 111 | Please fill in the specified fields of the bug report form, which will |
---|
| 112 | be displayed momentarily. |
---|
| 113 | Remember to save the file before exiting the editor. |
---|
| 114 | EOF |
---|
[23088] | 115 | : ${EDITOR=emacs} |
---|
| 116 | $EDITOR "$report_file" |
---|
| 117 | while true; do |
---|
| 118 | fmt << EOF |
---|
[2433] | 119 | |
---|
[23088] | 120 | Please enter "send" to send the report, "edit" to re-edit it, or |
---|
| 121 | "quit" to quit. |
---|
| 122 | EOF |
---|
| 123 | echo -n ' --> ' |
---|
| 124 | read reply |
---|
| 125 | [ send = "$reply" ] && break |
---|
| 126 | [ quit = "$reply" ] && exit |
---|
| 127 | [ edit = "$reply" ] && $EDITOR "$report_file" |
---|
| 128 | done |
---|
[2433] | 129 | |
---|
[23088] | 130 | if $sendmail < $report_file; then |
---|
| 131 | echo "Thank you for your bug report." |
---|
| 132 | else |
---|
| 133 | fmt << EOF |
---|
| 134 | Failed to send the bug report! Please contact x3-4435 for assistance. |
---|
| 135 | Your text is in $report_file if you wish to recover it. |
---|
| 136 | EOF |
---|
| 137 | fi |
---|
| 138 | fi |
---|