From: Valentin Vidic Date: Fri, 1 Feb 2008 15:54:42 +0000 (+0100) Subject: Introduced unique backup extension. X-Git-Tag: debian/4.0.1~53 X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=commitdiff_plain;h=9d75a6be10d4987f24d7f6d9e568bd8db5a6405f;p=carnet-upgrade.git Introduced unique backup extension. Moved all packages to second group. Always execute del proc group (function contains the check). --- diff --git a/src/actions/main.queue b/src/actions/main.queue index 1880a6e..aeede28 100644 --- a/src/actions/main.queue +++ b/src/actions/main.queue @@ -8,7 +8,7 @@ true comment_force_overwrite # ruzna opcija za dpkg # ovo bi trebao biti zadnji post_upgrade - spremi popis # instaliranih servisa za koje cemo na kraju provjeriti da li rade. ! check_services check check_services preupgrade -getent group proc remove_group_proc # calls post_upgrade add_group_proc +true remove_group_proc # calls post_upgrade add_group_proc pkg slapd backup_slapd_db true backup_etc_dir # etc i drugo true create_sources_list diff --git a/src/data.sh b/src/data.sh index f29350c..55d8955 100644 --- a/src/data.sh +++ b/src/data.sh @@ -1,6 +1,9 @@ # Minimum free space on /var after the download, in MB min_var_space=250 +# Backup extension +backup_ext=cn4-upgrade + # carnet-upgrade aborts if these packages are not up to date # name wanted version needed_versions=' @@ -33,16 +36,14 @@ mysql-common 4.0.24-10sarge3 # Packages to forcibly install before installing the rest with dist-upgrade, # because dist-upgrade would rather remove them. packages_first=' -php4-odbc -php4-xslt -amavisd-cn -php5-cn -squirrelmail-cn -mysql-cn ' # Packages that provide crucial services, upgrade them before the rest packages_second=' +amavisd-cn +php5-cn +squirrelmail-cn +mysql-cn bind9-cn bind9 openssh-cn openssh-server clamav-cn clamav-daemon @@ -63,6 +64,9 @@ ossec-hids-cn amavis-stats-cn webalizer-cn oidentd +php4-odbc +php4-xslt +libkrb5-17-heimdal ' # We want to remove these packages, used in remove_bloat() diff --git a/src/functions.sh b/src/functions.sh index 09821a3..7474d5e 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -304,11 +304,24 @@ upgrade () { # funkcija utrpa ispravan sources.list create_sources_list () { - [ -f /etc/apt/sources.list -a ! -f /etc/apt/sources.list.cn4-upgrade ] && mv /etc/apt/sources.list /etc/apt/sources.list.cn4-upgrade - cp /usr/share/carnet-upgrade/files/etc/apt/sources.list /etc/apt - notice "Novi sadrzaj datoteke /etc/apt/sources.list: + local sl sl_new + sl=/etc/apt/sources.list + sl_new=/usr/share/carnet-upgrade/files/etc/apt/sources.list + + # check if already installed + if ! cmp $sl $sl_new >/dev/null; then + + # backup old version + if [ -f $sl -a ! -f $sl.$backup_ext ]; then + cp $sl $sl.$backup_ext + fi + + # install new version + cp $sl_new $sl + notice "Novi sadrzaj datoteke /etc/apt/sources.list: `cat /etc/apt/sources.list`" + fi } @@ -338,7 +351,7 @@ add_group_proc () { # backup_slapd_db backup_slapd_db () { - local ldap_backup=/var/backups/slapcat.cn4-upgrade + local ldap_backup=/var/backups/slapcat.$backup_ext if [ ! -f $ldap_backup ]; then [ -x /etc/init.d/freeradius ] && /etc/init.d/freeradius stop || true @@ -361,7 +374,7 @@ backup_slapd_db () { # backup etc direktorija backup_etc_dir () { - local etc_backup=/var/backups/etc.cn4-upgrade.tar.gz + local etc_backup=/var/backups/etc.$backup_ext.tar.gz if [ ! -f $etc_backup ]; then if tar cfz $etc_backup /etc 2> /dev/null; then @@ -377,15 +390,15 @@ backup_etc_dir () { # fixaj /etc/default/raid2 fix_etc_default_raid2 () { if [ -f /etc/default/raid2 ]; then - sed "s/^AUTOSTART.*/AUTOSTART=true/g" /etc/default/raid2 > /etc/default/raid2.cn4-upgrade.$$ - chown --reference=/etc/default/raid2 /etc/default/raid2.cn4-upgrade.$$ - chmod --reference=/etc/default/raid2 /etc/default/raid2.cn4-upgrade.$$ + sed "s/^AUTOSTART.*/AUTOSTART=true/g" /etc/default/raid2 > /etc/default/raid2.$backup_ext.$$ + chown --reference=/etc/default/raid2 /etc/default/raid2.$backup_ext.$$ + chmod --reference=/etc/default/raid2 /etc/default/raid2.$backup_ext.$$ - if ! cmp -s /etc/default/raid2.cn4-upgrade.$$ /etc/default/raid2; then + if ! cmp -s /etc/default/raid2.$backup_ext.$$ /etc/default/raid2; then log "Fixed /etc/default/raid2 AUTOSTART option." - mv /etc/default/raid2.cn4-upgrade.$$ /etc/default/raid2 + mv /etc/default/raid2.$backup_ext.$$ /etc/default/raid2 else - rm /etc/default/raid2.cn4-upgrade.$$ + rm /etc/default/raid2.$backup_ext.$$ fi fi } @@ -393,7 +406,7 @@ fix_etc_default_raid2 () { # restore original config file (if the new package version is not # installed already) restore_config () { - local file file_backup + local file file_backup file_orig local pkg=$1 ver=$2 shift 2 @@ -402,7 +415,12 @@ restore_config () { # restore package files for file in $*; do - file_backup=$file.cn4-upgrade + file_orig=/usr/share/carnet-upgrade/files/$file + file_backup=$file.$backup_ext + + if cmp $file_orig $file >/dev/null; then + continue # original file is already in place + fi if [ -e $file -a ! -e $file_backup ]; then # backup file @@ -410,7 +428,7 @@ restore_config () { # install original log Restoring config file $file - cp /usr/share/carnet-upgrade/files/$file $file + cp $file_orig $file fi done } @@ -452,8 +470,8 @@ restore_configs () { /etc/cron.daily/aide \ /etc/default/aide; do - if [ ! -e "$file.cn4-upgrade" ]; then - mv "$file" "$file.cn4-upgrade" + if [ ! -e "$file.$backup_ext" ]; then + mv "$file" "$file.$backup_ext" fi rm -f "$file" @@ -494,8 +512,8 @@ upgrade_apache () { # register cn changes in modules.conf modules_conf=/etc/apache/modules.conf - if [ ! -e "$modules_conf.cn4-upgrade" ]; then - cp "$modules_conf" "$modules_conf.cn4-upgrade" + if [ ! -e "$modules_conf.$backup_ext" ]; then + cp "$modules_conf" "$modules_conf.$backup_ext" ucf $modules_conf $modules_conf fi @@ -534,8 +552,8 @@ upgrade_amavis () { # move old config aside local conf=/etc/amavis/amavisd.conf - if [ -e $conf -a ! -e $conf.cn4-upgrade ]; then - mv $conf $conf.cn4-upgrade + if [ -e $conf -a ! -e $conf.$backup_ext ]; then + mv $conf $conf.$backup_ext fi # install new packages