mirror of
https://github.com/MailScanner/v5.git
synced 2024-11-10 17:35:06 +08:00
0a87daf349
* Initial Refactor for 5.1.4-1 * Reorder docs and patch processing * Explicit targets for copy * Update install phase of specs * Disable AutoReqProv * Update install splash * Refactor post install * Update README * Distinguish rhel and suse rpms in naming Clarify naming in README Log ms-configure to /var/log * Do not automatically enable mailscanner on debian builds Move notes in packages to end of ms-configure Alter notes in specs to notify user to run ms-configure * Correct package name in copy * Move mtagroup creation back to spec * patch.diff no longer valid * Remove patch.diff from spec and build * Bump to version 5.2.1-1 for major changes * ATTENTION block added to README * Cosmetic changes to README * Tab cleanup of README * Revert not enabling mailscanner during install * Explicit destination file for copy on suse builds * Reorder doc copies for tarballing * Remove unneeded subdirectory in suse build * 5.2.1-1 Builds
190 lines
6.3 KiB
Bash
190 lines
6.3 KiB
Bash
#!/bin/sh
|
|
# postinst script for MailScanner
|
|
#
|
|
# see: dh_installdeb(1)
|
|
|
|
set -e
|
|
|
|
# summary of how this script can be called:
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
# <new-version>
|
|
# * <postinst> `abort-remove'
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
# <failed-install-package> <version> `removing'
|
|
# <conflicting-package> <version>
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
# the debian-policy package
|
|
|
|
# save directory
|
|
SAVEDIR="$HOME/ms_upgrade/saved.$$";
|
|
|
|
# group for users to run under
|
|
if ! getent group mtagroup >/dev/null 2>&1; then
|
|
groupadd -f mtagroup >/dev/null 2>&1
|
|
fi
|
|
|
|
if [ ! -d '/var/spool/MailScanner/archive' ]; then
|
|
mkdir -p /var/spool/MailScanner/archive
|
|
chmod 775 /var/spool/MailScanner/archive
|
|
chown root:mtagroup /var/spool/MailScanner/archive
|
|
fi
|
|
|
|
if [ ! -d '/var/spool/MailScanner/incoming' ]; then
|
|
mkdir -p /var/spool/MailScanner/incoming
|
|
chmod 775 /var/spool/MailScanner/incoming
|
|
chown root:mtagroup /var/spool/MailScanner/incoming
|
|
fi
|
|
|
|
if [ ! -d '/var/spool/MailScanner/quarantine' ]; then
|
|
mkdir -p /var/spool/MailScanner/quarantine
|
|
chmod 775 /var/spool/MailScanner/quarantine
|
|
chown root:mtagroup /var/spool/MailScanner/quarantine
|
|
fi
|
|
|
|
if [ ! -d '/var/spool/MailScanner/milterin' ]; then
|
|
mkdir -p /var/spool/MailScanner/milterin
|
|
chmod 775 /var/spool/MailScanner/milterin
|
|
chown root:mtagroup /var/spool/MailScanner/milterin
|
|
fi
|
|
|
|
if [ ! -d '/var/spool/MailScanner/milterout' ]; then
|
|
mkdir -p /var/spool/MailScanner/milterout
|
|
chmod 775 /var/spool/MailScanner/milterout
|
|
chown root:mtagroup /var/spool/MailScanner/milterout
|
|
fi
|
|
|
|
# lock down some directory permissions
|
|
runasuser="mail"
|
|
if [ -x /usr/sbin/ms-peek ]; then
|
|
runasuser=`/usr/sbin/ms-peek runasuser /etc/MailScanner/MailScanner.conf`
|
|
fi
|
|
if [ -z $runasuser ]; then
|
|
runasuser="mail"
|
|
fi
|
|
install -d -o$runasuser -gmtagroup -m0775 /var/spool/MailScanner/archive
|
|
install -d -o$runasuser -gmtagroup -m0775 /var/spool/MailScanner/incoming
|
|
install -d -o$runasuser -gmtagroup -m0775 /var/spool/MailScanner/quarantine
|
|
install -d -o$runasuser -gmtagroup -m0775 /var/spool/MailScanner/milterin
|
|
install -d -o$runasuser -gmtagroup -m0775 /var/spool/MailScanner/milterout
|
|
|
|
if [ -d '/etc/MailScanner/custom' -o -L '/etc/MailScanner/custom' ]; then
|
|
rm -f /etc/MailScanner/custom
|
|
fi
|
|
|
|
# softlink for custom functions
|
|
if [ -d '/usr/share/MailScanner/perl/custom' -a ! -L '/etc/MailScanner/custom' ]; then
|
|
ln -s /usr/share/MailScanner/perl/custom /etc/MailScanner/custom
|
|
fi
|
|
|
|
# softlink for reports
|
|
if [ -d '/usr/share/MailScanner/reports' -a ! -L '/etc/MailScanner/reports' ]; then
|
|
ln -s /usr/share/MailScanner/reports /etc/MailScanner/reports
|
|
fi
|
|
|
|
# remove old link if present
|
|
if [ -L '/etc/mail/spamassassin/mailscanner.cf' ]; then
|
|
rm -f /etc/mail/spamassassin/mailscanner.cf
|
|
fi
|
|
|
|
if [ -L '/etc/mail/spamassassin/MailScanner.cf' ]; then
|
|
rm -f /etc/mail/spamassassin/MailScanner.cf
|
|
fi
|
|
|
|
if [ -f '/etc/MailScanner/spam.assassin.prefs.conf' ]; then
|
|
mv -f /etc/MailScanner/spam.assassin.prefs.conf /etc/MailScanner/spamassassin.conf
|
|
fi
|
|
|
|
# remove old symlink if present
|
|
if [ -L '/etc/init.d/mailscanner' ]; then
|
|
rm -f /etc/init.d/mailscanner
|
|
fi
|
|
|
|
# remove old file if present
|
|
if [ -f '/etc/init.d/mailscanner' ]; then
|
|
rm -f /etc/init.d/mailscanner
|
|
fi
|
|
|
|
# remove old symlink if present
|
|
if [ -L '/etc/init.d/MailScanner' ]; then
|
|
rm -f /etc/init.d/MailScanner
|
|
fi
|
|
|
|
# remove old file if present
|
|
if [ -f '/etc/init.d/MailScanner' ]; then
|
|
rm -f /etc/init.d/MailScanner
|
|
fi
|
|
|
|
# remove old symlink if present
|
|
if [ -L '/etc/init.d/msmilter' ]; then
|
|
rm -f /etc/init.d/msmilter
|
|
fi
|
|
|
|
# remove old file if present
|
|
if [ -f '/etc/init.d/msmilter' ]; then
|
|
rm -f /etc/init.d/msmilter
|
|
fi
|
|
|
|
# remove old systemd file if present
|
|
if [ -f '/lib/systemd/system/mailscanner.service' ]; then
|
|
rm -f /lib/systemd/system/mailscanner.service
|
|
fi
|
|
|
|
# remove old systemd file if present
|
|
if [ -f '/lib/systemd/system/msmilter.service' ]; then
|
|
rm -f /lib/systemd/system/msmilter.service
|
|
fi
|
|
|
|
# Check for systemd
|
|
if [ -f '/lib/systemd/systemd' -o -f '/usr/lib/systemd/systemd' ]; then
|
|
cp /usr/lib/MailScanner/systemd/ms-systemd /lib/systemd/system/mailscanner.service
|
|
chmod -x /lib/systemd/system/mailscanner.service
|
|
cp /usr/lib/MailScanner/systemd/ms-milter /lib/systemd/system/msmilter.service
|
|
chmod -x /lib/systemd/system/msmilter.service
|
|
# add symlink to init script
|
|
elif [ ! -L '/etc/init.d/mailscanner' ]; then
|
|
ln -s /usr/lib/MailScanner/init/ms-init /etc/init.d/mailscanner
|
|
ln -s /usr/lib/MailScanner/init/msmilter-init /etc/init.d/msmilter
|
|
fi
|
|
|
|
# create if missing
|
|
[ -d '/etc/MailScanner/conf.d' ] || mkdir -p /etc/MailScanner/conf.d
|
|
|
|
# upgrade the old config
|
|
if [ -f /etc/MailScanner/MailScanner.conf.original -a -f /etc/MailScanner/MailScanner.conf ]; then
|
|
cp -f /etc/MailScanner/MailScanner.conf /etc/MailScanner/MailScanner.conf.dist
|
|
ms-upgrade-conf /etc/MailScanner/MailScanner.conf.original /etc/MailScanner/MailScanner.conf.dist > /etc/MailScanner/MailScanner.conf
|
|
mkdir -p ${SAVEDIR}/etc/MailScanner
|
|
mv -f /etc/MailScanner/MailScanner.conf.* ${SAVEDIR}/etc/MailScanner > /dev/null 2>&1
|
|
cp -f /etc/MailScanner/MailScanner.conf ${SAVEDIR}/etc/MailScanner/MailScanner.new > /dev/null 2>&1
|
|
fi
|
|
|
|
# update web bug link
|
|
OLD="^Web Bug Replacement.*";
|
|
NEW="Web Bug Replacement = https\:\/\/s3\.amazonaws\.com\/msv5\/images\/spacer\.gif";
|
|
if [ -f '/etc/MailScanner/MailScanner.conf' ]; then
|
|
sed -i "s/${OLD}/${NEW}/g" /etc/MailScanner/MailScanner.conf
|
|
fi
|
|
|
|
# fix reports directory
|
|
OLDTHING='\/etc\/MailScanner\/reports';
|
|
NEWTHING='\/usr\/share\/MailScanner\/reports';
|
|
if [ -f '/etc/MailScanner/MailScanner.conf' ]; then
|
|
sed -i "s/${OLDTHING}/${NEWTHING}/g" /etc/MailScanner/MailScanner.conf
|
|
fi
|
|
|
|
# fix custom functions directory
|
|
OLDTHING='^Custom Functions Dir.*';
|
|
NEWTHING='Custom Functions Dir = \/usr\/share\/MailScanner\/perl\/custom';
|
|
if [ -f '/etc/MailScanner/MailScanner.conf' ]; then
|
|
sed -i "s/${OLDTHING}/${NEWTHING}/g" /etc/MailScanner/MailScanner.conf
|
|
fi
|
|
|
|
if [ -f '/lib/systemd/systemd' -o -f '/usr/lib/systemd/systemd' ]; then
|
|
systemctl enable mailscanner.service
|
|
else
|
|
update-rc.d mailscanner defaults 80 80
|
|
fi
|
|
|
|
exit 0
|