How to create a backup of the firewall:
1 2 |
cd /opt/phion/config/configroot/ phionar cdl /tmp/$(date "+%Y%m%d")-$(hostname)-backup.par * |
How to build an email with attachment with bash and openssl:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#!/usr/bin/env bash # # Author: Brice Lilot FILE=/tmp/mail.txt DATE=$(date "+%a, %d %b %Y %H:%M:%S %z") SUBJECT="Firewall Backup" CUSTOMER="Customer" echo "HELO MAIL.CUSTOMER.TLD" > $FILE echo "MAIL FROM:<$FROM>" >> $FILE echo "RCPT TO:<$1>" >> $FILE echo "DATA" >> $FILE echo "From: Firewall $CUSTOMER <$FROM>" >> $FILE echo "To: <$1>" >> $FILE echo "Date: $DATE" >> $FILE echo "Subject: [$CUSTOMER] Firewall Backup - Done" >> $FILE echo "MIME-Version: 1.0" >> $FILE echo "Content-Type:multipart/mixed;boundary="boundary-yradnuob"" >> $FILE echo "--boundary-yradnuob" >> $FILE echo "Content-Type: text/plain; charset=us-ascii" >> $FILE cat <<<>>>$FILE Backup successful Date: $DATE Filename: $2 EOF echo "--boundary-yradnuob" >> $FILE echo "Content-Type: application/octet-stream;name="$2"" >> $FILE echo "Content-Transfer-Encoding:base64" >> $FILE echo "Content-Disposition:attachment;filename="$2"" >> $FILE openssl base64 > $FILE echo "" >> $FILE echo "" >> $FILE echo "." >> $FILE echo "QUIT" >> $FILE echo "" >> $FILE |
How to send an email via Netcat:
1 |
nc $SERVER $PORT < /tmp/mail.txt |