diff --git a/jtl-wafi-agent.py b/jtl-wafi-agent.py index 14667db..50d37e4 100644 --- a/jtl-wafi-agent.py +++ b/jtl-wafi-agent.py @@ -2973,11 +2973,23 @@ def activate_blocking(shop: str, silent: bool = True, expiry = datetime.now() + timedelta(hours=72) - # Step 2: Verzeichnisstruktur erstellen + # Step 2: Alte Daten bereinigen (Log, Stats, Bans) + log_file = os.path.join(httpdocs, SHOP_LOG_FILE) + if os.path.isfile(log_file): + os.remove(log_file) + if not silent: + logger.info(f"Alte Log-Datei gelöscht") + + if os.path.isdir(ratelimit_path): + shutil.rmtree(ratelimit_path) + if not silent: + logger.info(f"Altes Ratelimit-Verzeichnis gelöscht") + + # Step 3: Verzeichnisstruktur erstellen os.makedirs(ratelimit_path, mode=0o777, exist_ok=True) os.chmod(ratelimit_path, 0o777) - # Step 3: Blocking-Script erstellen + # Step 4: Blocking-Script erstellen if monitor_only: # Monitor-Only Modus: Nur Logging, kein Blocking script_content = MONITOR_TEMPLATE.format( @@ -3020,7 +3032,7 @@ def activate_blocking(shop: str, silent: bool = True, set_owner(blocking_file, uid, gid) set_owner(ratelimit_path, uid, gid, recursive=True) - # Step 4: Registrieren + # Step 5: Registrieren add_shop_to_active( shop=shop, bot_mode=bot_mode, @@ -3033,7 +3045,7 @@ def activate_blocking(shop: str, silent: bool = True, monitor_only=monitor_only ) - # Step 5: Country-Cache vom globalen Cache kopieren (wegen PHP open_basedir) + # Step 6: Country-Cache vom globalen Cache kopieren (wegen PHP open_basedir) copy_country_cache_to_shop_async(ratelimit_path) if not silent: