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