]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
notify.sh create
authorBastian Dehn <hhaalo@arcor.de>
Fri, 15 Jul 2016 19:38:11 +0000 (21:38 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 17 Jul 2016 07:34:36 +0000 (09:34 +0200)
password base64 encoded
functions for notifing

notify.sh [new file with mode: 0755]

diff --git a/notify.sh b/notify.sh
new file mode 100755 (executable)
index 0000000..6dd9306
--- /dev/null
+++ b/notify.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# default no notify
+# it will be set in .ablentohandy.conf
+NOTIFY=false
+
+MESSAGE=""
+# load all parameters to sendemail over smtp
+if [ ! -f $HOME/.albentohandy.conf ]
+then
+       printf "\nERROR\n.albentohandy.conf does not exist\n"
+       exit 1
+else
+       source $HOME/.albentohandy.conf
+fi
+
+# send email to notify user
+sendEmail()
+{
+if [ $NOTIFY == true ]
+then
+       sendemail -f $FROMADDRESS -t $TOADDRESS \
+-s $SMTP -xu $SMTPUSERNAME -xp $(echo $SMTPPASSWORD | base64 --decode) -o tls=yes \
+-u "albentohandy" -o message-content-type=html -m "$MESSAGE"
+fi
+}
+
+currentDate()
+{
+       MESSAGE="${MESSAGE}$(date +"%Y-%m-%d %H:%M:%S") "
+}
+
+openMail()
+{
+       MESSAGE="<html>\n \
+<head>\n \
+<title>albentohandy.sh notify</title>\n \
+</head>\n \
+<body>\n"
+}
+
+addInfo()
+{
+       MESSAGE="${MESSAGE}$1\n"
+}
+
+closeMail()
+{
+       MESSAGE="${MESSAGE}\n \
+</body>\n \
+</html>\n"
+}