Commit 1b783bf3 authored by Valentino Lauciani's avatar Valentino Lauciani
Browse files

Update email notification

parent c1b7e862
......@@ -231,25 +231,41 @@ configure_fail2ban()
send_email()
{
ARG_STRING=${1}
ARG_DATE=${2}
# coma separated
RECIPIENTS="valentino.lauciani@ingv.it"
# Set output
OUTPUT_TEXT="
SERVER_NAME: ${SERVER_NAME}
SERVER_IP: ${SERVER_IP}
"
if [[ "${ARG_STRIG}" == "Start" ]]; then
SUBJECT="Starting"
OUTPUT_TEXT="${OUTPUT_TEXT} \n DATE: ${ARG_DATE}"
else
SUBJECT="Created"
OUTPUT_TEXT="${OUTPUT_TEXT} \n DATE: ${ARG_DATE} \n \n OUTPUT: \n $( cat ${OUTPUTFILE} )"
fi
OUTPUT_TEXT=
/usr/sbin/sendmail -v "${RECIPIENTS}" <<EOF
subject:Azure - Started server "${SERVER_NAME}"
from:azure@azure.com
Subject:Azure - ${SUBJECT} new instance "${SERVER_NAME}"
From:azure@azure.com
DATA:$( date )
SERVER_NAME:${SERVER_NAME}
SERVER_IP:${SERVER_IP}
$( echo -e ${OUTPUT_TEXT} )
OUTPUT:
${OUTPUTFILE}
EOF
}
SEPLINE="============================================="
DATE_START=$( date +"%Y-%m-%d %H:%M:%S" )
send_email "Start" ${DATE_START} 2>&1 >> ${OUTPUTFILE}
echo "$SEPLINE" 2>&1 >> ${OUTPUTFILE}
date 2>&1 >> ${OUTPUTFILE}
echo "$@" 2>&1 >> ${OUTPUTFILE}
......@@ -262,6 +278,7 @@ configure_git $gitHostName $gitGroupName $gitRepoName $gitSshPrivateKey 2>&1 >>
configure_nginx $nginxUserName $nginxNumberOfWorkProcesses 2>&1 >> ${OUTPUTFILE}
configure_fail2ban 2>&1 >> ${OUTPUTFILE}
configure_iptables 2>&1 >> ${OUTPUTFILE}
send_email 2>&1 >> ${OUTPUTFILE}
DATE_END=$( date +"%Y-%m-%d %H:%M:%S" )
send_email "End" ${DATE_END} 2>&1 >> ${OUTPUTFILE}
cat $OUTPUTFILE
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment