Re: how to move a config file during package upgrade
On Wed, Jan 02, 2002 at 03:17:09PM +0100, Wichert Akkerman wrote:
> Previously Thomas Lange wrote:
> > my package fai will have a new location for its configuration file
> > /etc/fai.conf. The next version will use /etc/fai/fai.conf. How can I
> > handle this in a preinst script during an upgrade ? Any examples would
> > be fine.
>
> Move it in the preinst.
Approximately:
(new-version is the first version which uses /etc/fai/fai.conf)
preinst:
case "$1" in
upgrade)
version=$2
if dpkg --compare-versions "$2" lt new-version && test -f /etc/fai.conf; then
mkdir -p /etc/fai
mv /etc/fai.conf /etc/fai/fai.conf
fi
;;
esac
If there is other preinst code which could fail, add:
postrm:
case "$1" in
abort-upgrade)
version=$2
if dpkg --compare-versions "$2" lt new-version && test -f /etc/fai/fai.conf; then
mv /etc/fai/fai.conf /etc/fai.conf
fi
;;
esac
So that if things go wrong, the user is not left with a broken installation.
--
- mdz
Reply to: