1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
###
# Functions to propose changes in configuration files
###
# Replace an exsting file with the proposed one
replace_file () {
file=$1
if [ -e $file ] ; then
cp $file ${file}.gforge-old
fi
mv ${file}.gforge-new $file
}
# Propose a replacement to the user
propose_update () {
file=$1
mode=$2
template=gforge/shared/replace_file_$mode
if [ ! -e ${file}.gforge-new ] ; then
echo "${file} already configured, not changing."
elif diff -q ${file} ${file}.gforge-new > /dev/null 2>&1 ; then
# Old file and new file are identical
rm -f ${file}.gforge-new
else
db_fset $template seen false
db_subst $template file $file
db_input high $template || true
db_go || true
db_get $template || true
case "$RET" in
"true")
echo >&2 "Replacing file $file with changed version"
replace_file $file
;;
"false")
db_fset gforge/shared/file_changed seen false
db_subst gforge/shared/file_changed file $file
db_input high gforge/shared/file_changed || true
db_go || true
;;
esac
fi
}
# Same, but for installation
propose_update_install () {
propose_update $1 install
}
# Same, but for de-installation
propose_update_remove () {
propose_update $1 remove
}
|