config() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

config etc/rc.d/rc.saslauthd.new
config usr/lib/sasl2/smtpd.conf.new

# if rc.local doesn't exist, create it
if [ ! -e etc/rc.d/rc.local ]; then
        echo "#!/bin/sh" > etc/rc.d/rc.local
        chmod 755 etc/rc.d/rc.local
fi

# if rc.saslauthd is executable, run it on startup
run=`grep ". /etc/rc.d/rc.saslauthd" etc/rc.d/rc.local`
if [[ "${run}" == "" ]]; then
cat << EOF >> etc/rc.d/rc.local

# To disable saslauthd, chmod rc.dbus to 644
if [ -x /etc/rc.d/rc.saslauthd ]; then
  echo "Starting SaSLAuthD"
  . /etc/rc.d/rc.saslauthd start
fi
EOF
fi
( cd usr/lib/sasl2 ; rm -rf libsasldb.so.2 )
( cd usr/lib/sasl2 ; ln -sf libsasldb.so.2.0.20 libsasldb.so.2 )
( cd usr/lib/sasl2 ; rm -rf libsasldb.so )
( cd usr/lib/sasl2 ; ln -sf libsasldb.so.2.0.20 libsasldb.so )
( cd usr/lib/sasl2 ; rm -rf libcrammd5.so.2 )
( cd usr/lib/sasl2 ; ln -sf libcrammd5.so.2.0.20 libcrammd5.so.2 )
( cd usr/lib/sasl2 ; rm -rf libcrammd5.so )
( cd usr/lib/sasl2 ; ln -sf libcrammd5.so.2.0.20 libcrammd5.so )
( cd usr/lib/sasl2 ; rm -rf libdigestmd5.so.2 )
( cd usr/lib/sasl2 ; ln -sf libdigestmd5.so.2.0.20 libdigestmd5.so.2 )
( cd usr/lib/sasl2 ; rm -rf libdigestmd5.so )
( cd usr/lib/sasl2 ; ln -sf libdigestmd5.so.2.0.20 libdigestmd5.so )
( cd usr/lib/sasl2 ; rm -rf libotp.so.2 )
( cd usr/lib/sasl2 ; ln -sf libotp.so.2.0.20 libotp.so.2 )
( cd usr/lib/sasl2 ; rm -rf libotp.so )
( cd usr/lib/sasl2 ; ln -sf libotp.so.2.0.20 libotp.so )
( cd usr/lib/sasl2 ; rm -rf libgssapiv2.so.2 )
( cd usr/lib/sasl2 ; ln -sf libgssapiv2.so.2.0.20 libgssapiv2.so.2 )
( cd usr/lib/sasl2 ; rm -rf libgssapiv2.so )
( cd usr/lib/sasl2 ; ln -sf libgssapiv2.so.2.0.20 libgssapiv2.so )
( cd usr/lib/sasl2 ; rm -rf libplain.so.2 )
( cd usr/lib/sasl2 ; ln -sf libplain.so.2.0.20 libplain.so.2 )
( cd usr/lib/sasl2 ; rm -rf libplain.so )
( cd usr/lib/sasl2 ; ln -sf libplain.so.2.0.20 libplain.so )
( cd usr/lib/sasl2 ; rm -rf libanonymous.so.2 )
( cd usr/lib/sasl2 ; ln -sf libanonymous.so.2.0.20 libanonymous.so.2 )
( cd usr/lib/sasl2 ; rm -rf libanonymous.so )
( cd usr/lib/sasl2 ; ln -sf libanonymous.so.2.0.20 libanonymous.so )
( cd usr/lib/sasl2 ; rm -rf sasl2 )
( cd usr/lib/sasl2 ; ln -sf /usr/lib/sasl2 sasl2 )
( cd usr/lib ; rm -rf libsasl2.so.2 )
( cd usr/lib ; ln -sf libsasl2.so.2.0.20 libsasl2.so.2 )
( cd usr/lib ; rm -rf libsasl2.so )
( cd usr/lib ; ln -sf libsasl2.so.2.0.20 libsasl2.so )
