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 | subject=$(zenity --entry --text="$text") |
---|
36 | else |
---|
37 | echo "$text" || fmt |
---|
38 | echo -n ' --> ' |
---|
39 | read subject |
---|
40 | fi |
---|
41 | fi |
---|
42 | |
---|
43 | cat > $report_file << EOF |
---|
44 | To: $bugs_address |
---|
45 | Subject: Debathena Beta: $subject |
---|
46 | |
---|
47 | System name: $hostname |
---|
48 | Type: $cpu |
---|
49 | Display type: $dpy |
---|
50 | |
---|
51 | Shell: $shell |
---|
52 | Window manager: ${WINDOW_MANAGER:-unknown} |
---|
53 | |
---|
54 | What were you trying to do? |
---|
55 | [Please replace this line with your information.] |
---|
56 | |
---|
57 | What's wrong: |
---|
58 | [Please replace this line with your information.] |
---|
59 | |
---|
60 | What should have happened: |
---|
61 | [Please replace this line with your information.] |
---|
62 | |
---|
63 | Please describe any relevant documentation references: |
---|
64 | [Please replace this line with your information.] |
---|
65 | EOF |
---|
66 | |
---|
67 | if [ true = "$gnome" ]; then |
---|
68 | text="After you click OK, an editor window will appear with the bug report" |
---|
69 | text="$text contents. Please fill out the form, then save and exit. If" |
---|
70 | text="$text you change your mind, you will have a chance to cancel before" |
---|
71 | text="$text the bug report is sent." |
---|
72 | zenity --info --text="$text" |
---|
73 | gnome-text-editor "$report_file" |
---|
74 | # zenity doesn't let us specify the buttons on a question, and the |
---|
75 | # list dialog is awkward. So while we'd like to do something more |
---|
76 | # like what we do in the terminal case, we'll compromise a bit. |
---|
77 | question="Do you still want to send the bug report?" |
---|
78 | if ! zenity --question --text="$question"; then |
---|
79 | text="Cancelled. Your text is in $report_file if you wish to recover it." |
---|
80 | zenity --info --no-wrap --text="$text" |
---|
81 | exit |
---|
82 | fi |
---|
83 | |
---|
84 | if $sendmail < $report_file; then |
---|
85 | text="Thank you for your bug report." |
---|
86 | zenity --info --text="$text" |
---|
87 | else |
---|
88 | text="Failed to send the bug report! Please contact x3-4435 for" |
---|
89 | text="$text\nassistance. Your text is in $report_file" |
---|
90 | text="$text\nif you wish to recover it." |
---|
91 | zenity --error --no-wrap --text="$text" |
---|
92 | fi |
---|
93 | else |
---|
94 | fmt << EOF |
---|
95 | |
---|
96 | Please fill in the specified fields of the bug report form, which will |
---|
97 | be displayed momentarily. |
---|
98 | Remember to save the file before exiting the editor. |
---|
99 | EOF |
---|
100 | : ${EDITOR=emacs} |
---|
101 | $EDITOR "$report_file" |
---|
102 | while true; do |
---|
103 | fmt << EOF |
---|
104 | |
---|
105 | Please enter "send" to send the report, "edit" to re-edit it, or |
---|
106 | "quit" to quit. |
---|
107 | EOF |
---|
108 | echo -n ' --> ' |
---|
109 | read reply |
---|
110 | [ send = "$reply" ] && break |
---|
111 | [ quit = "$reply" ] && exit |
---|
112 | [ edit = "$reply" ] && $EDITOR "$report_file" |
---|
113 | done |
---|
114 | |
---|
115 | if $sendmail < $report_file; then |
---|
116 | echo "Thank you for your bug report." |
---|
117 | else |
---|
118 | fmt << EOF |
---|
119 | Failed to send the bug report! Please contact x3-4435 for assistance. |
---|
120 | Your text is in $report_file if you wish to recover it. |
---|
121 | EOF |
---|
122 | fi |
---|
123 | fi |
---|