From patchwork Mon Oct 14 14:47:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Weismueller X-Patchwork-Id: 2499 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 "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 46sLyV4fkmz42jK for ; Mon, 14 Oct 2019 14:48:02 +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) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 46sLyS4wYXz2v8; Mon, 14 Oct 2019 14:48:00 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 46sLyS2GZBz2yjy; Mon, 14 Oct 2019 14:48:00 +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 "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 46sLyQ4Xdmz2y4F for ; Mon, 14 Oct 2019 14:47:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 46sLyQ30Mkz1jh; Mon, 14 Oct 2019 14:47:58 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1571064478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1hpbXnXLGp28uCE/+hBr9F4AKshFwjqJX6QoH3f2Xq8=; b=AaR7Y7Nhd8UNlEZPPaq6a5H5UqQk7LHPKMYMwqSn+rM96SJoWWeiNDW/TMh9BRWJf9RM1X lVRCUntR/XRwstBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1571064478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1hpbXnXLGp28uCE/+hBr9F4AKshFwjqJX6QoH3f2Xq8=; b=MWZreCTVzoavsK71BwaHmypemSTU0oas2Im3D1fEu2bruxtX/2NEjM7rFRybb6YHXyZ+XM BnDMVBStrddHGAFDezOTnE4jvMGqpZARHdUBAwPDshhZzFbh7Hpw2ja8d7ZOPN9zyD6/8W ZWFXbkRhRy32tSqpYib/RDNeQTEP/epgp8ww+AJ+2xBHdf6/rkH+nvD27MOcq2MtjzKaiK PhvAzOeU43PzMsD1NnhXE/nGMgmv3D7nINRc9QBXrulHApPT9c5JlcGPRGV2AEmL0VskFF g/KUhDncBQJyOvu0S3YoayNUrAeZgBTCzPyNRE1BjwcJU2pxy1eQNt3duj3UPg== From: =?utf-8?q?Daniel_Weism=C3=BCller?= To: development@lists.ipfire.org Subject: [PATCH 4/4] xt_geoip_update: Always call the cleanup function when some step fails Date: Mon, 14 Oct 2019 16:47:56 +0200 Message-Id: <20191014144756.7674-4-daniel.weismueller@ipfire.org> In-Reply-To: <20191014144756.7674-1-daniel.weismueller@ipfire.org> References: <20191014144756.7674-1-daniel.weismueller@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=dweismueller smtp.mailfrom=daniel.weismueller@ipfire.org 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" Signed-off-by: Daniel Weismüller --- src/scripts/xt_geoip_update | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/scripts/xt_geoip_update b/src/scripts/xt_geoip_update index 6c0b70db0..ebd266533 100644 --- a/src/scripts/xt_geoip_update +++ b/src/scripts/xt_geoip_update @@ -117,27 +117,22 @@ function cleanup() { } function main() { - # Download ruleset. - download || exit $? + local func + for func in download install build build_legacy; do + if ! ${func}; then + # Cleanup any temporary data + cleanup - if ! install; then - # Do cleanup. - cleanup || exit $? - exit 1 - fi - - # Remove temporary files. - cleanup || exit $? - - # Convert the ruleset. - build || exit $? + return 1 + fi + done - # Convert GeoIP2 to lagacy. - build_legacy || exit $? + # Cleanup + cleanup || return $? - # Remove temporary files. - cleanup || exit $? + # All done + return 0 } # Run the main function. -main +main || exit $?