From a18addb94621b1e43b78dcb713ad2d88de800d37 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Weism=C3=BCller?= Date: Mon, 14 Oct 2019 16:47:56 +0200 Subject: [PATCH] xt_geoip_update: Always call the cleanup function when some step fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weismüller Signed-off-by: Arne Fitzenreiter --- 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 6c0b70db02..ebd2665331 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 $? -- 2.39.5