X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Ffunctions.sh;h=c075a880b8086eb66359c542f43cea4a49b61535;hb=7a88bf24e860e4f1095fbf6da721e3c4f6ec265f;hp=8df87ccaf29fb2dbdf1bb807028ca909bb21bcfe;hpb=c55fb59772c28f9752b7daa78316e9358445264f;p=carnet-upgrade.git diff --git a/src/functions.sh b/src/functions.sh index 8df87cc..c075a88 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -367,7 +367,7 @@ check_upgrade () { if [ "$upgrade" ]; then notice " -Prije prelaska na Debian Squeeze potrebno je napraviti nadogradnju ovih paketa: +Prije prelaska na Debian Wheezy potrebno je napraviti nadogradnju ovih paketa: $upgrade Pokrenite: @@ -480,7 +480,9 @@ reboot_required () { running_version=$( uname -v ) log "Running kernel: $running_release $running_version" - if grep -q "$running_release .* $running_version" $default_kernel; then + if [ "$kernel_package" != "${kernel_package#linux-image-3.2.0-}" ] || + grep -q "$running_release .* $running_version" $default_kernel + then log "Latest kernel version is running." return 1 else @@ -693,78 +695,42 @@ restore_configs () { local hostname domain config_new memtotal memlimit # restore simple configs - if pkg ntp-cn && pkg ntp lt 1:4.2.6.p2+dfsg-1+b1; then + if pkg ntp-cn && pkg ntp lt 1:4.2.6.p5+dfsg-2; then if restore_file /etc/ntp.conf; then postupgrade_reconfigure ntp-cn fi fi - if pkg kernel-2.6-cn && pkg procps lt 1:3.2.8-9; then - if restore_file /etc/sysctl.conf; then - postupgrade_reconfigure kernel-2.6-cn - fi - fi - - if pkg kernel-2.6-cn && pkg libpam-modules lt 1.1.1-6.1; then - if restore_file /etc/security/limits.conf; then - postupgrade_reconfigure kernel-2.6-cn - fi - fi - - if pkg vsftpd-cn && pkg vsftpd lt 2.3.2-3+squeeze2; then + if pkg vsftpd-cn && pkg vsftpd lt 2.3.5-3; then if restore_file /etc/vsftpd.conf; then postupgrade_reconfigure vsftpd-cn fi fi - if pkg squirrelmail-cn && pkg squirrelmail lt 2:1.4.21-2; then - if restore_file /etc/squirrelmail/apache.conf; then - postupgrade_reconfigure squirrelmail-cn + if pkg amavisd-cn && pkg amavisd-new lt 1:2.7.1-2; then + if restore_file /etc/cron.d/amavisd-new; then + rm -f /etc/cron.d/amavisd-new.$backup_ext + postupgrade_reconfigure amavisd-cn fi fi - if pkg spamassassin-cn && pkg spamassassin lt 3.3.1-1; then - if restore_file /etc/spamassassin/v310.pre; then - postupgrade_reconfigure spamassassin-cn + if pkg ossec-hids lt 2.7-1; then + if restore_file /var/ossec/rules/local_rules.xml; then + postupgrade_reconfigure ossec-hids-cn fi fi - if pkg amavisd-cn && pkg amavisd-new lt 1:2.6.4-3; then - if restore_file /etc/cron.daily/amavisd-new; then - rm -f /etc/cron.daily/amavisd-new.$backup_ext - postupgrade_reconfigure amavisd-cn - fi - - if restore_file /etc/amavis/conf.d/15-av_scanners; then - rm -f /etc/amavis/conf.d/15-av_scanners.$backup_ext - postupgrade_reconfigure amavisd-cn + if pkg sasl2-bin lt 2.1.25.dfsg1-6+deb7u1; then + if restore_file /etc/default/saslauthd; then + postupgrade_reconfigure postfix-cn fi fi - if pkg amavisd-cn lt 3:2.6.5; then - restore_file /etc/init.d/amavisd-cn - rm -f /etc/init.d/amavisd-cn.$backup_ext - fi - - if pkg console-tools lt 1:0.2.3dbs-69.1; then - restore_file /etc/console-tools/config - fi - - if pkg base-files lt 6.0squeeze2; then + if pkg base-files lt 7.1wheezy2; then restore_file /etc/issue restore_file /etc/issue.net fi - if pkg slapd lt 2.4.23-7.2; then - restore_file /etc/default/slapd - fi - - # dovecot won't start with these options - if pkg dovecot-cn && pkg dovecot-common lt 1:1.2.15-7; then - sed -i 's/^\( *\)\(sieve\(_storage\)\?=.*\)/\1#\2/' \ - /etc/dovecot/dovecot.conf - fi - # check if monitrc is template based if [ -e /etc/monit/monitrc ]; then # monit is removed at this point # regenerate config from template @@ -895,17 +861,12 @@ pkgupgrade () { fi } -# make a silent upgrade to new libc6 -upgrade_libc () { - DEBIAN_FRONTEND=noninteractive pkgupgrade libc6 libc6-dev tzdata -} - # upgrade apache2/php5 upgrade_apache2 () { pkgrm apache-common # prevents installation of apache2-suexec pkgrm php5-suhosin # not available for wheezy pkgupgrade libapache2-mod-php5 php5-cli php5-cn apache2-cn \ - php5-odbc + php5-odbc mod-security-cn } upgrade_amavis () { @@ -925,35 +886,13 @@ upgrade_amavis () { /etc/init.d/amavisd-cn restart } -# handle freerdius upgrade -upgrade_freeradius () { - local password - - pkg freeradius-aai lt 2.1.12~srce1 || return 0 - - # aai team prevents a normal upgrade - cp -av /etc/freeradius /etc/freeradius.$backup_ext - pkgrm freeradius-aai freeradius-ldap freeradius - rm -rf /etc/freeradius/certs - pkgadd freeradius-aai - - # sync localhost passwords - if pkg libpam-radius-auth && [ -f "/etc/pam_radius_auth.conf" ]; then - pkgadd libpam-radius-auth - password=$( - sed -n '/^[[:space:]]*client[[:space:]]\+localhost/,/^[[:space:]]*}/ { /^[[:space:]]*secret[[:space:]]*=[[:space:]]*\([^[:space:]]*\)/s//\1/p }' /etc/freeradius/clients.conf - ) - if [ "$password" ] \ - && ! grep -q "^127.0.0.1\(:[[:digit:]]\+\)\?[[:space:]]\+$password[[:space:]]\+" \ - /etc/pam_radius_auth.conf - then - sed -i.$backup_ext "s/^\(127.0.0.1\(:[[:digit:]]\+\)\?[[:space:]]\+\)[^[:space:]]\+\(.*\)/\1$password\3/" /etc/pam_radius_auth.conf - fi - fi -} - # handle mysql 5.0 to 5.1 upgrade upgrade_mysql () { + # libc6-dev prevents mysql upgrade + if pkg libc6-dev; then + pkgrm libc6-dev + fi + if pkg mysql-server || pkg mysql-server-5.1; then pkgadd mysql-server dpkg -P mysql-server-5.1 @@ -977,6 +916,53 @@ upgrade_postfix () { fi } +# upgrade the IMAP server +upgrade_dovecot() { + local local_conf=/etc/dovecot/conf.d/95-${backup_ext}.conf + + if [ -f /etc/dovecot/conf.d/95-local -a ! -f $local_conf ]; then + mv /etc/dovecot/conf.d/95-local $local_conf + sed -i 's/\/usr\/lib\/dovecot\/modules\/imap/\/usr\/lib\/dovecot\/modules/g' $local_conf + /etc/init.d/dovecot restart + fi + + if [ ! -f $local_conf ]; 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 > $local_conf + sed -i 's/\/user\/lib\/dovecot\/modules\/imap/\/usr\/lib\/dovecot\/modules/g' $local_conf + + 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 @@ -984,6 +970,39 @@ 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 +} + +# manual upgrade of mailman to avoid two copies of mailman running +# first started by python upgrade and second started by mailman itself +upgrade_mailman() { + if pkg mailman-cn lt 2:2.1.15~cn0; then + /etc/init.d/mailman stop || true + pkgadd python + pkgadd mailman mailman-cn + fi +} + +# manual upgrade of kernel due to new packet name +upgrade_kernel() { + if pkg kernel-2.6-cn; then + pkgrm kernel-2.6-cn + + if pkg grub-pc; then + pkgadd kernel-cn grub-pc + else + pkgadd kernel-cn + fi + fi +} + get_variable () { local name=$1 file=$2 val @@ -995,6 +1014,12 @@ get_variable () { echo $val } +# switch to rsyslog +upgrade_syslog() { + pkgadd rsyslog + dpkg -P sysklogd klogd +} + # restore munin configs for silent upgrade upgrade_munin () { local config backup hostname domain @@ -1026,24 +1051,6 @@ upgrade_munin () { dpkg-reconfigure munin-cn } -# try not to overwrite user modified issue files -fix_issue () { - if cmp /etc/issue $cnup/files/etc/issue.expect.new >/dev/null; then - cp -av /etc/issue /etc/issue.$backup_ext - cat > /etc/issue </dev/null; then - cp -av /etc/issue.net /etc/issue.net.$backup_ext - cat > /etc/issue.net </dev/null \ - | grep -q '^kernel-2.6-cn is already the newest version.$' + if LC_ALL=C apt-get -s install kernel-cn 2>/dev/null \ + | grep -q '^kernel-cn is already the newest version.$' then - log "Not checking free space in /: kernel-2.6-cn already installed" + log "Not checking free space in /: kernel-cn already installed" return fi