From a25e4b35569bc4c08a26a2be54c2271e0531d9a0 Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Thu, 17 Oct 2013 09:04:01 +0200 Subject: [PATCH] Handle service upgrades. --- src/actions/main.queue | 4 +++- src/functions.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/actions/main.queue b/src/actions/main.queue index 313bcf0..27e03f6 100644 --- a/src/actions/main.queue +++ b/src/actions/main.queue @@ -32,10 +32,12 @@ pkg munin-cn upgrade_munin pkg freeradius-aai upgrade_freeradius pkg openldap-aai pkgadd openldap-aai pkg amavisd-new upgrade_amavis +pkg mysql-server-5.1 upgrade_mysql pkg apache2-cn upgrade_apache2 pkg postfix-cn upgrade_postfix +pkg dovecot-cn upgrade_dovecot pkg bind9-cn upgrade_bind -pkg mysql-cn upgrade_mysql +pkg fail2ban-cn upgrade_fail2ban true upgrade_postgresql true upgrade first # neki paketi moraju rucno true upgrade second # neke pakete zelimo ranije diff --git a/src/functions.sh b/src/functions.sh index 7037e0d..1e831f4 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -979,6 +979,44 @@ upgrade_postfix () { fi } +# upgrade the IMAP server +upgrade_dovecot() { + if [ ! -f /etc/dovecot/conf.d/95-local ]; then + pkgrm dovecot-cn + + # restore config + if [ ! -f /etc/dovecot/dovecot.conf.$backup_ext ]; then + mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.$backup_ext + cp /usr/share/dovecot/dovecot.conf /etc/dovecot/dovecot.conf + fi + + # copy SSL certificates + OLD_SSL_CERT="/etc/ssl/certs/dovecot.pem" + OLD_SSL_KEY="/etc/ssl/private/dovecot.pem" + SSL_CERT="/etc/dovecot/dovecot.pem" + SSL_KEY="/etc/dovecot/private/dovecot.pem" + if [ -f $OLD_SSL_CERT -a -f $OLD_SSL_KEY -a ! -f $SSL_CERT -a ! -f $SSL_KEY ]; then + if [ ! -e /etc/dovecot/private ]; then + install -d -o root -g root -m0700 /etc/dovecot/private + fi + + cp -av $OLD_SSL_CERT $SSL_CERT + cp -av $OLD_SSL_KEY $SSL_KEY + + chown root:dovecot $SSL_CERT + chmod 0644 $SSL_CERT + chown root:dovecot $SSL_KEY + chmod 0600 $SSL_KEY + fi + + # install new version and restore local changes + pkgadd dovecot-core + doveconf -n -c /etc/dovecot/dovecot.conf.$backup_ext > /etc/dovecot/conf.d/95-local + + pkgadd dovecot-cn + fi +} + # upgrade bind separately so DNS is not down for too long # or breaks postinst scripts of other cn packages that depend on # working resolver @@ -986,6 +1024,16 @@ upgrade_bind() { pkgadd bind9-cn } +# handle fail2ban upgrade due to error: +# trying to overwrite '/etc/fail2ban/filter.d/dovecot.conf', which is also in package fail2ban-cn +upgrade_fail2ban() { + if pkg fail2ban-cn && dpkg -L fail2ban-cn | grep -qF dovecot.conf; then + pkgrm fail2ban-cn + pkgadd fail2ban + pkgadd fail2ban-cn + fi +} + get_variable () { local name=$1 file=$2 val -- 1.7.10.4