Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function getinfo
- {
- echo "" >> /tmp/mail.txt
- echo "Technical INFO:" >> /tmp/mail.txt
- echo "" >> /tmp/mail.txt
- hostname --ip >> /tmp/mail.txt
- free >> /tmp/mail.txt
- df -h >> /tmp/mail.txt
- echo "" >> /tmp/mail.txt
- echo "Asterisk STATUS: " >> /tmp/mail.txt
- service asterisk status >> /tmp/mail.txt
- echo "" >> /tmp/mail.txt
- echo "Centos8 STATUS: " >> /tmp/mail.txt
- systemctl status cockpit.socket >> /tmp/mail.txt
- echo "" >> /tmp/mail.txt
- echo "Registration's STATUS:" >> /tmp/mail.txt
- asterisk -rx "sip show peers" | grep -v Unspecified >> /tmp/mail.txt
- }
- dt=`date`
- host=($(hostname --ip | tr " " "\n"))
- if [ -n "$1" ]
- then
- echo "From: root@$host <automailer@asterisk.com>" > /tmp/mail.txt
- echo "To: Customer <$1>" >> /tmp/mail.txt
- echo "Subject: Новое событие на SIP сервере TrueIP $host" >> /tmp/mail.txt
- echo "Date: $dt" >> /tmp/mail.txt
- else
- echo ""
- echo "Using: ./sendmail TO MESSAGE [file to attach] [TECHINFO]"
- echo "Powered by iMiro Wrench. Saint-Petersburg, Russia, July 2020"
- echo ""
- exit 0
- fi
- if [ -n "$2" ]
- then
- echo "" >> /tmp/mail.txt
- echo $2 >> /tmp/mail.txt
- else
- echo "" >> /tmp/mail.txt
- echo "Something happens now on your SIP server." >> /tmp/mail.txt
- getinfo
- fi
- if [ -n "$3" ]
- then
- FILE=$1
- if [ -f "$FILE" ]; then
- echo "" >> /tmp/mail.txt
- echo "--------------------Attached file:--------------------" >> /tmp/mail.txt
- echo "" >> /tmp/mail.txt
- cat $3 >> /tmp/mail.txt
- echo "" >> /tmp/mail.txt
- echo "-----------------End of attached file:----------------" >> /tmp/mail.txt
- else
- getinfo
- fi
- fi
- echo "" >> /tmp/mail.txt
- echo "Best regards, TrueIP Team. Saint-Petersburg, Russia. 2020" >> /tmp/mail.txt
- if [ -n "$4" ]
- then
- getinfo
- fi
- curl --ssl-reqd \
- --url 'smtps://smtp.gmail.com:465' \
- --user 'timianalias@gmail.com:aa483861' \
- --mail-from 'automailer@asterisk.com' \
- --mail-rcpt `echo $1` \
- --upload-file /tmp/mail.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement