summaryrefslogtreecommitdiff
path: root/setup-problem-reporting
blob: 0b24a307a4337b2eafb941d959b48ffb5dab0eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh

PREFIX=
. "$PREFIX/lib/libalpine.sh"

conf="$ROOT/etc/gnats/send-pr.conf"

cfgval() {
	awk -F= "/^$1/ {print \$2}" "$ROOT/etc/ssmtp/ssmtp.conf" 2>/dev/null
}

email=$(awk -F= '/^FROM/ {print $2}' "$conf" 2>/dev/null)

if [ -z "$email" ] ; then
	hostname=$(cfgval hostname)
	if [ -z "$hostname" ]; then
		hostname=$(hostname -f 2>/dev/null || cat /etc/hostname)
	fi
else
	hostname=$(hostname -f 2>/dev/null || cat /etc/hostname)
fi
domain=$(hostname -d $hostname 2>/dev/null)
if [ -n "$hostname" -a -z "$email" ] ; then
	email=$(whoami)@$hostname
fi

echon "Sender email address for problem reports? [$email] "
default_read email $email

if grep ^FROM "$conf" > /dev/null ; then
	sed -i "s/FROM.*/FROM=$email/" "$conf"
else
	echo "FROM=$email" >> "$conf"
fi

setup-mta

echo ""
echo "Please run 'send-pr' to submit problem reports"