source /etc/sorcery/local/depends/postfix  &&

message "${MESSAGE_COLOR}If this is the first cast of postfix,"
message "you may want to run newaliases to make it work right now.${DEFAULT_COLOR}"

if  [  "$ALIAS"  ==  "n"  ];  then
  message "${MESSAGE_COLOR}Don't forget to run newaliases to apply your changes on the alias file.${DEFAULT_COLOR}"
else
  newaliases
fi  &&

# look for a backup file
backup_file=`ls -t -1 -r /etc/postfix-backup* | tail --lines=1`  &&

if  [  "$backup_file"  !=  ""  ];  then
  if  [  "$RESTORE"  ==  "n"  ];  then
    message "${MESSAGE_COLOR}Restore skipped. (you can still use $backup_file lather yourself)${DEFAULT_COLOR}"
  else
    message "${MESSAGE_COLOR}Restoring config files... ${DEFAULT_COLOR}"
    tar -C / -xjvPf $backup_file
  fi
else
  message "${MESSAGE_COLOR}No backup for config files found. ${DEFAULT_COLOR}"
fi  &&

#
# postfix 2.x.x new directives needed (at least) :
#
if  [  -e  /etc/postfix/master.cf  ];  then

  local     relayCheck=`cat /etc/postfix/master.cf | grep relay`     &&
  local  proxymapCheck=`cat /etc/postfix/master.cf | grep proxymap`  &&

  if  [  "$relayCheck"  ==  ""  ];  then
    if query "${MESSAGE_COLOR}The relay directive is missing in /etc/postfix/master.cf... Add it now ? ${DEFAULT_COLOR}" y
    then
      echo "# The next line was automatically added:" >> /etc/postfix/master.cf
      echo "relay     unix  -       -       n       -       -       smtp" >> /etc/postfix/master.cf
    fi
  fi  &&
  
  if  [  "$proxymapCheck"  ==  "" ];  then
    if query "${MESSAGE_COLOR}The proxymap directive is missing in /etc/postfix/master.cf... Add it now ? ${DEFAULT_COLOR}" y
    then
      echo "# The next line was automatically added:" >> /etc/postfix/master.cf
      echo "proxymap  unix  -       -       n       -       -       proxymap" >> /etc/postfix/master.cf
    fi
  fi
fi  &&

#
# SSL/TLS warnings
#
if [ "$SSL_TLS" == "y" ]; then
  message " "
  message "${MESSAGE_COLOR}About the TLS/SSL patch:"
  message "This patch is experimental."
  message " "
  message "Then there is one other thing that is extremly important when it comes to clients."
  message "TLS Will NOT work if you are on Windows and have Norton auto-protect enabled for"
  message "outgoing e-mail. It simply drops the STARTTLS command, which usually have fatal"
  message "implications on your client. ${DEFAULT_COLOR}"
  message " "
fi

#
# Postgresql tables info
#
#
#  The PostgreSQL patch is outdated
#
#if [ "$PGSQL" == "y" ]; then
#  message " "
#  message "${MESSAGE_COLOR}About the Postgresql patch:"
#  message "This patch is experimental."
#  message " "
#  message "This patch enables postfix to use postgresql as its lookup table. ie. You can use"
#  message "postgresql to store all data about virtual users and domains."
#  message "See /usr/doc/$SPELL/$NAME4 for some examples (They might be also used with some"
#  message "modifications with mysql database) ${DEFAULT_COLOR}"
#  message " "
#fi
