iniziato implementazione gestione eventi

This commit is contained in:
lejubila
2017-10-25 23:44:06 +02:00
parent c048337056
commit b3dae26372
9 changed files with 114 additions and 5 deletions

4
events/init_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*custom*
# Except this file
!.gitignore

31
events/scripts/sendmail.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
#
# Send mail on triggered event
#
# $1 = event
# $2 = cause
# $3 = time
#
# To send an email with this script you must install and configure ssmtp and mailutils:
# sudo apt-get install ssmtp mailutils
#
# edit the configuration file /etc/ssmtp/ssmtp.conf and insert the below lines:
#
# root=postmaster
# mailhub=smtp.gmail.com:587
# hostname=guard
# FromLineOverride=YES
# AuthUser=your_mail@gmail.com
# AuthPass=your_password
# UseSTARTTLS=YES
#
EVENT="$1"
CAUSE="$2"
TIME=$3
TO="mail@destination.com"
FROM="piGuardian@your_domain.com"
SUBJECT="piGuardian notification mail: $EVENT"
echo -e "PiGuardian triggered new event\n\nEVENT: $EVENT\nCAUSE: $CAUSE\nTIME: $(/bin/date -d@$TIME)" | /usr/bin/mail -s "$SUBJECT" $TO -r $FROM -A /home/pi/piGuardian/log/piGuardian.log

21
events/scripts/sendtelegram.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
#
# Send mail on triggered event
#
# $1 = event
# $2 = cause
# $3 = time
#
# To send an email with this script you must install telegram-cli @see http://tuxmaniacs.it/2015/01/installare-telegram-sul-raspberry-pi.html
#
EVENT="$1"
CAUSE="$2"
TIME=$3
TG_CLI="/home/pi/tg/bin/telegram-cli"
TO="Your_Destination_Contact"
CMD="msg $TO \"piGuardian triggered new event\\n\\nEVENT: $EVENT\\nCAUSE: $CAUSE\\nTIME: $(/bin/date -d@$TIME)\""
(sleep 1; echo "contact_list"; sleep 1; echo $CMD) | $TG_CLI -W