repoforge/rpms — Issue #112: Upgrading monit from 5.3.2-1 to 5.3.2-2 can cause config to be lost
Author: crispygoth
Created: 2012-02-02 18:41:30+00:00
State: open

I just upgraded monit from 5.3.2-1 to 5.3.2-2, and my /etc/monitrc was overwritten with the default config file.

Previously, when upgrading to 5.3.2-1 I had noticed that it was looking in the new location for the config file, and had fixed this by hand. It looks like the culprit is the postinst script added in -2 to move the config to the new location:

[ -f /etc/monit.conf ] &&
touch -r /etc/monitrc /etc/monit.conf &&
mv -f /etc/monit.conf /etc/monitrc 2> /dev/null || :

Combined with the fact that the package seems to still be shipping the config file as /etc/monit.conf:

# rpm -q --list monit
/etc/monit.conf
/etc/monit.d
…

In this situation, what seems to be happening is:

# rpm unpacks the new package, including /etc/monit.conf
# the postinst notices that /etc/monit.conf exists, which it does, and overwrites it with the default config
# bye-bye customised config file - time to check that your backups actually work!

I guess there are actually two issues here that should be addressed:

# if /etc/monitrc exists then do *not* overwrite it, even if /etc/monit.conf exists too
# the config file should be shipped in the correct location