So I asked for some help on configuring mail.  There were many kind
soles on the leaf-user list that helped out.  From this, I have created
some mail functionality that may be useful to others.  So I'd like to
package it in a way that my changed files can be absorbed into the other
packages where they belong.  I think the most important accomplishment
that I made was that the mail functionality can be turned on and off in
the lrp.conf file.  This file is on a menu that an average user can get
to easily.  I looked at many other examples and the user had to get down
in the script and make changes.  However, I borrowed heavily from others
examples.  Ya know...."The first law of reverse engineering is to steal
the best."

I believe I fixed the cron path issue. I created a script to send
dynamic ip addresses to a list of email addresses.  I created a way to
send log files to a list of email addresses.  This is different than the
other email status emails.  I had to modify dhclient-exit-hooks,
multicron-d, lrp.conf, and created a new ipmail script.  The scripts
should be absorbed in dhclient.lrp, etc.lrp, etc.lrp, and root.lrp
respectfully.  At this point I am having trouble locating the correct
documentation, or I am not putting the information together correctly in
my head.

I have no preference to the names and they can be changed to more ideal
candidates.  Eventually I would hope that these ideas would wind up in a
LEAF distro or two.  I would hope that the package would exist until
taken over in this manor.  Here's what my design goal is
        lrpkg -i mailtool.lrp
        configure lrp.conf
        backup root.lrp
        backup etc.lrp
        backup dnclient.lrp

The first problem I am having is on my DCD102 system.  I put ipmail in
/usr/bin/ipmail.  I then performed a backup of root.lrp.  ipmail was not
in the backup.  I read the "LRP packaging details and limitations" FAQ
http://sourceforge.net/docman/display_doc.php?docid=1461&group_id=13751.
I tried to edit root's .list file and could not make my new file stick
in the backup.

So here are my list of newbie packaging questions?
        Is ipmail correctly located in /usr/bin?
        Should I first create a package and then install it?
        Are the file names ok?
        Are the variable names listed below ok?
        Are there any other shell script techniques that I should be
        following?
        Can files be absorbed in another package?

Below are the diffs.
Greg Morgan

[root@baloo orig]# diff -bu lrp.conf.new lrp.conf

--- lrp.conf.new        Sat May 25 23:15:02 2002
+++ lrp.conf    Sat May 25 22:57:15 2002
@@ -1,9 +1,6 @@
 #This is the master config file for systemwide LRP functions.
 #It is referenced by multicron-* and POSIXness.

-# Variables needed for programs launched by cron.
-SHELL=/bin/sh
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

 # Log files in /var/log/ to rotate. DEPTH == Amount to keep.
 lrp_LOGS_DAILY="daemon.log debug kern.log messages syslog user.log \
@@ -17,19 +14,6 @@

 # Email address to use for notices and alerts. If blank alerts won't be
sent.
 #lrp_MAIL_ADMIN="[EMAIL PROTECTED]"
-
-# Email address(es) to use for dynamic ip change alerts.  This is a
space
-# separated list, if you desire multiple people to receive this
notification.
-# If blank alerts won't be sent.
-#lrp_MAILIP_ADMIN="[EMAIL PROTECTED] [EMAIL PROTECTED]"
-lrp_MAILIP_SUBJECT="$HOSTNAME IP"
-lrp_MAILIP_SEARCH="My IP address is:"
-
-# Email address(es) to send log files.  This is a space separated list,
-# if you desire multiple people to receive this notification.
-# If blank alerts won't be sent.
-#lrp_MAILLOG_ADMIN="[EMAIL PROTECTED] [EMAIL PROTECTED]"
-lrp_MAILLOG_SUBJECT="$HOSTNAME log:"

 # Server that will be contacted via 'rdate' for the time service daily.
 # Turning this on also updates the CMOS clock

[root@baloo orig]# !:gs/lrp.conf/dhclient-exit-hooks/

diff -bu dhclient-exit-hooks.new dhclient-exit-hooks
--- dhclient-exit-hooks.new     Sat May 25 23:05:45 2002
+++ dhclient-exit-hooks Sat May 25 22:55:44 2002
@@ -9,8 +9,6 @@

 reload_all() {
   svi network ipfilter reload
-  # Mail ip address if configured in /etc/lrp.conf
-  [ -f /usr/bin/ipmail ] && /usr/bin/ipmail
 }

 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \

