Sendmail & omsendin - how to change the configuration

Discuss the Scalix Server software

Moderators: ScalixSupport, admin

Shaun
Posts: 47
Joined: Mon Nov 12, 2007 10:54 am

Sendmail & omsendin - how to change the configuration

Postby Shaun » Mon Nov 12, 2007 11:25 am

Hi everyone.

I'm currently implementing a scalix community edition server (latest version as of 12th Nov 2007), and I'm hoping someone can help me with sendmail running on OpenSuSE 10.1

I've used sendmail extensively, and I'm used to m4 files. From what I understand from these newsgroups, there is a command called omsendin, which overwrites the current sendmail.cf with a scalix friendly one. I'd like to use my own modified sendmail.cf, as this particular box is for a satillite company and has no DNS, so I want to prevent DNS support. Can someone tell me what changes Scalix makes to the sendmail.cf file so I can place them in manually? - Or, if possible, let me know the changes you have to make to the m4 file!

Many Thanks

Shaun
Posts: 47
Joined: Mon Nov 12, 2007 10:54 am

Postby Shaun » Mon Nov 12, 2007 12:12 pm

I cheated - edited the omsendin script to read my version of the mc file. :lol:

skf
Posts: 40
Joined: Thu Sep 15, 2005 3:33 pm

Postby skf » Mon Nov 12, 2007 1:15 pm

Could you share your omsendin version.

Shaun
Posts: 47
Joined: Mon Nov 12, 2007 10:54 am

Postby Shaun » Tue Nov 13, 2007 6:37 am

Sure - it's nothing special though...

Code: Select all

#!/opt/scalix/bin/omposixsh
# GenVer = 11.0.4.10790

#
# Script to update the sendmail configuration file (for version 8.7 and lter)
# Since there are already commented-out lines for the sendmail configuration
# on HP-UX, there is special code to handle this.
#
# Copyright (C) 2003 Scalix Corporation.  All rights reserved.
# (c) Copyright Hewlett-Packard Company 1989-1995.  All Rights Reserved.
#
#
# Sccs_Id[] = "%W%";
#
#

#------ START --  set up Scalix shell variables  --------------#
if [ -f /opt/scalix/global/config ]
then
    # export OMCURRENT to any of the instances.
    # This is necessary for omgetmsg to work
    OMCURRENT=`omcheckgc -l | head -1`
    export OMCURRENT
fi

OMBIN=/opt/scalix/bin
PATH=$OMBIN:$PATH; export PATH

OPTBASE=`omeval dirname $OMBIN`

#------ END   --  set up Scalix shell variables  --------------#
# Sun's awk on Solaris does not have some newer features.
AWK=awk
[ -f /bin/nawk ] && AWK=/bin/nawk

#
# First try to find the required message catalog.
#

tempmsg=`omgetmsg -c mc_110 1 100`

if [ $? -ne 0 ]
then

    #
    # Current LANG failed, try default LANG...
    #

    LANG=`omeval omdeflang`
    export LANG
    usermsg=`omgetmsg -c mc_110 1 100`

    if [ $? -ne 0 ]
    then
        echo "Cannot open Message catalog" >&2
        echo "You must load at least one message catalog" >&2
        echo "and have your enviroment set correctly" >&2
        echo "before installing or running Scalix" >&2
        exit 30
    else
        omgetmsg 1 4450 >&2
    fi

fi

#------------------------------------------------------------------------------

#
# Ensure that the CORE package has been installed
#

if  [ ! -f `omrealpath '~/sys/install/OM-CORE.inst'` ] && \
    [ ! -f `omrealpath '~/sys/install/OM-CORE.fin'` ] || \
    [ ! -f $OMBIN/omsetsvc ] || \
    [ ! -f $OMBIN/omaddq ] || \
    [ ! -f $OMBIN/omeval ]
then
    # MSG : No core fileset installed.
    omgetmsg -c mc_110 1 600 `basename $0`
    exit 1
fi

#------------------------------------------------------------------------------

#
# Check user is root.
#

if [ `omeval whoami` != "root" ]
then
    # MSG : Must be root.
    omgetmsg -c mc_110 1 110
    exit 1
fi

#------------------------------------------------------------------------------

#
# Check that scalix user and scalix group exist.
#

if [ ! "`omeval pwget -n scalix`" ]
then

# MSG : No scalix user.
    omgetmsg -c mc_110 1 195 scalix
    omgetmsg -c mc_110 1 196
    exit 1
fi

if [ ! "`omeval grget -n scalix`" ]
then

# MSG : No scalix group.
    omgetmsg -c mc_110 1 199 scalix
    omgetmsg -c mc_110 1 196
    exit 1
fi

#------------------------------------------------------------------------------

