xt_geoip_update: Always call the cleanup function when some step fails

Signed-off-by: Daniel Weismüller <daniel.weismueller@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
This commit is contained in:
Daniel Weismüller
2019-10-14 16:47:56 +02:00
committed by Arne Fitzenreiter
parent 7b2d933055
commit a18addb946

View 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
return 1
fi
done
# Remove temporary files.
cleanup || exit $?
# Cleanup
cleanup || return $?
# Convert the ruleset.
build || exit $?
# Convert GeoIP2 to lagacy.
build_legacy || exit $?
# Remove temporary files.
cleanup || exit $?
# All done
return 0
}
# Run the main function.
main
main || exit $?