mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
Change mmdb-country job to download the file only if needed
This commit is contained in:
parent
9e009f7bee
commit
55d24a8d14
1 changed files with 22 additions and 0 deletions
|
@ -27,6 +27,28 @@ logger = setup_logger("JOBS.mmdb-country", getenv("LOG_LEVEL", "INFO"))
|
|||
status = 0
|
||||
|
||||
try:
|
||||
# Only download mmdb if the country blacklist or whitelist is enabled
|
||||
dl_mmdb = False
|
||||
# Multisite case
|
||||
if getenv("MULTISITE", "no") == "yes":
|
||||
for first_server in getenv("SERVER_NAME", "").split(" "):
|
||||
if getenv(
|
||||
f"{first_server}_BLACKLIST_COUNTRY", getenv("BLACKLIST_COUNTRY")
|
||||
) or getenv(
|
||||
f"{first_server}_WHITELIST_COUNTRY", getenv("WHITELIST_COUNTRY")
|
||||
):
|
||||
dl_mmdb = True
|
||||
break
|
||||
# Singlesite case
|
||||
elif getenv("BLACKLIST_COUNTRY") or getenv("WHITELIST_COUNTRY"):
|
||||
dl_mmdb = True
|
||||
|
||||
if not dl_mmdb:
|
||||
logger.info(
|
||||
"Country blacklist or whitelist is not enabled, skipping download..."
|
||||
)
|
||||
_exit(0)
|
||||
|
||||
# Don't go further if the cache is fresh
|
||||
if is_cached_file("/var/cache/bunkerweb/country.mmdb", "month"):
|
||||
logger.info("country.mmdb is already in cache, skipping download...")
|
||||
|
|
Loading…
Reference in a new issue