Table of Contents
This section should be an help to use two special features of your LEAF Bering box namely the mail and cron facilities.
This document is maintained by Eric Wolzak <leaf at wolzak.de>
.
In the Bering root.lrp there is a mail command, which is one of the "POSIXness" script files. With this command you can send emails typed directly from the console or written as files. You can also send file attachment.
This command can only be used to send mail and differs substantially from the "real" linux mail command. In particular you cannot edit (read, delete, ..) mail from the firewall. As an alternative to this simple mail program you can use a real mailer program like qmail
The syntax of the Bering mail command is:
# mail Usage: mail options to[,...] Options: [-s subject] [-c cc[,...]] [-b bcc[,...]] [-a attachment[,...]] [-d domain] [-h smptserver]
-a attach text file(s)
-d specify from FQDN, overriding local domain
-h specify SMTP server, overriding the MAIL_SERVER setting
-v verbose
Mail default settings are set in /etc/POSIXness.conf
.
Please refer to the Bering installation guide (System configuration
section) for detailed instructions about default mail parameters
Through the System Configuration menu choose the (2) POSIXness Configuration entry. You will then be able to set the following options:
MAIL_SERVER: this is the SMTP server where mail is sending its mail to (e.g.MAIL_SERVER="smtp.myprovider.com")
MAIL_DOMAIN: this is the domain which will be shown in the from list (e.g. MAIL_DOMAIN="yourdomain.org" the FROM line will then be [email protected])
USER: this is the user you will use as the "part" before the @ sign for yourdomain.org. If you don't set a name here then the mail will be sent with the user the mail command is evoked or defaulting to root.If USER="john.doe", then your mail will be from: [email protected]
Be careful about the MAIL_DOMAIN definition as lots of smtp servers will refuse mails with a name they cannot resolve to a valid IP. Others refuse to relay mails that cannot be delivered locally.
To mail a message to someone edit a file with the editor (e.g. ae message), type your text and save the message file. Then to send your message:
cat message | mail -s "I want to tell you" to [email protected]
or as an attachement:
mail -s "I want to send you" -a "message" to [email protected]
You can also type your mail directly from the console:
mail -s "I want to send you" to [email protected]
Once you hit return, the console will wait for a message to be typed in. Once you have finished with your message input, type CTRL-D.
To mail the log and alerts files to the Bering box admin, set lrp_MAIL_ADMIN to the email address you want your logfiles sent to you. This parameter is found in the Master LRP settings entry of the System configuration menu
To be able to send mail from the firewall, you will need to open port TCP/25 of the firewall. In the shorewall rules file you will need to include the following statement:
ACCEPT fw net 25 tcp
The cronjobs are executed according to the entries defined in the
directories /etc/cron.d/
(every minute),
/etc/cron.daily
(every day), /etc/cron.weekly
and /etc/cron.monthly
.The most important part to add
things to is probably /etc/cron.d
. The syntax is the
standard syntax as is read in man cron and crontab.
#Periodic schedule for multicron. (Ping check, Space check, etc) #Default: Every 15 minutes */15 * * * * root /etc/multicron-p * * * * * root /bin/date >>/tmp/tijd */2 * * * * root /bin/beep -f 1200
In this example multicron-p is executed every fifteen minutes, date every minute etc. After changing the cronjob is updated automatically. You can verify this with
# tail -f /var/log/syslog Aug 18 09:15:01 firewall /USR/SBIN/CRON[28891]: (root) CMD (/etc/multicron-p) Aug 18 09:16:01 firewall /USR/SBIN/CRON[9097]: (root) CMD (/bin/beep) Aug 18 09:16:01 firewall /USR/SBIN/CRON[29944]: (root) CMD (/bin/date >>/tmp/tijd) Aug 18 09:16:01 firewall /usr/sbin/cron[1774]: (*system*multicron) RELOAD(/etc/cron.d/multicron)
Important is that you have one empty line after the last entry in the cron file. You can edit the multicron file as above or (probably a better idea) insert a new file with the syntax as before for each additional purpose.
An example for this could be:
#ls /etc/cron.d -rw-r--r-- 1 root root 211 Aug 18 09:15 multicron -rw-r--r-- 1 root root 93 Aug 18 09:13 closewindows -rw-r--r-- 1 root root 80 Aug 17 08:12 md5sumfiles