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

Re: Replace line in file based on pattern



On Du, 02 ian 22, 21:22:33, Paul M. Foster wrote:
> 
> I'm not interested in hacking a bunch of servers. Just one. The whole
> purpose here is to restore a system to more or less its original
> configuration when a reinstall must occur. A reinstall must occur when there
> is a severe hardware failure, or when Debian (or any other operating system)
> comes up with a major revision (in Debian's case, every couple of years).
> The problem I've seen with just copying an old config file over the top of
> the one installed by default is that in some cases, syntax changes or
> options are added or deleted in the config files from one version to
> another. Thus, my idea of "surgical" alteration of the config files.

If I understand correctly you mean:

1. System is installed with package foo version 1.0

2. You customize configuration of package foo

3. At some point in the future a reinstall might be required and you 
want to restore the system to the state at point 2.

If you are still on the same stable release a simple overwrite of the 
configuration should do it as, by definition, stable shouldn't introduce 
major changes (like syntax changes in the configuration file[1]).

If you want to reinstall the system with a newer release of Debian you 
are probably better of just going through each and every changed 
configuration file with something like vimdiff[2].


There are at least two reasons to this:

A. As you already noted above, configuration file syntax may change.

Any automated method you can think of involves a risk of doing a change 
that will simply be wrong for the newer version. While examining the 
situation to tell whether it's safe to do automatically or not you might 
as well just do the change manually.

Tools like vimdiff make it very easy to apply changes selectively.


B. On (typically major) upgrades a package might consider your 
customizations and adapt accordingly, however installing a fresh new 
version might not.

This is because both upstreams and Debian are doing their best to enable 
in-place upgrades whenever possible, even between major releases. Such 
mechanisms typically involve having the old configuration already in 
place, either during the upgrade (if done by package scripts) or at 
first start of the new software version (if done by the software 
itself).

While it may work if you make sure you replace / edit / whatever the 
configuration before the first start of the software it can't possibly 
work if the changes are managed via package scripts (for hopefully 
obvious reasons).


[1] exceptions to this rule might happen, e.g. if the change of 
configuration (syntax) is required to fix a security issue or in cases 
where fixing security issues is done by upgrading to newer major 
versions of the software (as for Firefox, Chrome, etc.).

[2] going through the Release Notes and NEWS.Debian first is highly 
recommended, as these are the places where the need for manual changes 
are documented.

Hope this helps,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser

Attachment: signature.asc
Description: PGP signature


Reply to: