]> Frank Brehm's Git Trees - config/helga/etc.git/commitdiff
Current state
authorFrank Brehm <frank@brehm-online.com>
Sat, 29 Jun 2013 07:02:55 +0000 (09:02 +0200)
committerFrank Brehm <frank@brehm-online.com>
Sat, 29 Jun 2013 07:02:55 +0000 (09:02 +0200)
postfix/get-checks-from-postfixbuch.sh

index 30955dde3319375ab5c4029faa20e59efd2b2997..0c04f527920670a514ad4f9be75a924cc01c0200 100755 (executable)
@@ -7,6 +7,7 @@ echo "[$( date )]: Checking for new versions of postfix checkfiles from »${BASE
 
 POSTFIX_DIR=/etc/postfix
 PF_MAP_DIR="${POSTFIX_DIR}/maps"
+OLDDIR="${PF_MAP_DIR}/old"
 RESTART_POSTFIX=
 
 cd ${PF_MAP_DIR} || exit 5
@@ -37,7 +38,14 @@ for FILE_BASE in body_checks header_checks; do
     fi
     echo "New version of »${FILE_BASE}«, substituting."
 
-    mv "${POSTFIX_FILE}" "${POSTFIX_FILE}.$( date -r ${POSTFIX_FILE} +'%Y-%m-%d_%H:%M:%S' )"
+    if [ ! -d "${OLDDIR}" ] ; then
+        echo "Creating »${OLDDIR}« ..."
+        mkdir -pv "${OLDDIR}"
+    fi
+
+    BAK_FILE="${OLDDIR}/${FILE_BASE}.$( date -r ${POSTFIX_FILE} +'%Y-%m-%d_%H:%M:%S' )"
+
+    mv -v "${POSTFIX_FILE}" "${BAK_FILE}"
     mv "${TMP_FILE}" "${POSTFIX_FILE}"
     RESTART_POSTFIX=y