X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Ffunctions.sh;h=7afb24acfdf0bf4fdbca15d3c841dbad938adfe3;hb=ee79cec573d44cfe51ce58a163c181b7048efc06;hp=25ef535846d8451fed9f6ec18577a935068c98de;hpb=5626b6c6fa1a7cd1c48e5aaff41a663ee98cb397;p=carnet-upgrade.git diff --git a/src/functions.sh b/src/functions.sh index 25ef535..7afb24a 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -263,7 +263,7 @@ check_upgrade () { if [ "$upgrade" ]; then notice " -Prije prelaska na Debian Etch potrebno je napraviti upgrade ovih paketa: +Prije prelaska na Debian Etch potrebno je napraviti nadogradnju ovih paketa: $upgrade Pokrenite: @@ -313,7 +313,7 @@ create_sources_list () { # backup old version if [ -f $sl -a ! -f $sl.$backup_ext ]; then - cp $sl $sl.$backup_ext + cp -a $sl $sl.$backup_ext fi # install new version @@ -349,25 +349,36 @@ add_group_proc () { fi } -# backup_slapd_db +# backup ldap database backup_slapd_db () { local ldap_backup=/var/backups/slapcat.$backup_ext + local old_umask result if [ ! -f $ldap_backup ]; then [ -x /etc/init.d/freeradius ] && /etc/init.d/freeradius stop || true if [ -x /etc/init.d/slapd -a -d /var/lib/ldap ]; then /etc/init.d/slapd stop || true - if slapcat -l $ldap_backup; then + old_umask=`umask` + umask 0077 # protect the backup file + slapcat -l $ldap_backup + result=$? + umask $old_umask + /etc/init.d/slapd start || true + + if [ "$result" eq 0 ]; then log "$ldap_backup created" notice "Napravljen backup slapd baze u $ldap_backup." + else + log "$ldap_backup was not created" + notice "Backup slapd baze u $ldap_backup nije uspio." + exit 1 fi - /etc/init.d/slapd start || true fi [ -x /etc/init.d/freeradius ] && /etc/init.d/freeradius start || true else - log "slapd backup already at $ldap_backup, skipping" + log "slapd backup already at $ldap_backup, skipping." notice "Backup slapd baze u $ldap_backup vec postoji!" fi } @@ -375,12 +386,21 @@ backup_slapd_db () { # backup etc direktorija backup_etc_dir () { local etc_backup=/var/backups/etc.$backup_ext.tar.gz + local old_umask if [ ! -f $etc_backup ]; then + old_umask=`umask` + umask 0077 # protect the backup file + if tar cfz $etc_backup /etc 2> /dev/null; then log "$etc_backup created" notice "Napravljen backup /etc direktorija u $etc_backup." + else + log "$etc_backup was not created" + notice "Backup /etc direktorija u $etc_backup nije uspio." + exit 1 fi + umask $old_umask else log "/etc backup already present in $etc_backup, skipping." notice "Backup /etc direktorija u $etc_backup vec postoji!" @@ -408,11 +428,16 @@ fix_etc_default_raid2 () { restore_config () { local file file_backup file_orig local pkg=$1 ver=$2 + local old_umask shift 2 # check package version pkg $pkg lt $ver || return 0 + # create new files safely + old_umask=`umask` + umask 0077 + # restore package files for file in $*; do file_orig=/usr/share/carnet-upgrade/files/$file @@ -429,8 +454,12 @@ restore_config () { # install original log Restoring config file $file cp $file_orig $file + chown --reference $file_backup $file + chmod --reference $file_backup $file fi done + + umask $old_umask } # restore modified config to their package defaults @@ -537,7 +566,7 @@ upgrade_apache () { # register cn changes in modules.conf modules_conf=/etc/apache/modules.conf if [ ! -e "$modules_conf.$backup_ext" ]; then - cp "$modules_conf" "$modules_conf.$backup_ext" + cp -a "$modules_conf" "$modules_conf.$backup_ext" ucf $modules_conf $modules_conf fi