So, I got disclaimers working on my edge assp boxes, problem though. If there are any forwards it is applying the disclaimer twice.

Here is the script that I got to work
Code:
#!/bin/sh
INSPECT_DIR=/var/spool/filter
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
LOCAL_DOMAIN1=domain1.com
LOCAL_DOMAIN2=domain2.com
RECIP=`echo $* | awk '{print $NF}'| tr [A-Z] [a-z]`
RECIP_DOMAIN=`echo $RECIP | awk -F"@" '{print $2}'`
SENDER=`echo $* | awk '{print $2}'| tr [A-Z] [a-z]`
SEND_DOMAIN=`echo $SENDER | awk -F"@" '{print $2}'`
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

cat > in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

if [ "$RECIP_DOMAIN" = "$SEND_DOMAIN" ]; then
/usr/bin/altermime --input=in.$$ \
                   --disclaimer=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt \
                   --disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt  \
                   --xheader="X-Copyrighted-Material:" || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }

elif [ "$SEND_DOMAIN" = "$LOCAL_DOMAIN2" ]; then
/usr/bin/altermime --input=in.$$ \
                   --disclaimer=/opt/zimbra/postfix/conf/disclaimers/domain2.txt \
                   --disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/domain2.txt \
                   --xheader="X-Copyrighted-Material: Please visit http://www.domain2.com/privacy.htm" || \
                   { echo Message content rejected; exit $EX_UNAVAILABLE; }

elif [ "$SEND_DOMAIN" = "$LOCAL_DOMAIN1" ]; then

/usr/bin/altermime --input=in.$$ \
                   --disclaimer=/opt/zimbra/postfix/conf/disclaimers/domain1.txt \
                   --disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/domain1.txt \
                   --xheader="X-Copyrighted-Material: Please visit http://www.domain1.com/privacy.htm" || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }

else


/usr/bin/altermime --input=in.$$ \
                   --disclaimer=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt \
                   --disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/emptydisclaimer.txt \
                   --xheader="X-Copyrighted-Material: " || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }


fi

$SENDMAIL -i "$@" <in.$$
exit $?
however this is one of a few scripts from this page Adding a disclaimer (altermime) or footer - Zimbra :: Wiki and it doesn't have a check for if the disclaimer already exists. There is a check for same domain which is cool but I want both.

the other script
Code:
#!/bin/sh
   INSPECT_DIR=/var/spool/filter
   SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
   FOLDER_DISCLAIMER=/opt/zimbra/postfix/conf
   DOMAIN="example.com"
   
   # Exit codes from <sysexits.h>
   EX_TEMPFAIL=75
   EX_UNAVAILABLE=69
   
   # Clean up when done or when aborting.
   trap "rm -f in.$$" 0 1 2 3 15
   
   # Start processing.
   cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
   
   TEXT_DISCLAIMER=`grep "[[:alnum:]]" ${FOLDER_DISCLAIMER}/disclaimer.txt | grep -v "_" | tail -4 | head -1`
   cat > in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }
   
   # Verify if is there the disclaimer present in the mail body
   grep -q "${TEXT_DISCLAIMER}" in.$$
   let R1="$?"
   
   # Verify if the sender is from DOMAIN
   #grep "From:" in.$$ | head -1 | grep -i $DOMAIN > /dev/null 2>&1
   echo "$2" | grep -i -q "$DOMAIN"
   let R2="$?"
   
   # Verify if the recipient is from DOMAIN
   echo "$4" | grep -i -q "$DOMAIN"
   let R3="$?"
   
   if [[ $R1 != 0 && $R2 == 0 && $R3 != 0 ]]; then
       /usr/bin/altermime --input=in.$$ \
                      --disclaimer=${FOLDER_DISCLAIMER}/disclaimer.txt \
                      --disclaimer-html=${FOLDER_DISCLAIMER}/disclaimer.html || \
                      { echo -e \n Message content rejected; exit $EX_UNAVAILABLE; }
   fi
   
   $SENDMAIL -i "$@" < in.$$
   
   exit $?
So, how do I check if the disclaimer already exists, and if it doesnt then add it?