[root@baloo orig]# !:gs/dhclient-exit-hooks/multicron-d/

diff -bu multicron-d.new multicron-d
--- multicron-d.new     Sat May 25 23:07:47 2002
+++ multicron-d Sat May 25 22:58:49 2002
@@ -54,7 +54,6 @@
        cd /var/log
        for LOG in $LOGFILES; do
                if [ -f $LOG ]; then
-                       maillogs $LOG
                        savelog -g adm -m 640 -u root -c
${lrp_LOGS_DEPTH:-4} $LOG >/dev/null
                fi
        done
@@ -163,14 +162,6 @@
        fi
 }

-maillogs () {
-       if [ "$lrp_MAILLOG_ADMIN" != "" ]; then
-               for m in ${lrp_MAILLOG_ADMIN}; do
-                       mail -s "$lrp_MAILLOG_SUBJECT $1" "$m" < $1
-               done
-       fi
-}
-

 qt () { "$@" >/dev/null 2>&1 ; }

@@ -178,7 +169,6 @@
 TAB='  '
 SP=' '

-[ -f /etc/network.conf ] && . /etc/network.conf
 [ ! -f /etc/lrp.conf ] && exit 1
 . /etc/lrp.conf

[root@baloo orig]# cat ../ipmail
#!/bin/sh
#
# Ident: ipmail
#

# Uncomment set statement to debug.
#set -x

# This is the stuff you edit.

DAEMONLOG="/var/log/daemon.log"
IPMAILFILE="/tmp/ipmail.txt"
IPMAILMSG="/tmp/newmail.txt"
MASTCONF="/etc/lrp.conf"
NETCONF="/etc/network.conf"

#
# This is the stuff you don't touch.  You make your changes in
/etc/lrp.conf
# and /etc/POSIXness.conf.
#

#Bring in the network settings.
[ -f $NETCONF ] && . $NETCONF
#Bring in the master lrp settings.
[ -f $MASTCONF ] && . $MASTCONF

# Read in the old dynamic ip, if it exists.
if [ -f $IPMAILFILE ]; then
        OLDIP=`cat $IPMAILFILE`
else
        # This is the first execution so set the OLDIP address to a
        # bogus number.
        OLDIP='xxx.xxx.xxx.xxx'
fi

# EXTERN_IP comes from $NETCONF
# lrp_MAILIP_ADMIN comes from $MASTCONF
# lrp_MAILIP_SUBJECT comes from $MASTCONF
# lrp_MAILIP_SEARCH comes from $MASTCONF
# MAIL_SERVER configuration is performed in POSIXness.conf

if [ x${OLDIP} != x${EXTERN_IP} ]; then
        # If the lrp_MAILIP_ADMIN is blank, do not send notices but log
changes.
        if [ "$lrp_MAILIP_ADMIN" != "" ]; then
                [ -f $IPMAILMSG ] && rm $IPMAILMSG  # Clear the file.
                # Create the mail message text.
                echo ${lrp_MAILIP_SEARCH} ${EXTERN_IP} >> $IPMAILMSG
                # These are the mail options.
                #mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr]
to-addr...
                for m in ${lrp_MAILIP_ADMIN}; do
                        mail -s "${lrp_MAILIP_SUBJECT}" $m < $IPMAILMSG
                done
                [ -f $IPMAILMSG ] && rm $IPMAILMSG  # Clean up time.
        fi
        # Log the results for a change to the ip address.
        LOG_IT=`echo changed ${OLDIP} to ${EXTERN_IP}`
else
        # Log the results for no change to the ip address.
        LOG_IT=`echo ${EXTERN_IP} did not change`
fi

# Save the current ip for the next run.
[ -f $IPMAILFILE ] && rm $IPMAILFILE
echo ${EXTERN_IP} > $IPMAILFILE
# Log the results.
echo `date +"%b %d %T` ${HOSTNAME} ipmail: ${LOG_IT} >> $DAEMONLOG

[root@baloo orig]#

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm


_______________________________________________
Leaf-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to