X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Ffunctions.sh;h=22ba7a6346d640a86e3b9dda127d12de9fb9f98d;hb=4ed1f8879ea142ce18774c32b69cad2a365a9b7d;hp=7b9eae40e8cd9ac829431395352eebed83514ff0;hpb=6a3a2c168191ec411b938cc271535e692003dc2c;p=carnet-upgrade.git diff --git a/src/functions.sh b/src/functions.sh index 7b9eae4..22ba7a6 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,11 +129,12 @@ 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 + n=0 pkglist=$(mktemp /var/lib/carnet-upgrade/pkglist.XXXXXX) COLUMNS=200 dpkg -l | awk '$1 ~ /^.i/ { print $2 }' > $pkglist for i in $(echo "$bloats" | sed 's/ */ /g'| awk -F' ' '{print $2}') @@ -143,13 +144,15 @@ remove_bloat() { add_this="$(echo "$bloats" | egrep " .*\b${i}\b" | sed 's/ */ /g'| awk -F' ' '{print $1}')" if ! echo "$to_show" | grep -q "$add_this"; then to_show="$to_show \"$add_this\" \"\" on" + n=$(($n+1)) fi fi done [ "$DEBUG" ] || rm -f $pkglist [ -z "$to_show" ] && return 0 + test $n -gt 8 && n=8 tmpfile=$(mktemp /var/lib/carnet-upgrade/dialog-tmp.XXXXXX) - cmd="dialog --nocancel --backtitle \""$title"\" --checklist \""$text"\" 20 75 8 $to_show" + cmd="dialog --nocancel --backtitle \""$title"\" --checklist \""$text"\" 20 75 $n $to_show" [ "$DEBUG" ] && set +x eval $cmd 2> $tmpfile [ "$DEBUG" ] && set -x @@ -199,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" @@ -223,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'" + checkmsg="" + [ "$test" != "true" ] && checkmsg="if '$test'" if eval $test; then - log "$(printf 'action %02d' $lineno) starting: '${action}' $testmsg " + 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 @@ -295,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" @@ -485,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 @@ -523,12 +528,14 @@ 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 @@ -588,6 +595,7 @@ upgrade_libc () { # upgrade apache -> apache2 upgrade_apache () { + local delpkg p # bugfix for apache2-cn postinst mkdir -p /etc/apache2 @@ -620,6 +628,8 @@ upgrade_apache () { } 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 @@ -627,7 +637,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 @@ -654,8 +664,7 @@ upgrade_openldap () { } 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)