summaryrefslogtreecommitdiffstats
path: root/notify-users
blob: 1b630379b68872efae79e49b542aae0cad08fe2b (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
#!/bin/bash

if [[ $# < 2 ]]; then
	echo "usage: $(basename "$0") <server> <subject>"
	exit
fi

server=$1
subject=$2

send_mails() {
	addr_file=$1
	subject=$2
	body=$3
	from="Florian Pritz <flo@xinu.at>"

	for addr in $(cat "$addr_file"); do
		msmtp -t <<EOF
Subject: $subject
From: $from
To: $addr
Date: $(date -R)

$body

EOF
	done
}

echo "Mail body: ^D to send"
body=$(cat)

if [[ "$body" == "" ]]; then
	body="No more information available."
fi

jabberwall.pl ~/"docs/$server/users/jabber" "$subject" "$body"
send_mails ~/"docs/$server/users/email" "$subject" "$body"