#! /bin/sh #---------------------------------------------------------------------------- # template-restore-bconf - restore config file from /etc/backup.d # # Creation: 2003-12-24 ap # Last Update: $Id$ # # Copyright (c) 2001-2003 Ansgar Puester, Ansgar.Puester(at)T-Online(dot)de # Copyright (c) 2008-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib # --------------------------------------------------------------------------- # header_md(): prepare header display # --------------------------------------------------------------------------- header_md() { MD_TITLE="Restore configuration file from ${backupd} directory" MD_SUBTITLE=" Avaliable backups for package $package: \n" # export for use in config_shlib (choose) export MD_TITLE export MD_SUBTITLE } # --------------------------------------------------------------------------- # header(): display header # --------------------------------------------------------------------------- header() { clrhome mecho --info "${MD_TITLE}" mecho } # --------------------------------------------------------------------------- # footer(): display footer # --------------------------------------------------------------------------- footer() { mecho mecho anykey } # --------------------------------------------------------------------------- # overwrite_hint(): display overwrite hint # --------------------------------------------------------------------------- overwrite_hint() { mecho --warn "Attention: this will overwrite your current configuration" mecho -n --warn " file for package" mecho -n " ${package}" mecho --warn " with an older" mecho --warn " configuation file named" mecho " ${restfile}" mecho -n --warn " that was saved in" mecho " ${backupd}." mecho } # --------------------------------------------------------------------------- # restore_file(): restore the file # --------------------------------------------------------------------------- restore_file() { header mecho overwrite_hint _ask_tmpfile=$(mktemp -t XXXXXXXXXXXXX) /var/install/bin/ask 'Continue' >${_ask_tmpfile} rc=${?} read answer < ${_ask_tmpfile} rm -f ${_ask_tmpfile} if [ ${rc} = 255 ] then answer=no fi case "${answer}" in yes) mecho # echo "TEST cp -p $restfile $configd/$package" cp -p $restfile $configd/$package activate_hint ;; *) mecho mecho --info "Configuration file $configd/$package was not changed." ;; esac } # include function library . /var/install/bin/config_shlib # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- # get package name from filename PACKAGE-restore-bconf filename=`basename $0` package=`echo $filename | sed "s|-restore-bconf$||"` # if package is template # take package from $PACKAGE [ "$package" = 'template' ] && package="$PACKAGE" #debug echo "+++ TEST filename: $filename" #debug echo " PACKAGE: $PACKAGE" #debug echo " package: $package" #debug read answ < /dev/tty # prepare header header_md # select a file select_file case "${answer}" in '') exit 0 ;; 0) exit 127 ;; *) eval restfile='${bfile_'${answer}'}' # do the restore restore_file ;; esac footer # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------