• Inviting everyone who uses WordPress management tools in Plesk
    The Plesk team is conducting a 60-minute research session that includes an interview and a moderated usability test.
    To participate, please use this link .
    Your experience will help shape product decisions and ensure the tools better support real-world use cases.

Input Mail-Headers?

Just follow that recipe!
I don't agree that such info is sensitive, but hey, everyone has their right for paranoia.

There's no way (AFAIK) to prevent Plesk from rewriting main.cf and master.cf, but it doesn't do it as often as it did in the past.

I have a monitoring system that will alert me that this file has changed.
I have a cronjob that will save the complete /etc/postfix in a compressed tar-file if it ever changes.
It has the advantage that you will find out if Plesk has been improved or that it just killed your custom setup.

cat /etc/cron.hourly/taretcs
Code:
#!/bin/bash

tarfolder /etc/postfix
tarfolder /etc/courier-imap
tarfolder /etc/dovecot

cat /usr/local/sbin/tarfolder
Code:
#!/bin/bash

# Strip last slash..
DATESTAMP=`date +%Y-%m-%d.%H-%M`
HEADLESS=
tty >/dev/null || HEADLESS=true

GLOB=
SUFFIX=
while getopts d opt ; do
  case $opt in
    d)   GLOB='/*(.)' ;;
    ?)   printf "Usage: %s: [-d] <folder>\n" $0
    exit 2;;
  esac
done
shift `expr ${OPTIND} - 1`

[ -z "${GLOB}" ] || SUFFIX="_NoSubfolders"

FOLDER="`echo ${1} | sed 's/\/$//'`"
[ -d "${FOLDER}" ] || exit 1

if ! echo "${FOLDER}" | grep -q '^/' ; then
  FOLDER="`realpath ${FOLDER} 2>/dev/null`"
  if [ -z "${FOLDER}" ] ; then
    echo "You need to use an absolute path (or install readlink => apt-get instatll readlink)" >&2
    exit 1
  fi
fi

DIRFILE=`echo ${FOLDER} | tr '/ ' '.' | tr -s '.'`
TMPDIR=`mktemp -t -d ${0//*\/}.XXXXXXXXXX`

if cd ${TMPDIR} ; then
  TGZ="${TMPDIR}/.${DIRFILE}.${DATESTAMP}.tgz"

  tar cpzf "${TGZ}" "${FOLDER}${GLOB}" --exclude=*.tgz >/dev/null 2>&1
  LATEST_TGZ=`find "${FOLDER}" -maxdepth 1 -type f | \
                   grep "${DIRFILE}.*\.tgz" | xargs -I{} stat -c '%Y %n' {} | \
                   sort -rn | head -n1 | awk '{print $2}'`

  if [ -z "${LATEST_TGZ}" ] ; then
    [ ${HEADLESS} ] || echo "First tgz" >&2
    mv "${TGZ}" "${FOLDER}/"
  else
    mkdir ${TMPDIR}/f1
    mkdir ${TMPDIR}/f2
    if tar xzf "${LATEST_TGZ}" -C ${TMPDIR}/f1  >/dev/null 2>&1 ; then
      if tar xzf "${TGZ}" -C ${TMPDIR}/f2  >/dev/null 2>&1 ; then
        if diff -r ${TMPDIR}/f1  ${TMPDIR}/f2 >/dev/null 2>&1 ; then
          [ ${HEADLESS} ] || echo "Folder \"${FOLDER}\" hasn't changed.... I will discard this tgz" >&2
        else
          if [ ! ${HEADLESS} ] ; then
            echo "Last tgz is different" >&2
            diff -r ${TMPDIR}/f1  ${TMPDIR}/f2
          fi
          mv "${TGZ}" "${FOLDER}/"
        fi
      fi
    fi
  fi
fi
rm -rf ${TMPDIR}
 
Last edited:
Back
Top