### # 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 }