SYSTYPE="`omeval omsystype`"
case $SYSTYPE in
    LINUX)
        # Red Hat Linux originally had /etc/sendmail.cf and
        # /usr/lib/sendmail, later versions move sendmail to /sbin and
        # sendmail.cf /etc/mail.  Red Hat 8.0 introduced submit.cf.
        # It's easy to cope with all this: we just look for what's
        # available and then edit it.
        if [ -f /etc/mail/sendmail.cf ]
        then SENDMAIL_CF=/etc/mail/sendmail.cf
        else SENDMAIL_CF=/etc/sendmail.cf
        fi
        if [ -f /etc/mail/sendmail.mc ]
        then SENDMAIL_MC=/etc/mail/sendmail.mc
        fi
        if [ -f /etc/mail/linux.mc ]
        then SENDMAIL_MC=/etc/mail/linux.mc
        fi
       
        ###################################################
        # Custom MC or CF Files - just change entries below
        # Comment out if not required...  Remember, MC is the
        # Input file, CF is the output file...
        #
        if [ -f /etc/mail/my_sendmail.mc ]
        then SENDMAIL_MC=/etc/mail/my_sendmail.mc
        fi
        #if [ -f /etc/mail/my_sendmail.cf ]
        #then SENDMAIL_CF=/etc/mail/my_sendmail.cf
        #fi
        #
        # End of custom MC or CF Files
        ###################################################

        if [ -f /usr/sbin/sendmail ]
        then SENDMAIL_PROG=/usr/sbin/sendmail
        else SENDMAIL_PROC=/usr/lib/sendmail
        fi
        ;;
    *)
        echo "Unexpected Platform type, giving up"
        exit 1
esac

#------------------------------------------------------------------------------

# Update Sendmail config. file.

OMCONF=`omrealpath '~/newconfig'`
export OMCONF

OM_SM_CF=$OMCONF/om_sendmail.cf
OM_SM_CF_BAK=$OMCONF/om_sm.cfBAK
TMP_SM_CF=$OMCONF/om_sendmail.c1   

if [ ! -f $SENDMAIL_CF ] || [  ! -f $SENDMAIL_PROG ]
then

    # "WARNING: [OMINST 246] Sendmail is not installed on your system so"
    # "WARNING: the sendmail configuration file $SENDMAIL_CF has not"
    # "WARNING: been updated for Scalix.  Install Sendmail and run"
    # "WARNING: $OMBIN/omsendin to update for Scalix."
    omgetmsg -c mc_110 1 246 $SENDMAIL_CF $OMBIN/omsendin
    exit 0
fi

# makeBackup [original] [backup-base]
makeBackup () {
    # select a name for the backup file that won't
    # involve deleting DIFFERENT previous backups.
    count=1
    while [ -f "$2$count" -a $count -lt 99 ]; do
        if cmp "$1" "$2$count" >/dev/null 2>&1
        then rm -f "$2$count"
        else count=$(($count+1))
        fi
    done
    mv -f "$1" "$2$count"
}


if [ -f $OM_SM_CF ]
then
    makeBackup "$OM_SM_CF" "$OM_SM_CF_BAK"
fi

if [ -n "$SUBMIT_CF" -a -f "$OMCONF/om_submit.cf" ]
then
    makeBackup "$OMCONF/om_submit.cf" "$OMCONF/om_submit.cf.BAK"
fi

cp $SENDMAIL_CF $OM_SM_CF
test -n "$SUBMIT_CF" && cp "$SUBMIT_CF" "$OMCONF/om_submit.cf"
FAILED="no"

#-----------------------------------------------------------------
#
# Delete the old openmail or scalix mailer lines if they're present as we
# may want to update them.
#
deleteOldConfigLines () {
    if test -n "$1" && egrep '\$# *(openmail|scalix)' "$1" >/dev/null
    then
        # there's something there, remove it
        if "$AWK" -f /opt/scalix/template/release.sys/smawk_rm "$1" > $TMP_SM_CF
        then mv $TMP_SM_CF "$1"
        else
            # can't find place for config lines (this isn't true, we
            # can't remove them but this is the message we have)
            omgetmsg -c mc_110 1 255 >&2
            return 1
        fi
    fi
    return 0
}



#-----------------------------------------------------------------
#  Add Scalix lines to sendmail.cf
#
# We use smawk to process the 8.7 sendmail.cf on some versions of AIX,
# otherwise 8.8 is the minimum acceptable version.
#
# No lines in current sendmail.cf.  Use awk to add Scalix lines.

addNewConfigLines () {
    test -f "$1" || return 0
    $AWK -f /opt/scalix/template/release.sys/smawk_8.7 "$1" > $TMP_SM_CF
    case $? in
        0) mv $TMP_SM_CF "$1"
           return 0
           ;;
        1) supplemental=271;;
        2) supplemental=272;;
        3) supplemental=273;;
        4) supplemental=274;;
        5) supplemental=275;;
        6) supplemental=276;;
        *) supplemental=270;;
    esac
    rm -f "$1"
    # MSG : Cannot find place for lines.
    omgetmsg -c mc_110 1 255
    omgetmsg -c mc_110 1 $supplemental
    # "WARNING: [OMINST 279] Modify $SENDMAIL_CF.  Use the script"
    # "WARNING:              $OMBIN/omsendin for guidance."
    omgetmsg -c mc_110 1 279 "$1" $OMBIN/omsendin
    return 1
}

