1 | #!/bin/sh |
---|
2 | # $Id: sendbug.sh,v 1.21 2003-07-30 19:16:12 zacheiss Exp $ |
---|
3 | |
---|
4 | visual=false |
---|
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 | |
---|
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) |
---|
31 | |
---|
32 | shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null` |
---|
33 | case $shell in |
---|
34 | $SHELL) |
---|
35 | ;; |
---|
36 | "") |
---|
37 | shell="$SHELL (?)" |
---|
38 | ;; |
---|
39 | *) |
---|
40 | shell="$shell ($SHELL?)" |
---|
41 | ;; |
---|
42 | esac |
---|
43 | |
---|
44 | if [ -z "$subject" ]; then |
---|
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 |
---|
48 | if ! subject=$(zenity --entry --text="$text"); then |
---|
49 | exit |
---|
50 | fi |
---|
51 | else |
---|
52 | echo "$text" || fmt |
---|
53 | echo -n ' --> ' |
---|
54 | read subject |
---|
55 | fi |
---|
56 | fi |
---|
57 | |
---|
58 | cat > $report_file << EOF |
---|
59 | To: $bugs_address |
---|
60 | Subject: Debathena: $subject |
---|
61 | |
---|
62 | System name: $hostname |
---|
63 | Type: $cpu |
---|
64 | Display type: $dpy |
---|
65 | |
---|
66 | Shell: $shell |
---|
67 | Window manager: ${WINDOW_MANAGER:-unknown} |
---|
68 | |
---|
69 | What were you trying to do? |
---|
70 | [Please replace this line with your information.] |
---|
71 | |
---|
72 | What's wrong: |
---|
73 | [Please replace this line with your information.] |
---|
74 | |
---|
75 | What should have happened: |
---|
76 | [Please replace this line with your information.] |
---|
77 | |
---|
78 | Please describe any relevant documentation references: |
---|
79 | [Please replace this line with your information.] |
---|
80 | EOF |
---|
81 | |
---|
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 |
---|
98 | |
---|
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 | |
---|
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 |
---|
115 | : ${EDITOR=emacs} |
---|
116 | $EDITOR "$report_file" |
---|
117 | while true; do |
---|
118 | fmt << EOF |
---|
119 | |
---|
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 |
---|
129 | |
---|
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 |
---|