X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Ffunctions.sh;h=46bb6f6fa9340635d70667556bed8b99cc476923;hb=9cca6edc89d02bb8820c4cb1b65707c38dab8758;hp=40378f90a2ef39a3b304e3c4bd337519c885aeb5;hpb=59888b246232e73ee4f9995f3a9a3f57b128c9b5;p=carnet-upgrade.git diff --git a/src/functions.sh b/src/functions.sh index 40378f9..46bb6f6 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -28,7 +28,7 @@ log() { # find first free uid/gid in range # find_id passwd 100 999 find_id() { - local db first last ids + local i db first last ids db=$1 first=$2 last=$3 @@ -129,8 +129,8 @@ dist_upgrade () { } remove_bloat() { - local to_remove add_this i j text to_show cmd tmpfile installed - local update_selections pkgs_to_deselect oldifs + local to_remove add_this i j n text to_show cmd tmpfile installed + local update_selections pkgs_to_deselect pkgs_to_remove oldifs pkglist text="$msg_remove_bloat" [ "$DEBUG" ] && set -x @@ -202,7 +202,7 @@ run_post_upgrade() { ### run_actions() { - local line lineno lineno2 f n name action testmsg + local line lineno lineno2 f n name action checkmsg check [ "$DEBUG" ] && set -vx name="$1" f="$2" @@ -226,16 +226,16 @@ run_actions() { lineno2=$(($lineno2+1)) line=$(echo -n "$line"| sed 's/\\$//'; head -$lineno2 "$f" | tail -1) done - test=$(echo "$line" | sed 's/ */ /g'| awk -F' ' '{print $1}') + check=$(echo "$line" | sed 's/ */ /g'| awk -F' ' '{print $1}') action=$(echo "$line" | sed 's/ */ /g'| awk -F' ' '{print $2}') - testmsg="" - [ "$test" != "true" ] && testmsg="if '$test'" - if eval $test; then - log "$(printf 'action %02d' $lineno) starting: '${action}' $testmsg " + checkmsg="" + [ "$check" != "true" ] && checkmsg="if '$check'" + if eval $check; then + log "$(printf 'action %02d' $lineno) starting: '${action}' $checkmsg " eval $action - log "$(printf 'action %02d' $lineno) finished: '${action}' $testmsg" + log "$(printf 'action %02d' $lineno) finished: '${action}' $checkmsg" else - log "$(printf 'action %02d' $lineno) skipping: '${action}' $testmsg" + log "$(printf 'action %02d' $lineno) skipping: '${action}' $checkmsg" fi [ "$lineno2" -gt "$lineno" ] && lineno=$lineno2 done @@ -286,7 +286,7 @@ check_apache_version () { if pkg apache-cn && ! pkg apache2-cn; then notice " -Prije prelaska na Debian Etch potrebno je napraviti nadogradnju sa apache 1.3 na apache 2.0. +Prije prelaska na Debian Etch potrebno je napraviti nadogradnju sa Apache 1.3 na Apache 2.0. Pokrenite: 'apt-get install apache2-cn' @@ -298,7 +298,7 @@ Nakon toga ponovno pozovite ovu skriptu." } upgrade () { - local to_install packages + local i to_install packages case "$1" in first) packages="$packages_first" @@ -488,6 +488,8 @@ restore_config () { # restore modified config to their package defaults # so the upgrade doesn't complain so much restore_configs () { + local config_backup + pkg base-files lt 4 && restore_config /etc/issue /etc/issue.net pkg bind9 lt 1:9.3.4 && restore_config /etc/bind/named.conf.options pkg libpam-modules lt 0.79 && restore_config /etc/security/limits.conf @@ -526,15 +528,18 @@ restore_configs () { done fi - # register cn changes in apache files - for config in /etc/php4/cgi/php.ini \ - /etc/php4/cli/php.ini \ - /etc/php4/apache/php.ini \ + # register cn changes in ucf managed files + for config in /etc/apache/modules.conf \ + /etc/clamav/clamd.conf \ + /etc/clamav/freshclam.conf \ /etc/php4/apache2/php.ini \ - /etc/apache/modules.conf + /etc/php4/apache/php.ini \ + /etc/php4/cgi/php.ini \ + /etc/php4/cli/php.ini do config_backup=$config.$backup_ext if [ -e $config -a ! -e $config_backup ]; then + log "Saving config file $config" cp -av $config $config_backup ucf $config_backup $config fi @@ -589,40 +594,36 @@ upgrade_libc () { DEBIAN_FRONTEND=noninteractive pkgadd libc6 } -# upgrade apache -> apache2 -upgrade_apache () { +# upgrade apache2 to etch +upgrade_apache2 () { + local package packages - # bugfix for apache2-cn postinst - mkdir -p /etc/apache2 - touch /etc/apache2/httpd.conf + # php-suhosin-cn causes removal of applications on dist-upgrade + # because of php5 only dependencies + pkgrm php-suhosin-cn - # temporary remove packages conflicting with apache2 - delpkg="" - for p in aosi-aai aosi-www-aai \ - php4-cn php4-odbc php4-xslt \ - squirrelmail-cn; do - - # remember installed packages - if pkg $p; then - delpkg="$delpkg $p" - fi + for package in \ + libapache2-mod-php4 \ + php4-cli \ + php4-cgi \ + php4-cn \ + apache2-cn \ + php4-odbc \ + php4-suhosin + do + if pkg $package; then + packages="$packages $package" + fi done - # remove (but not purge) problematic packages - if [ "$delpkg" ]; then - eval apt-get --yes remove $delpkg - fi - - # remove old apache - pkgrm apache apache-common - - # install new packages - eval pkgadd apache2-cn apache2-mpm-prefork \ - php4-cn libapache2-mod-php4 \ - $delpkg + for package in $packages; do + pkgadd $package + done } upgrade_amavis () { + local conf + # remove init script diversion if [ -L /etc/init.d/amavis -a -f /etc/init.d/amavis.amavisd-new ]; then rm -vf /etc/init.d/amavis @@ -630,7 +631,7 @@ upgrade_amavis () { fi # move old config aside - local conf=/etc/amavis/amavisd.conf + conf=/etc/amavis/amavisd.conf if [ -e $conf -a ! -e $conf.$backup_ext ]; then mv -v $conf $conf.$backup_ext fi @@ -649,16 +650,34 @@ upgrade_amavis () { # fix openldap-aai postinst user handling upgrade_openldap () { - #pkgrm openldap-cn # deprecated + # slapd postinst fails if this is false + echo 'slapd slapd/move_old_database boolean true' | debconf-set-selections + + # workaround for race condition in openldap-aai postinst apt-get -y$s install openldap-aai || true # postinst fails chown -R openldap:openldap /var/lib/ldap # fix slapd /etc/init.d/slapd restart dpkg --configure -a # try postinst again } +# fix postgresql deinstallation during upgrade +upgrade_postgresql () { + if check_services show 2>&1 | grep -qw postgresql; then + pkgadd postgresql || apt-get -f install + fi +} + +# upgrade the MTA +upgrade_postfix () { + pkgadd postfix-cn + + if pkg postgrey; then + pkgrm postgrey # not used by postfix-cn anymore + fi +} + get_variable () { - name=$1 - file=$2 + local name=$1 file=$2 val if [ -f "$file" ]; then val=$(sed -n "/^[[:space:]]*$name[[:space:]]*=/s/[[:space:]]*//gp" $file)