#!/bin/sh dir=$(mktemp -d /tmp/ticket2mail.XXXX) /usr/local/bin/fossil json timeline ticket --R /zdata/fossil/poudriere.fossil > ${dir}/tl.json now=$(TZ=UTC date +%s) min=$(( now - 2 )) bc=$(/usr/local/bin/jshon -e payload -e timeline -e 0 -e briefComment < ${dir}/tl.json | xargs echo) ts=$(/usr/local/bin/jshon -e payload -e timeline -e 0 -e timestamp < ${dir}/tl.json | xargs echo) user=$(/usr/local/bin/jshon -e payload -e timeline -e 0 -e user < ${dir}/tl.json | xargs echo) uuid=$(/usr/local/bin/jshon -e payload -e timeline -e 0 -e ticketUuid < ${dir}/tl.json | xargs echo) rm -rf ${dir} [ $ts -lt $min ] && exit tomail=$(echo "select content from ticket, concealed where tkt_uuid=\"${uuid}\" and ticket.private_contact=concealed.hash; select user.info from ticketchng, ticket, user where tkt_uuid=\"${uuid}\" and ticket.tkt_id = ticketchng.tkt_id and ticketchng.login=user.login and user.info glob '*@*' and user.login!=\"${user}\";" | /usr/local/bin/fossil sql -R /zdata/fossil/poudriere.fossil | sort -u) for m in ${tomail}; do /usr/sbin/sendmail -fbugs@etoilebsd.net ${m} << EOF Subject: [poudriere] ${bc} https://fossil.etoilebsd.net/poudriere/info/${uuid} EOF done