]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
xt_geoip_update: Always call the cleanup function when some step fails
authorDaniel Weismüller <daniel.weismueller@ipfire.org>
Mon, 14 Oct 2019 14:47:56 +0000 (16:47 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Mon, 14 Oct 2019 17:45:29 +0000 (17:45 +0000)
Signed-off-by: Daniel Weismüller <daniel.weismueller@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
src/scripts/xt_geoip_update

index 6c0b70db02c106e80a2f41d8ff50472b865841ea..ebd2665331c75ac5863e2d455e8cda6a5c37cb07 100644 (file)
@@ -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 $?