Option to notify by mail

merge-requests/30/head
Bob Mottram 2021-03-09 10:50:47 +00:00
parent 794da93c52
commit 2bc4bdd15e
1 changed files with 51 additions and 38 deletions

View File

@ -29,6 +29,8 @@
PROJECT_NAME=epicyon
epicyonInstallDir=/opt/${PROJECT_NAME}
MY_EMAIL_ADDRESS="username@domain"
local_domain=$HOSTNAME
if [ -f /var/lib/tor/hidden_service_epicyon/hostname ]; then
local_domain=$(cat /var/lib/tor/hidden_service_epicyon/hostname)
@ -111,6 +113,8 @@ function sendNotification {
SUBJECT="$2"
MESSAGE="$3"
hasSent=
if [ -d /etc/prosody ]; then
if [ -f /usr/bin/sendxmpp ]; then
# generate a random password for a temporary user account
@ -126,6 +130,7 @@ function sendNotification {
kill_sendxmpp_process
# send the xmpp notification using the temporary account
echo "${MESSAGE}" | /usr/bin/sendxmpp -u notification -p "${notification_user_password}" -j localhost -o ${local_domain} --message-type=headline -n -t -s ${PROJECT_NAME} ${USERNAME}@${local_domain}
hasSent=1
fi
fi
# remove the temporary xmpp account
@ -135,6 +140,14 @@ function sendNotification {
if [ -d /etc/matrix ]; then
matrix_server_message "${USERNAME}" "${USERNAME}" "$MESSAGE"
hasSent=1
fi
if [ ! "$hasSent" ]; then
if [[ "$MY_EMAIL_ADDRESS" != "username@domain" ]]; then
# send to a fixed email address for a single user instance
echo "$MESSAGE" | /usr/bin/mail -s "$SUBJECT" "$MY_EMAIL_ADDRESS"
fi
fi
}