# 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
}
# 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
# 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
# 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
}
# 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
# 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
# install original
log Restoring config file $file
- cp /usr/share/carnet-upgrade/files/$file $file
+ cp $file_orig $file
fi
done
}
/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"
# 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
# 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