1 | #!/bin/sh |
---|
2 | # $Id: sendbug.sh,v 1.21 2003-07-30 19:16:12 zacheiss Exp $ |
---|
3 | |
---|
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 |
---|
9 | fi |
---|
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) |
---|
18 | |
---|
19 | shell=`awk -F: '/^'$USER':/ { print $7; exit; }' /etc/passwd 2>/dev/null` |
---|
20 | case $shell in |
---|
21 | $SHELL) |
---|
22 | ;; |
---|
23 | "") |
---|
24 | shell="$SHELL (?)" |
---|
25 | ;; |
---|
26 | *) |
---|
27 | shell="$shell ($SHELL?)" |
---|
28 | ;; |
---|
29 | esac |
---|
30 | |
---|
31 | if [ -z "$subject" ]; then |
---|
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 |
---|
35 | if ! subject=$(zenity --entry --text="$text"); then |
---|
36 | exit |
---|
37 | fi |
---|
38 | else |
---|
39 | echo "$text" || fmt |
---|
40 | echo -n ' --> ' |
---|
41 | read subject |
---|
42 | fi |
---|
43 | fi |
---|
44 | |
---|
45 | cat > $report_file << EOF |
---|
46 | To: $bugs_address |
---|
47 | Subject: Debathena Beta: $subject |
---|
48 | |
---|
49 | System name: $hostname |
---|
50 | Type: $cpu |
---|
51 | Display type: $dpy |
---|
52 | |
---|
53 | Shell: $shell |
---|
54 | Window manager: ${WINDOW_MANAGER:-unknown} |
---|
55 | |
---|
56 | What were you trying to do? |
---|
57 | [Please replace this line with your information.] |
---|
58 | |
---|
59 | What's wrong: |
---|
60 | [Please replace this line with your information.] |
---|
61 | |
---|
62 | What should have happened: |
---|
63 | [Please replace this line with your information.] |
---|
64 | |
---|
65 | Please describe any relevant documentation references: |
---|
66 | [Please replace this line with your information.] |
---|
67 | EOF |
---|
68 | |
---|
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 |
---|
85 | |
---|
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 | |
---|
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 |
---|
102 | : ${EDITOR=emacs} |
---|
103 | $EDITOR "$report_file" |
---|
104 | while true; do |
---|
105 | fmt << EOF |
---|
106 | |
---|
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 |
---|
116 | |
---|
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 |
---|