]> pd.if.org Git - zpackage/blob - zpm-bug
add tlse header
[zpackage] / zpm-bug
1 #!/bin/sh
2
3 # program to submit a bug report
4
5 # TODO
6 # encrypt the report.  Use chacha20 and a public key
7 # for bug submissions.  This key will need to be set up
8 # for zoranix.  Should probably use the packager's public
9 # key as well.
10 #
11 # allow a bug report from stdin
12
13 set -e
14
15 [ -f /etc/rc.conf ] && . /etc/rc.conf
16 [ -f /etc/zoranix.conf ] && . /etc/zoranix.conf
17
18 name=$(logname)
19 host=$(hostname)
20 from=${REPLYTO:-${name}@${host}}
21
22 signature=
23 if [ -r $HOME/.signature ]; then
24         signature=$(cat $HOME/.signature)
25 else
26         signature=$(printf '-- \n%s\n' $name)
27 fi
28
29 # -n <note> -- make a bug report out of a note
30 file=$(mktemp ${TMPDIR:-/tmp}/bugreport-XXXXXX)
31
32 note=
33 package=${1:-general}
34 subject='zoranix bug report'
35
36 if [ "$1" = "-n" ]; then
37         shift
38         if [ $# -eq 0 ]; then
39                 rm $file
40                 usage
41         fi
42         note=$1
43         package=$(zpm note category $1)
44         subject=$(zpm note show $1 | head -1)
45         if [ $subject = "" ]; then
46                 subject='zoranix bug report'
47         fi
48 fi
49
50 cat >$file <<EOR
51 Subject: $subject
52 X-Package: $package
53 X-SupportId: $SUPPORTID
54 From: $from
55 To: ${BUGREPORTEMAIL:-bugreport@zoranix.net}
56
57 EOR
58
59 if [ -n "$note" ]; then
60         zpm note show $note > $file
61 elif [ -f /etc/zpm/bugtemplate ]; then
62         cat /etc/zpm/bugtemplate >> $file
63 else
64 cat >>$file <<EOR
65 Please write your bug report here.  This note will be submitted via
66 ${BUGSUBMITVIA:-https}.
67 EOR
68 fi
69
70 cat >>$file <<EOR
71
72 -- 
73 $signature
74 EOR
75
76 ${EDITOR:-vi} $file
77
78 # TODO encrypt the file, possibly sign
79 # if encrypted, should uuencode the lot
80
81 # submit the file to the bug destination
82
83 case ${BUGSUBMITVIA:-https} in
84         mail)
85                 mail -s 'zoranix bug report' ${BUGREPORTEMAIL:-bugreport@zoranix.net} < $file
86                 rm $file
87                 ;;
88         sendmail)
89                 sendmail ${BUGREPORTEMAIL:-bugreport@zoranix.net} < $file
90                 rm $file
91                 ;;
92         https)
93                 curl -F bug=@$file ${BUGREPORTDEST:-https://zoranix.net/bugreport.cgi}
94                 rm $file
95                 ;;
96         *)
97                 echo "zpm-bug: unknown submission method '${BUGSUBMITVIA:-smtp}'" 1>&2
98                 echo "a copy of your report is in $file" 1>&2
99                 exit 1;
100 esac