[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

moving config files



Hi friends!

I am in need of an advice: Can someone give me a quick howto how to move
config files from an old location to a new location? Do I need some
version checking?

Taking a look into tetex-*.preinst I would like to do the following:
config_move ()
{
    oldfile=$1
    oldmd5sum=$2
    newloc=$3

    if ! [ -r $oldfile ] ; then
        return 0
    fi
    oldloc=`dirname $1`
    newmd5sum=`md5sum $oldfile |  cut -d ' ' -f 1`
    if [ "$newmd5sum" = "$oldmd5sum" ] ; then
        echo "Removing obsolete, unchanged conffile $oldfile"
        rm $oldfile
    else
        if [ "X$newloc" = "X" ] ; then
            echo "Conffile $oldfile was changed, leaving it at the same place"
        else
            echo "Conffile $oldfile was changed, moving it to new location $newloc"
            mkdir -p $newloc
            mv $oldfile $newloc
        fi
    fi
    test -d $oldloc && rmdir --ignore-fail-on-non-empty $oldloc || true
}

case "$1" in
    upgrade|install)
        set -e
        config_move /etc/texmf/map/dvips/cm-super/cm-super-t1.map aedad51b5745237d8633f7821d0c0f6f /etc/texmf/fonts/map/dvips/cm-super/
        config_move /etc/texmf/map/dvips/cm-super/cm-super-t2a.map befe816fca42bc17eaebff2e333e8419 /etc/texmf/fonts/map/dvips/cm-super/
	...

Does this seem ok?

On a side note: the function move_old_conffile() in tetex-bin.preinst
seems to be a bit strange:
    rm $oldname
    if rmdir $oldname 2>/dev/null; then
      echo "Removed obsolete dir $oldname."
    fi
I guess the rmdir $oldname should be a rmdir $olddir. Did nobody happend
to stumble on this?


Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining AT logic DOT at>             Università di Siena
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
BURLESTON
That peculiarly tuneless humming and whistling adopted by people who
are extremely angry.
			--- Douglas Adams, The Meaning of Liff



Reply to: