Ensure config files are not overwritten in RPM upgrade

In order to ensure that configuration files do not get overwritten when
upgrading an RPM, it is not sufficient to mark them as configuration. You
have to use the 'noreplace' parameter to make sure, they are never
overwritten. Added this parameter for the /etc/elasticsearch directory
as well as the /etc/sysconfig/elasticsearch file.

In addition, the post remove script now only deletes the user in case of
a package removal (and does nothing on package upgrade).

Closes #3123
This commit is contained in:
Alexander Reelsen 2013-05-31 16:18:32 +02:00
parent e6a3c9c153
commit 183bb76371
2 changed files with 12 additions and 14 deletions

View File

@ -634,11 +634,7 @@
<mappings> <mappings>
<mapping> <mapping>
<directory>/etc/elasticsearch/</directory> <directory>/etc/elasticsearch/</directory>
<configuration>true</configuration> <configuration>noreplace</configuration>
</mapping>
<mapping>
<directory>/etc/elasticsearch/</directory>
<configuration>true</configuration>
<sources> <sources>
<source> <source>
<location>config/</location> <location>config/</location>
@ -650,7 +646,7 @@
</mapping> </mapping>
<mapping> <mapping>
<directory>/etc/sysconfig/</directory> <directory>/etc/sysconfig/</directory>
<configuration>true</configuration> <configuration>noreplace</configuration>
<sources> <sources>
<source> <source>
<location>src/rpm/sysconfig</location> <location>src/rpm/sysconfig</location>

View File

@ -1,13 +1,15 @@
echo "Removing elasticsearch user and group if existing" # only execute in case of package removal, not on upgrade
if [ $1 -eq 0 ] ; then
getent passwd elasticsearch > /dev/null getent passwd elasticsearch > /dev/null
if [ "$?" == "0" ] ; then if [ "$?" == "0" ] ; then
userdel elasticsearch userdel elasticsearch
fi fi
getent group elasticsearch >/dev/null getent group elasticsearch >/dev/null
if [ "$?" == "0" ] ; then if [ "$?" == "0" ] ; then
groupdel elasticsearch groupdel elasticsearch
fi
fi fi
exit exit