#-----------------------------------------------------------------
# Modify cf file directly method

modifyCfDirect () {
    deleteOldConfigLines "$OM_SM_CF" || exit $?
    if [ -n "$SUBMIT_CF" ]
    then
        deleteOldConfigLines "$OMCONF/om_submit.cf" || exit $?
    fi

    addNewConfigLines "$OM_SM_CF" || exit $?

    # We used to use this with OpenMail long ago.  Let's just remove it.
    rm -f /etc/mail/omtables >/dev/null 2>&1

    # Add scalix to trusted-users if it exists
    if [ -f /etc/mail/trusted-users ]
    then
        grep scalix /etc/mail/trusted-users >/dev/null 2>&1 || echo scalix >> /etc/mail/trusted-users
    fi

}

#-----------------------------------------------------------------
# Modify cf file m4 method
modifyCfm4 () {
    grep "^MAILER(scalix)dnl" $SENDMAIL_MC >/dev/null 2>&1 || echo "MAILER(scalix)dnl" >> $SENDMAIL_MC

    m4 $SENDMAIL_MC > $OM_SM_CF
}

#----------------------------------------------------------------
# Start the modifications

if [ "$USE_OMMAPSMTP" == "TRUE" ]
then
    # Use the old style ommapsmtp system
    modifyCfDirect
else
    # Use the new style ldapmapper system and m4 config
    modifyCfm4
fi

# On SUSE we must switch off automatic generation of sendmail.cf from sysconfig
if [ -f /etc/sysconfig/mail ]
then
    sed -e 's/MAIL_CREATE_CONFIG="yes"/MAIL_CREATE_CONFIG="no"/' /etc/sysconfig/mail > $OMCONF/sysconfig.mail
    cp $OMCONF/sysconfig.mail /etc/sysconfig/mail
    echo "MAIL_CREATE_CONFIG set to 'no' in /etc/sysconfig/mail"
fi

#-----------------------------------------------------------------
# Now have a tailored copy of sendmail.cf for Scalix.
# We'll assume that if sendmail.cf wasn't changed, then submit.cf
# wasn't either -- this seems reasonable.
STRIPPED_SENDMAIL_CF=$(mktemp)
STRIPPED_OM_SM_CF=$(mktemp)

grep -v "^#" $SENDMAIL_CF > $STRIPPED_SENDMAIL_CF
grep -v "^#" $OM_SM_CF > $STRIPPED_OM_SM_CF

if cmp $STRIPPED_SENDMAIL_CF $STRIPPED_OM_SM_CF >/dev/null
then
    # MSG : sendmail.cf unchanged. Scalix lines already active.
    omgetmsg -c mc_110 1 251 $SENDMAIL_CF
else
    file="$OM_SM_CF"
fi
rm $STRIPPED_SENDMAIL_CF $STRIPPED_OM_SM_CF

# nothing to do?
if [ -z "$file" ]
then exit 0
fi


#-----------------------------------------------------------------
# MSG : NOTE : copy of sendmail.cf with Scalix changes now in
#       $OM_SM_CF.  Use $OMCONF/sm.update to install it.
omgetmsg -c mc_110 1 252 "$file" $OMCONF/sm.update
yes=$(omgetmsg -c mc_110 1 259)
no=$(omgetmsg -c mc_110 1 260)

# Setting environment variable '$OM_SMDEFER' to 'yes' or 'no' avoids
# questions at this point.  (ominstall now sets this to 'yes')

case Defer_$OM_SMDEFER in
    Defer_yes ) reply="$yes"  ;;
    Defer_no )  reply="$no"   ;;
    * )         reply="unset" ;;
esac

echo
if [ "$reply" = "unset" ]
then
    # MSG : Would you like to install the Scalix sendmail.cf file now (y/n)
    omgetmsg -c mc_110 1 253  $yes $no
    read reply
    echo
fi

until [ "$reply" = "$yes" ] || [ "$reply" = "$no" ]
do
    # MSG : Unexpected input.
    omgetmsg -c mc_110 1 256 $yes $no
    read reply
done

if  [ "$reply" = "$yes" ]
then
    # MSG : Executing.....
    omgetmsg -c mc_110 1 257 $OMCONF/sm.update
    $OMCONF/sm.update
    echo
fi

exit 0


Hope it helps someone... :wink:


Return to “Scalix Server”



Who is online

Users browsing this forum: No registered users and 2 guests

cron