From patchwork Wed Apr 7 20:44:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 4122 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4FFxJl6JqSz3yBV for ; Wed, 7 Apr 2021 20:46:47 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4FFxJl3Jywz1V3; Wed, 7 Apr 2021 20:46:47 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4FFxJl2SKsz2xmG; Wed, 7 Apr 2021 20:46:47 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4FFxJk10Nkz2xX7 for ; Wed, 7 Apr 2021 20:46:46 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4FFxJj43NHzfQ for ; Wed, 7 Apr 2021 20:46:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id EDB9050D81 for ; Wed, 7 Apr 2021 22:46:44 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id Chcpr5HoD9gz for ; Wed, 7 Apr 2021 22:46:41 +0200 (CEST) Received: from amaterasu.sicho.home ([192.168.0.1] helo=chojin.sicho.home) by filekeeper.sicho.home with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1lUF3e-0003Zi-CE; Wed, 07 Apr 2021 22:45:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1617828378; bh=TE9jubJO74u/nwyZLLtrB/ogd3n1UMpeRUkMvOCHKGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=J53G9P30oXFW1gDR+halQRDXriDOLOQtAHJyvma4+UNcYtq/Zux14bWWrtNqm7a2/ /v5VjQZknlNLtgLf9DFEcOtIJ+xBTqjFJM+4YjPum9SLj4vHsRFBSt4FvBZQdYLDLD 4gX64gGEYTetew/628ZFegQzfUNAvb7BWg4RoA9WwroIFWjo7q85I+1zs4nyDGBWqA 2PZ0Zd2goJBguqSIzMCeTIAdIt5UQfnaxwHnxxNgxwekifK7m+GSNpp1Idt0pxuoBU SbxDwgEuxfviwsELhYlYK47CAEjrqk9+EqEy1rMAwp7bEDUvh8MTyuP4FjJaPjpmLR sxQCpYosrIKxA== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH 3/4] [V2] zabbix_agentd: Better configfile handling during update Date: Wed, 7 Apr 2021 22:44:55 +0200 Message-Id: <20210407204455.450-4-robin.roevens@disroot.org> In-Reply-To: <20210407204455.450-1-robin.roevens@disroot.org> References: <20210407204455.450-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-filekeeper-MailScanner-ID: 1lUF3e-0003Zi-CE X-filekeeper-MailScanner: Found to be clean X-filekeeper-MailScanner-From: robin.roevens@disroot.org X-filekeeper-MailScanner-Watermark: 1618433155.72249@RKiMtnuJhZbWW/mt2dukeQ ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1617828405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KpaEVo9qUdBFxn7RjFU3pgnUQ5YFKc3Y1OGaxLeO8Jc=; b=JjHwbfokfLWTVD7lCvVHUn72Pgf0+8DShr4AINGFkvHt4FobVaDIYvmaT1Wnm/jIOZwdiv 6Ok/rPr8yiB/4K44OYCaOd6Y0G1Thoq+XdHUFzxWmBIpMP88991TUr7eSwhXCV2AulCINX jx2zDeopHSVqCyKzAGUSnK/+RP2Spkf/pAUnCb8GVcaQAFuL5WDBga1F2erb9w9TF7Elpb rHX6JVkHa7+8iBY1Skrc/Q0Admy//vGC5EAepTmdY3FJpFlaKfgr+IwQ2HNyEyt5lAdxLg ryCInafPY0OV4I+Mpp0g3T5eVSdz9NxAQC1Mm8gIgpc9qCaReR1mR/JEH7rMAg== ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1617828405; a=rsa-sha256; cv=none; b=hfSGK/iIQWVNE+Xb+XE504UbIr09vZtt5aZohJ//Dw38+Eq56ZtumfkTjwakI4g8vXCtl/ 1UzOqbaOrTIhvpFeg49O8dz7tp+4zHcFMR5BYAfuHWyVyzvNhNwxHngu0ILBgYDcbSy+7y qYnyMxfxis6OZbtI/oEthwio7Ip05iqERVvuhe4dQU+rxN1w+mkcKkSq8qRWzFWodnmBZ+ A93zY8aS5BEltvPq894EtCrjijsO2oKl/taSYIfndBkW2SAWlZDtY6j6aOo55MAMXisLoE rjPJcU4drspvDAnRMBJuooGYPph3jmgRcDEe0FS4uSo4r4IlbDglXkx6s+5O1w== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=J53G9P30; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org X-Rspamd-Queue-Id: 4FFxJj43NHzfQ Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=J53G9P30; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-4.76 / 11.00]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:c]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_MISSING_CHARSET(2.50)[]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_REPUTATION_HAM(-2.26)[asn: 50673(-0.32), country: NL(-0.01), ip: 178.21.23.139(-0.80)]; DKIM_TRACE(0.00)[disroot.org:+]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; BAYES_HAM(-3.00)[99.99%] X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" - 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 --- 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%) diff --git a/config/rootfiles/packages/zabbix_agentd b/config/rootfiles/packages/zabbix_agentd index a938f2605..6945c5ef7 100644 --- a/config/rootfiles/packages/zabbix_agentd +++ b/config/rootfiles/packages/zabbix_agentd @@ -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 diff --git a/config/zabbix_agentd/userparameter_pakfire.conf b/config/zabbix_agentd/template_app_pakfire.conf similarity index 100% rename from config/zabbix_agentd/userparameter_pakfire.conf rename to config/zabbix_agentd/template_app_pakfire.conf diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd index 2d57b0dbe..73e08d20a 100644 --- a/lfs/zabbix_agentd +++ b/lfs/zabbix_agentd @@ -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 \ diff --git a/src/paks/zabbix_agentd/install.sh b/src/paks/zabbix_agentd/install.sh index b98230ea1..4248a7ec1 100644 --- a/src/paks/zabbix_agentd/install.sh +++ b/src/paks/zabbix_agentd/install.sh @@ -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} diff --git a/src/paks/zabbix_agentd/uninstall.sh b/src/paks/zabbix_agentd/uninstall.sh index b771d1f63..7a13880c5 100644 --- a/src/paks/zabbix_agentd/uninstall.sh +++ b/src/paks/zabbix_agentd/uninstall.sh @@ -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 diff --git a/src/paks/zabbix_agentd/update.sh b/src/paks/zabbix_agentd/update.sh index 68bba4f80..91dd8f723 100644 --- a/src/paks/zabbix_agentd/update.sh +++ b/src/paks/zabbix_agentd/update.sh @@ -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