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:
# 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
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
}
# 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!"
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
# 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
fi
}
+# temporary disable listchanges packages to reduce clutter during upgrade
+apt_listchanges () {
+ local file command=$1
+
+ for file in /etc/apt/apt.conf.d/20listchanges \
+ /etc/apt/apt.conf.d/20listchanges-cn
+ do
+ case $command in
+ disable)
+ if [ -f $file ]; then
+ dpkg-divert --local --rename --divert $file.$backup_ext \
+ --add $file || true
+ fi
+ ;;
+
+ enable)
+ if [ -f $file.$backup_ext ]; then
+ dpkg-divert --remove $file || true
+ fi
+ ;;
+ esac
+ done
+}
+
# make a silent installation of carnet and srce keyrings
install_keyrings () {
pkgadd carnet-keyring srce-keyring
# 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