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>
<mapping>
<directory>/etc/elasticsearch/</directory>
<configuration>true</configuration>
</mapping>
<mapping>
<directory>/etc/elasticsearch/</directory>
<configuration>true</configuration>
<configuration>noreplace</configuration>
<sources>
<source>
<location>config/</location>
@ -650,7 +646,7 @@
</mapping>
<mapping>
<directory>/etc/sysconfig/</directory>
<configuration>true</configuration>
<configuration>noreplace</configuration>
<sources>
<source>
<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
if [ "$?" == "0" ] ; then
userdel elasticsearch
fi
getent passwd elasticsearch > /dev/null
if [ "$?" == "0" ] ; then
userdel elasticsearch
fi
getent group elasticsearch >/dev/null
if [ "$?" == "0" ] ; then
groupdel elasticsearch
getent group elasticsearch >/dev/null
if [ "$?" == "0" ] ; then
groupdel elasticsearch
fi
fi
exit