[3/4,V2] zabbix_agentd: Better configfile handling during update
Commit Message
- Renamed userparameters_pakfire.conf to template_app_pakfire.conf
following current Zabbix template naming conventions.
- Install configfiles as .ipfirenew-files to prevent removing possible
user changed files on uninstall.
If the configfiles are not yet present, the .ipfirenew-files will be
renamed to the actual configfiles. And if an existing configfile
does not differ from the new one, the .ipfirenew-file will be removed.
This allows the user to manually merge his existing config with the
new config after update (warnings will be displayed during update
when manual review is required).
Signed-off-by: Robin Roevens <robin.roevens@disroot.org>
---
config/rootfiles/packages/zabbix_agentd | 12 ++++----
...pakfire.conf => template_app_pakfire.conf} | 0
lfs/zabbix_agentd | 11 ++++---
src/paks/zabbix_agentd/install.sh | 29 +++++++++++++++++++
src/paks/zabbix_agentd/uninstall.sh | 4 +++
src/paks/zabbix_agentd/update.sh | 14 +++++++--
6 files changed, 57 insertions(+), 13 deletions(-)
rename config/zabbix_agentd/{userparameter_pakfire.conf => template_app_pakfire.conf} (100%)
@@ -1,11 +1,11 @@
etc/logrotate.d/zabbix_agentd
etc/rc.d/init.d/zabbix_agentd
-etc/sudoers.d/zabbix
-etc/zabbix_agentd
-etc/zabbix_agentd/scripts
-etc/zabbix_agentd/zabbix_agentd.conf
-etc/zabbix_agentd/zabbix_agentd.d
-etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf
+etc/sudoers.d/zabbix.ipfirenew
+#etc/zabbix_agentd
+#etc/zabbix_agentd/scripts
+etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew
+#etc/zabbix_agentd/zabbix_agentd.d
+etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew
usr/bin/zabbix_get
usr/bin/zabbix_sender
#usr/lib/modules
similarity index 100%
rename from config/zabbix_agentd/userparameter_pakfire.conf
rename to config/zabbix_agentd/template_app_pakfire.conf
@@ -90,10 +90,13 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
-rmdir /etc/zabbix_agentd/zabbix_agentd.conf.d
-mkdir -pv /etc/zabbix_agentd/zabbix_agentd.d
-mkdir -pv /etc/zabbix_agentd/scripts
+ # Remove original config
+ @rm -f /etc/zabbix_agentd/zabbix_agentd.conf
+ # And replace with our own config
install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/zabbix_agentd.conf \
- /etc/zabbix_agentd/zabbix_agentd.conf
- install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/userparameter_pakfire.conf \
- /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf
+ /etc/zabbix_agentd/zabbix_agentd.conf.ipfirenew
+ install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/template_app_pakfire.conf \
+ /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf.ipfirenew
# Create directory for additional agent modules
-mkdir -pv /usr/lib/zabbix
@@ -111,7 +114,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
# Install sudoers include file
install -v -m 644 $(DIR_SRC)/config/zabbix_agentd/sudoers \
- /etc/sudoers.d/zabbix
+ /etc/sudoers.d/zabbix.ipfirenew
# Install include file for backup
install -v -m 644 $(DIR_SRC)/config/backup/includes/zabbix_agentd \
@@ -23,6 +23,23 @@
#
. /opt/pakfire/lib/functions.sh
+review_required=false
+
+function setup_configfile() {
+ # Puts configfile in place if it does not already exist or
+ # remove the shipped version if it does not differ from existing file
+ configfile=$1
+
+ if [ ! -f $configfile ]; then
+ mv $configfile.ipfirenew $configfile
+ elif diff -q $configfile $configfile.ipfirenew >/dev/null; then
+ rm -f $configfile.ipfirenew
+ else
+ echo "WARNING: new $configfile saved as $configfile.ipfirenew for manual review"
+ review_required=true
+ fi
+}
+
if ! getent group zabbix &>/dev/null; then
groupadd -g 118 zabbix
fi
@@ -45,4 +62,16 @@ mkdir -pv /usr/lib/zabbix
chown zabbix.zabbix /usr/lib/zabbix
restore_backup ${NAME}
+
+# Put zabbix configfiles in place
+setup_configfile /etc/zabbix_agentd/zabbix_agentd.conf
+setup_configfile /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf
+setup_configfile /etc/sudoers.d/zabbix
+
+if $review_required; then
+ echo "WARNING: New versions of some configfile(s) where provided as .ipfirenew-files."
+ echo " They may need manual review in order to take advantage of new features"
+ echo " or even to make this version of ${NAME} work."
+fi
+
start_service --background ${NAME}
@@ -23,6 +23,10 @@
#
. /opt/pakfire/lib/functions.sh
stop_service ${NAME}
+
+# Remove .ipfirenew files in advance so they won't be included in backup
+rm -rfv /etc/zabbix_agentd/*.ipfirenew /etc/zabbix_agentd/*/*.ipfirenew
+
make_backup ${NAME}
remove_files
@@ -23,10 +23,18 @@
#
. /opt/pakfire/lib/functions.sh
extract_backup_includes
-./uninstall.sh
-./install.sh
+
+# Ensure /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf is
+# renamed to /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf
+if [ -f /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf ]; then
+ mv -v /etc/zabbix_agentd/zabbix_agentd.d/userparameter_pakfire.conf \
+ /etc/zabbix_agentd/zabbix_agentd.d/template_app_pakfire.conf
+fi
# Ensure /etc/sudoers.d/zabbix.user is renamed to /etc/sudoers.d/zabbix
-if [ -e /etc/sudoers.d/zabbix.user ]; then
+if [ -f /etc/sudoers.d/zabbix.user ]; then
mv -v /etc/sudoers.d/zabbix.user /etc/sudoers.d/zabbix
fi
+
+./uninstall.sh
+./install.sh
\ No newline at end of file