preinst is in mail-stack-delivery 1:2.2.33.2-1ubuntu4.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #!/bin/sh
set -e
# Prepare to move a conffile without triggering a dpkg question
prep_mv_conffile() {
PKGNAME="$1"
CONFFILE="$2"
if [ -e "$CONFFILE" ]; then
md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
if [ "$md5sum" = "$old_md5sum" ]; then
rm -f "$CONFFILE"
else
if [ -e "$CONFFILE" ]; then
if [ "$CONFFILE" = "/etc/dovecot/conf.d/01-dovecot-postfix.conf" ]; then
mv -f "$CONFFILE" "/etc/dovecot/conf.d/01-mail-stack-delivery.conf"
fi
if [ "$CONFFILE" = "/etc/dovecot/auth.d/01-dovecot-postfix.auth" ]; then
mv -f "$CONFFILE" "/etc/dovecot/auth.d/01-mail-stack-delivery.auth"
fi
fi
fi
fi
}
case "$1" in
install|upgrade)
# Check if mail-stack-delivery.conf had any customizations
if [ -f "/usr/share/dovecot/mail-stack-delivery.conf" ]; then
if [ -f "/etc/dovecot/mail-stack-delivery.conf" ]; then
mv /etc/dovecot/mail-stack-delivery.conf /etc/dovecot/mail-stack-delivery.conf.bak
DIR=`mktemp -d`
egrep -v ^protocol /etc/dovecot/mail-stack-delivery.conf.bak > $DIR/mail-stack-delivery-custom.conf
egrep -v ^protocol /usr/share/dovecot/mail-stack-delivery.conf > $DIR/mail-stack-delivery.conf
if diff -qur $DIR/mail-stack-delivery-dist.conf $DIR/mail-stack-delivery-custom.conf 1>/dev/null 2>&1; then
rm -f /etc/dovecot/mail-stack-delivery.conf.bak
else
awk ' /^auth default/ {flag=1;next} /^}/{flag=0} flag { print }' /etc/dovecot/mail-stack-delivery.conf.bak > /etc/dovecot/auth.d/01-mail-stack-delivery.auth
awk ' /^## Dovecot conf/{flag=1} /^auth default/{flag=0} flag { print }' /etc/dovecot/mail-stack-delivery.conf.bak > /etc/dovecot/conf.d/01-mail-stack-delivery.conf
awk ' /^# If you wish to use another authentication server than dovecot-auth/{flag=1} flag { print }' /etc/dovecot/mail-stack-delivery.conf.bak >> /etc/dovecot/conf.d/01-mail-stack-delivery.conf
fi
rm -rf $DIR
fi
fi
# If we had the default 99-mail-stack-delivery.conf save it as it is
# potentially needed in postinst for a special case of the ssl transition
# from mail-stack-delivery to dovecot-core
if [ "$1" = "upgrade" ]; then
msdconf="/etc/dovecot/conf.d/99-mail-stack-delivery.conf"
oldsumdpkg=$(dpkg-query -W -f='${Conffiles}' mail-stack-delivery | \
sed -n -e "\' $msdconf ' { s/ obsolete$//; s/.* //; p }")
oldsumfile=$(md5sum "$msdconf" | cut -d' ' -f 1)
if [ "$oldsumdpkg" = "$oldsumfile" ]; then
# the existance of the unmodified file is the marker for postinst
# to retain it if 10-ssl.conf is not on the new default
cp -f "$msdconf" "$msdconf.olddefault"
fi
fi
;;
abort-upgrade)
# remove unconditionally on abort
rm -f /etc/dovecot/conf.d/99-mail-stack-delivery.conf.olddefault
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
|