Boot, ur og email

Når BBB starter op vil jeg have den til at stille uret og sende mig en email.

1. Installer exim4 (email program):

apt-get update
apt-get install exim4

2. konfigurer exim4:

dpkg-reconfigure exim4-config

Mail Server: “mail sent by smarthost; no local mail”
Mail Server configuration: “smtp.altiboxmail.dk”

/etc/exim4/update-exim4.conf.conf

dc_eximconfig_configtype='satellite'
dc_other_hostnames='beaglebone.localdomain'
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost='beaglebone.localdomain'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.altiboxmail.dk'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

3. opret script til at sende email:
nano /root/emailnotify.sh

#!/bin/bash
#sleep 60
IP=`hostname -I`
HOSTNAME=`hostname -f`
echo "$HOSTNAME online. IP address: $IP" > /root/email.txt
echo >> /root/email.txt
date >> /root/email.txt
mail -s "$HOSTNAME online" -r root@$HOSTNAME max@max-it.dk < /root/email.txt
#cat /root/email.txt
rm -rf /root/email.txt
 

4. Opdater ur og kør email-script:

nano /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# update clock
ntpdate -b -s -u pool.ntp.org

# email
/root/emailnotify.sh

exit 0

5. genstart

reboot

6. Kontrol:

tail /var/log/exim4/mainlog

Skriv et svar

This site uses Akismet to reduce spam. Learn how your comment data is processed.