0

I have built a RPM-package for Centos 6.6 that is installed on a machine of our customer. This package contains our own software, customized for the specific use case, but also uses the open-source package HAProxy.

HAProxy (RPM-version 1.5.4-2.el6_7.1) comes with a default-configuration in /etc/haproxy/haproxy.conf and it cannot be customized without changing this file. But I want the configuration to be part my generated package. RPM throws an error if the /etc/haproxy/haproxy.conf file is in my package, because it is also part of the haproxy-package.

I have worked around this problem by providing a custom upstart-script which starts HAProxy with a different config file, but this does not seem to be the right way to do this.

Is there a preferred way to handle such customizations?

Nils Knappmeier
  • 669
  • 7
  • 10

3 Answers3

1

In cases like this, I've created an RPM which installs configuration files into a different subdirectory, and in its %post and %preun scriptlets modifies the uncooperative package's config-files:

  • when installing, I renamed the original config-files, and made symbolic links from those pathnames to the overwriting config-files, and
  • when uninstalling, the package removed the symbolic links and restored the original package's files.

Doing it that way of course meant that my config-RPM was dependent on the original RPM. A little awkward to describe, but it works.

In followup, the issue of updating was mentioned. Updating an RPM requires special handling to avoid uninstalling things. The rpm program passes a parameter $1 which you can test in the %pre and %preun scriptlets to notice that this is an upgrade and that there is no need to save the original config-files (or restore them). The rest of the scriptlet would be the same, by copying the new versions of your config-files over the others.

Further reading:

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • According to [this question](http://stackoverflow.com/questions/14511334/rpm-upgrade-handling-of-config-files) the modified config file might be overridden when doing `rpm -U`. Is your method preventing this behavior? – Nils Knappmeier Mar 24 '16 at 09:53
  • no - that's a different situation (it describes a case where `%config` *is used). – Thomas Dickey Mar 24 '16 at 23:17
0

Your approach is correct. On EL6 and sysv there is no other choice than creating custom haproxy package or custom haproxy service or create script which customer runs after installation. I see creating another service as best option.

Note that on EL7 with SystemD you have much better option as you can use Drop-In feature of SystemD. For more information see:

msuchy
  • 5,162
  • 1
  • 14
  • 26
0

The usual way this is done is to have a drop-in configuration directory, e.g. /etc/httpd/conf.d/, where your package would drop its configuration, and you would tell the other daemon, e.g. httpd, to do a graceful restart in your %post/%postun.

I don't know anything about HAProxy, but a quick search implies that they do not support this configuration directory concept that has been around for many years. A few people have hacked it in, but unless it is out-of-the-box, you will run into your original problem again.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39