[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 | |
---|
[25582] | 32 | localacct= |
---|
[13428] | 33 | shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null` |
---|
[25582] | 34 | if [ -z "$shell" ]; then |
---|
| 35 | shell=`getent passwd $USER 2>/dev/null | cut -d ':' -f 7` |
---|
| 36 | else |
---|
| 37 | localacct="(local account)" |
---|
| 38 | fi |
---|
[13018] | 39 | case $shell in |
---|
| 40 | $SHELL) |
---|
[23088] | 41 | ;; |
---|
[13018] | 42 | "") |
---|
[23088] | 43 | shell="$SHELL (?)" |
---|
| 44 | ;; |
---|
[13018] | 45 | *) |
---|
[23088] | 46 | shell="$shell ($SHELL?)" |
---|
| 47 | ;; |
---|
[13018] | 48 | esac |
---|
| 49 | |
---|
[18057] | 50 | if [ -z "$subject" ]; then |
---|
[23088] | 51 | text="Please enter the name of the program or locker with which you are" |
---|
| 52 | text="$text having problems." |
---|
| 53 | if [ true = "$gnome" ]; then |
---|
[23633] | 54 | if ! subject=$(zenity --entry --text="$text"); then |
---|
| 55 | exit |
---|
| 56 | fi |
---|
[23088] | 57 | else |
---|
| 58 | echo "$text" || fmt |
---|
| 59 | echo -n ' --> ' |
---|
| 60 | read subject |
---|
| 61 | fi |
---|
[18057] | 62 | fi |
---|
| 63 | |
---|
[2433] | 64 | cat > $report_file << EOF |
---|
| 65 | To: $bugs_address |
---|
[23924] | 66 | Subject: Debathena: $subject |
---|
[23088] | 67 | |
---|
[2433] | 68 | System name: $hostname |
---|
[23088] | 69 | Type: $cpu |
---|
| 70 | Display type: $dpy |
---|
[2447] | 71 | |
---|
[25582] | 72 | Shell: $shell $localacct |
---|
[13018] | 73 | Window manager: ${WINDOW_MANAGER:-unknown} |
---|
[25582] | 74 | Desktop session: ${GDMSESSION:-unknown} |
---|
[13018] | 75 | |
---|
[25582] | 76 | 1) What were you trying to do? |
---|
[5] | 77 | |
---|
[2433] | 78 | |
---|
[25582] | 79 | 2) What happened? |
---|
[2433] | 80 | |
---|
[25582] | 81 | |
---|
| 82 | 3) What should have happened? |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | 4) Does this problem happen only on this workstation, or other workstations? |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | 5) If you were following instructions, please include the URL or a |
---|
| 89 | description of the documentation: |
---|
| 90 | (e.g. a "problem set for 18.03" or http://ist.mit.edu) |
---|
| 91 | |
---|
| 92 | |
---|
[2433] | 93 | EOF |
---|
| 94 | |
---|
[23088] | 95 | if [ true = "$gnome" ]; then |
---|
| 96 | text="After you click OK, an editor window will appear with the bug report" |
---|
| 97 | text="$text contents. Please fill out the form, then save and exit. If" |
---|
| 98 | text="$text you change your mind, you will have a chance to cancel before" |
---|
| 99 | text="$text the bug report is sent." |
---|
| 100 | zenity --info --text="$text" |
---|
| 101 | gnome-text-editor "$report_file" |
---|
| 102 | # zenity doesn't let us specify the buttons on a question, and the |
---|
| 103 | # list dialog is awkward. So while we'd like to do something more |
---|
| 104 | # like what we do in the terminal case, we'll compromise a bit. |
---|
| 105 | question="Do you still want to send the bug report?" |
---|
| 106 | if ! zenity --question --text="$question"; then |
---|
| 107 | text="Cancelled. Your text is in $report_file if you wish to recover it." |
---|
| 108 | zenity --info --no-wrap --text="$text" |
---|
| 109 | exit |
---|
| 110 | fi |
---|
[2433] | 111 | |
---|
[23088] | 112 | if $sendmail < $report_file; then |
---|
| 113 | text="Thank you for your bug report." |
---|
| 114 | zenity --info --text="$text" |
---|
| 115 | else |
---|
[25582] | 116 | text="Failed to send the bug report! Please contact olc@mit.edu for" |
---|
[23088] | 117 | text="$text\nassistance. Your text is in $report_file" |
---|
[25582] | 118 | text="$text\nif you wish to recover it and submit it to $bugs_address" |
---|
[23088] | 119 | zenity --error --no-wrap --text="$text" |
---|
| 120 | fi |
---|
| 121 | else |
---|
[25582] | 122 | : ${EDITOR=nano} |
---|
| 123 | helpstr= |
---|
| 124 | case "$EDITOR" in |
---|
| 125 | nano|pico) |
---|
| 126 | helpstr="(Ctrl-O, then Enter to save; Ctrl-X to quit after saving)" |
---|
| 127 | ;; |
---|
| 128 | emacs) |
---|
| 129 | helpstr="(Ctrl-X, Ctrl-S to save; Ctrl-X, Ctrl-C to quit after saving)" |
---|
| 130 | ;; |
---|
| 131 | esac |
---|
[23088] | 132 | fmt << EOF |
---|
| 133 | |
---|
[25582] | 134 | After you press <Enter>, an editor will now open with the bug report |
---|
| 135 | form. Some fields have been filled out already. Please answer the |
---|
| 136 | numbered questions with as much detail as possible. |
---|
| 137 | Remember to save the file before exiting the editor. |
---|
| 138 | $helpstr |
---|
| 139 | |
---|
| 140 | Press <Enter> to continue. |
---|
[2433] | 141 | EOF |
---|
[25582] | 142 | read dummy |
---|
[23088] | 143 | $EDITOR "$report_file" |
---|
| 144 | while true; do |
---|
| 145 | fmt << EOF |
---|
[2433] | 146 | |
---|
[23088] | 147 | Please enter "send" to send the report, "edit" to re-edit it, or |
---|
| 148 | "quit" to quit. |
---|
| 149 | EOF |
---|
| 150 | echo -n ' --> ' |
---|
| 151 | read reply |
---|
| 152 | [ send = "$reply" ] && break |
---|
| 153 | [ quit = "$reply" ] && exit |
---|
| 154 | [ edit = "$reply" ] && $EDITOR "$report_file" |
---|
| 155 | done |
---|
[2433] | 156 | |
---|
[23088] | 157 | if $sendmail < $report_file; then |
---|
| 158 | echo "Thank you for your bug report." |
---|
| 159 | else |
---|
| 160 | fmt << EOF |
---|
[25582] | 161 | Failed to send the bug report! This shouldn't happen! |
---|
| 162 | Your text is in $report_file if you wish to recover it, |
---|
| 163 | and you can submit it to $bugs_address. |
---|
[23088] | 164 | EOF |
---|
| 165 | fi |
---|
| 166 | fi |
---|