From d3adfcf32d2e3053ec44f988bd4197b4a46a1a2c Mon Sep 17 00:00:00 2001 From: ebeckers Date: Fri, 5 Dec 2025 16:06:05 +0100 Subject: [PATCH] first commit --- 01_create_backend_service_link11.py | 76 +++++++++++++++++ 02_create_security_policy_link11.py | 92 ++++++++++++++++++++ 03_create_sg_link11.py | 66 +++++++++++++++ 04_create_cert_set_cert_in_sg_lb.py | 127 ++++++++++++++++++++++++++++ README.md | 1 + certtest.py | 54 ++++++++++++ get_backend_services_link11.py | 54 ++++++++++++ get_certificates_link11.py | 45 ++++++++++ get_load_balancers_link11.py | 55 ++++++++++++ get_security_policy_link11.py | 58 +++++++++++++ get_server_groups_link11.py | 57 +++++++++++++ serverliste_link11.csv | 1 + shop001.csv | 23 +++++ shop002.csv | 21 +++++ shop006.csv | 23 +++++ shop009.csv | 2 + shop012.csv | 26 ++++++ shop013.csv | 21 +++++ shop016.csv | 28 ++++++ shop018.csv | 27 ++++++ shop020.csv | 26 ++++++ shop025.csv | 26 ++++++ shop026.csv | 18 ++++ shop027.csv | 20 +++++ shop028.csv | 27 ++++++ shop029.csv | 22 +++++ shop031.csv | 22 +++++ shop034.csv | 24 ++++++ shop037.csv | 21 +++++ shop042.csv | 17 ++++ shop044.csv | 20 +++++ shop045.csv | 22 +++++ shop046.csv | 22 +++++ shop051.csv | 20 +++++ shop056.csv | 23 +++++ shop999.csv | 84 ++++++++++++++++++ sync_security_policies_link11.py | 122 ++++++++++++++++++++++++++ todelete.csv | 5 ++ update_server_groups_link11.py | 60 +++++++++++++ 39 files changed, 1458 insertions(+) create mode 100755 01_create_backend_service_link11.py create mode 100755 02_create_security_policy_link11.py create mode 100755 03_create_sg_link11.py create mode 100755 04_create_cert_set_cert_in_sg_lb.py create mode 100644 README.md create mode 100755 certtest.py create mode 100755 get_backend_services_link11.py create mode 100755 get_certificates_link11.py create mode 100755 get_load_balancers_link11.py create mode 100755 get_security_policy_link11.py create mode 100755 get_server_groups_link11.py create mode 100644 serverliste_link11.csv create mode 100644 shop001.csv create mode 100644 shop002.csv create mode 100644 shop006.csv create mode 100644 shop009.csv create mode 100644 shop012.csv create mode 100644 shop013.csv create mode 100644 shop016.csv create mode 100644 shop018.csv create mode 100644 shop020.csv create mode 100644 shop025.csv create mode 100644 shop026.csv create mode 100644 shop027.csv create mode 100644 shop028.csv create mode 100644 shop029.csv create mode 100644 shop031.csv create mode 100644 shop034.csv create mode 100644 shop037.csv create mode 100644 shop042.csv create mode 100644 shop044.csv create mode 100644 shop045.csv create mode 100644 shop046.csv create mode 100644 shop051.csv create mode 100644 shop056.csv create mode 100644 shop999.csv create mode 100755 sync_security_policies_link11.py create mode 100644 todelete.csv create mode 100755 update_server_groups_link11.py diff --git a/01_create_backend_service_link11.py b/01_create_backend_service_link11.py new file mode 100755 index 0000000..b259e52 --- /dev/null +++ b/01_create_backend_service_link11.py @@ -0,0 +1,76 @@ +#!/bin/python +from env import * +import requests +import json + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def domain_to_id(domain): + return domain.replace(".", "-") + +def domain_to_backend_id(domain): + return f"backend-{domain_to_id(domain)}" + + +def create_backend_service(name, ip): + entry_id = domain_to_backend_id(name) + url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/backend-services/{entry_id}" + + print(f"\n📦 creating Backend Service for {name} → IP: {ip}") + + payload = { + "back_hosts": [ + { + "backup": False, + "down": False, + "fail_timeout": 10, + "host": ip, + "http_ports": [80], + "https_ports": [443], + "max_fails": 0, + "monitor_state": "", + "weight": 1 + } + ], + "description": f"JTL Shopserver {name}", + "http11": True, + "id": entry_id, + "least_conn": True, + "name": name, + "sticky": "none", + "sticky_cookie_name": "", + "transport_mode": "default" + } + + print(payload) + response = requests.post(url, headers=HEADERS, data=json.dumps(payload) + + ) + + if response.status_code == 201: + print(f"[✓] Backend Service '{name}' erfolgreich erstellt.") + else: + print(f"[✗] Fehler bei {name} ({ip}): {response.status_code} → {response.text} {response.json()}") + + +def main(): + #create_backend_service("shop022.jtl-hosting.de", "31.172.84.222") + #create_backend_service("shop056.jtl-hosting.de", "31.172.91.121") + #create_backend_service("shop000.jtl-hosting.de", "31.172.91.145") + #create_backend_service("shop051.jtl-hosting.de", "31.172.91.88") + create_backend_service("shop009.jtl-hosting.de", "31.172.84.33") + +if __name__ == "__main__": + main() diff --git a/02_create_security_policy_link11.py b/02_create_security_policy_link11.py new file mode 100755 index 0000000..d9071d1 --- /dev/null +++ b/02_create_security_policy_link11.py @@ -0,0 +1,92 @@ +#!/bin/python +from env import * +import requests +import json + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen, diese dient als +# Vorlage für die neu erstellte Security Policy +SECURITY_POLICY = "secpol-shop022-jtl-hosting-de" # z. B. Shop022 + + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + +def domain_to_id(domain): + return domain.replace(".", "-") + +def domain_to_secpol_id(domain): + return f"secpol-{domain_to_id(domain)}" + +def domain_to_backend_id(domain): + return f"backend-{domain_to_id(domain)}" + +def create_security_policy(domain): + # Zuerst die SECURITY_POLICY abrufen, diese wird als Vorlage genutzt + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/security-policies/{SECURITY_POLICY}" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von Security policy '{SECURITY_POLICY}' erfolgreich.") + else: + print(f"[✗] Fehler bei ({SECURITY_POLICY}): {response.status_code} → {response.text}") + #print(response.text) + res=json.loads(response.text) + + backendservice = domain_to_backend_id(domain) + + # Neuen Backend-Service in allen Pfaden der Security Policy setzen + for mapitem in res['map']: + if (mapitem['id'] != "__site_level__"): + mapitem['backend_service'] = backendservice + + #print (res['map']) + # Neuen Namen und ID setzen + entry_id = domain_to_secpol_id(domain) + res['id'] = entry_id + res['name'] = domain + + ''' + for key,value in res.items(): + if ( key != "map" ): + print (key, value, "\n") + else: + print(key) + for items in value: + for key2, value2 in items.items(): + print(key2, value2) + ''' + + # Nun die angepasste Security Policy als neue speichern + url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/security-policies/{entry_id}" + + print(f"\n📦 creating Security Policy {entry_id}") + + response = requests.post(url, headers=HEADERS, data=json.dumps(res)) + + if response.status_code == 201: + print(f"[✓] Security Policy '{entry_id}' erfolgreich erstellt.") + else: + print(f"[✗] Fehler bei {entry_id}: {response.status_code} → {response.text} {response.json()}") + + +def main(): + #create_security_policy('shop020.jtl-hosting.de') + #create_security_policy('shop022.jtl-hosting.de') + #create_security_policy('shop000.jtl-hosting.de') + #create_security_policy('shop051.jtl-hosting.de') + create_security_policy('shop009.jtl-hosting.de') + + +if __name__ == "__main__": + main() diff --git a/03_create_sg_link11.py b/03_create_sg_link11.py new file mode 100755 index 0000000..2605109 --- /dev/null +++ b/03_create_sg_link11.py @@ -0,0 +1,66 @@ +#!/bin/python +from env import * +import requests +import json + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def sanitize_entry_id(domain): + """Erstellt eine gültige entry_id ohne Punkte, wie von der API gefordert.""" + return domain.replace(".", "-") + + +def create_server_group(domain, security_policy): + entry_id = sanitize_entry_id(domain) + url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/server-groups/{entry_id}" + + payload = { + "id": entry_id, + "challenge_cookie_domain": "$host", + "description": f"Automatisch erstellt fuer {domain}", + "mobile_application_group": "", + "name": domain, + "proxy_template": PROXY_TEMPLATE, + "routing_profile": "__default__", + "security_policy": security_policy, + "server_names": [ + domain, + "www."+domain + ], + "ssl_certificate": "placeholder", + "client_certificate": "", + "client_certificate_mode": "off", + } + # print(payload) + print(f"\n📦 Erstelle Gruppe für {domain} → ID: {entry_id}") + response = requests.post(url, headers=HEADERS, data=json.dumps(payload)) + + if response.status_code == 201: + print(f"[✓] Server-Gruppe '{entry_id}' erfolgreich erstellt.") + elif response.status_code == 409: + print(f"[i] Gruppe '{entry_id}' existiert bereits.") + else: + print(f"[✗] Fehler bei {domain} ({entry_id}): {response.status_code} → {response.text}") + +def main(): + # === CSV-Datei einlesen === + with open("serverliste_link11.csv", "r") as file: + for line in file: + domain = line.strip() + if domain: + create_server_group(domain, 'secpol-shop009-jtl-hosting-de') + +if __name__ == "__main__": + main() diff --git a/04_create_cert_set_cert_in_sg_lb.py b/04_create_cert_set_cert_in_sg_lb.py new file mode 100755 index 0000000..e5529ec --- /dev/null +++ b/04_create_cert_set_cert_in_sg_lb.py @@ -0,0 +1,127 @@ +#!/bin/python +from env import * +import requests +import csv +import json +import time + +# === KONFIGURATION === +CONFIG_ID = "prod" +CSV_DATEI = "serverliste_link11.csv" + +# Load Balancer Settings (eintragen oder automatisch abrufen) +PROVIDER = "link11" +REGION = "global" +LISTENER = "jtlwaap-lb-prod-443" +LISTENER_PORT = 443 + +BASE_URL = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}" + +HEADERS_JSON = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} +HEADERS_GET = { + "Authorization": f"Bearer {API_TOKEN}", + "Accept": "*/*" +} + +def sanitize_entry_id(domain): + """Erstellt eine gültige entry_id ohne Punkte, wie von der API gefordert.""" + return domain.replace(".", "-") + +def domain_to_cert_id(domain): + return f"jtlwaap-{sanitize_entry_id(domain)}" + +def create_certificate(domain): + cert_id = domain_to_cert_id(domain) + url = f"{BASE_URL}/certificates/{cert_id}" + params = { + "domains": [ + domain, + "www."+domain + ] + } + + payload = { + "id": cert_id, + "le_auto_renew": True, + "le_auto_replace": True, + "le_hash": "", + "provider_links": [] + } + #return cert_id + + response = requests.post(url, headers=HEADERS_JSON, params=params, data=json.dumps(payload)) + + if response.status_code == 201: + print(f"[✓] Zertifikat erstellt: {cert_id}") + return cert_id + elif response.status_code == 409: + print(f"[i] Zertifikat bereits vorhanden: {cert_id}") + return cert_id + else: + print(f"[✗] Fehler bei Zertifikat {cert_id}: {response.status_code} → {response.text}") + return None + +def update_server_group(domain, cert_id): + entry_id = sanitize_entry_id(domain) + url = f"{BASE_URL}/server-groups/{entry_id}" + + # Servergruppe einlesen + response = requests.get(url, headers=HEADERS_JSON,) + + target=json.loads(response.text) + # Neues Zertifikat einstellen + target['ssl_certificate'] = cert_id + + # Servergruppe speichern + response = requests.put(url, headers=HEADERS_JSON, data=json.dumps(target)) + + if response.status_code == 200: + print(f"[✓] Servergruppe aktualisiert für {domain}") + else: + print(f"[✗] Fehler bei Servergruppe {domain}: {response.status_code} → {response.text}") + +def assign_to_load_balancer(domain, cert_id): + url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/load-balancers/{LISTENER}/certificates/{cert_id}" + params = { + "provider": PROVIDER, + "region": REGION, + "listener": LISTENER, + "listener-port": LISTENER_PORT + } + + response = requests.put(url, headers=HEADERS_JSON, params=params) + + if response.status_code == 200: + print(f"[✓] Zertifikat dem Load Balancer zugewiesen: {cert_id}") + else: + print(f"[✗] Fehler beim Load Balancer für {cert_id}: {response.status_code} → {response.text}") + +def verarbeite_domain(domain): + print(f"\n--- Bearbeite Domain: {domain} ---") + + cert_id = create_certificate(domain) + if not cert_id: + return + + time.sleep(2) # Wartezeit, falls Zertifikaterstellung async dauert + + update_server_group(domain, cert_id) + #time.sleep(5) + assign_to_load_balancer(domain, cert_id) + +def main(): + try: + with open(CSV_DATEI, newline='') as csvfile: + reader = csv.reader(csvfile) + for row in reader: + domain = row[0].strip() + if domain: + verarbeite_domain(domain) + except Exception as e: + print(f"[!] Fehler beim Lesen der CSV: {e}") + +if __name__ == "__main__": + main() diff --git a/README.md b/README.md new file mode 100644 index 0000000..700b664 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Siehe https://jtl-software.atlassian.net/wiki/spaces/TH/pages/491683992/Link11+einrichten diff --git a/certtest.py b/certtest.py new file mode 100755 index 0000000..099babb --- /dev/null +++ b/certtest.py @@ -0,0 +1,54 @@ +#!/bin/python +from env import * +import requests +import csv +import json +import time + +# === KONFIGURATION === +CONFIG_ID = "prod" + +# Load Balancer Settings (eintragen oder automatisch abrufen) +PROVIDER = "link11" +REGION = "global" +LISTENER = "jtlwaap-lb-prod-443" +LISTENER_PORT = 443 + +HEADERS_JSON = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} +HEADERS_GET = { + "Authorization": f"Bearer {API_TOKEN}", + "Accept": "*/*" +} + +def sanitize_entry_id(domain): + """Erstellt eine gültige entry_id ohne Punkte, wie von der API gefordert.""" + return domain.replace(".", "-") + +def domain_to_cert_id(domain): + return f"jtlwaap-{sanitize_entry_id(domain)}" + +def assign_to_load_balancer(cert_id): + url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/load-balancers/{LISTENER}/certificates/{cert_id}" + params = { + "provider": PROVIDER, + "region": REGION, + "listener": LISTENER, + "listener-port": LISTENER_PORT + } + + response = requests.put(url, headers=HEADERS_JSON, params=params) + + if response.status_code == 200: + print(f"[✓] Zertifikat dem Load Balancer zugewiesen: {cert_id}") + else: + print(f"[✗] Fehler beim Load Balancer für {cert_id}: {response.status_code} → {response.text}") + + +def main(): + assign_to_load_balancer('jtlwaap-eb-autotest2-shop000-jtl-hosting-de') + +if __name__ == "__main__": + main() diff --git a/get_backend_services_link11.py b/get_backend_services_link11.py new file mode 100755 index 0000000..8881f66 --- /dev/null +++ b/get_backend_services_link11.py @@ -0,0 +1,54 @@ +#!/bin/python +import requests +import json +import pprint + +# === Konfiguration === +API_TOKEN = "dvGLKQzkJ4wvIXLExQj3jVlyalysTdy2Xp3QtcblI0gmDotnD_xywsyao9pU25y1" +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen +SECURITY_POLICY = "16fbf6d51b17" # z. B. Shop022 +# SECURITY_POLICY = "3f7a521c6570" # Shop023 +# SECURITY_POLICY = "9cc8dd695d5c" # Shop024 +# SECURITY_POLICY = "1f707fb18483" # Shop028 + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def get_security_policy(policy): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/backend-services" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von backend-services erfolgreich.") + else: + print(f"[✗] Fehler bei ({policy}): {response.status_code} → {response.text}") + #print(response.text) + res=json.loads(response.text) + pprint.pp(res) + ''' + for key,value in res.items(): + if ( key != "items" ): + print (key, value, "\n") + else: + print(key) + for items in value: + for key2, value2 in items.items(): + print(key2, value2) + ''' +def main(): + get_security_policy(SECURITY_POLICY) + +# === CSV-Datei einlesen === +if __name__ == "__main__": + main() diff --git a/get_certificates_link11.py b/get_certificates_link11.py new file mode 100755 index 0000000..915bb5b --- /dev/null +++ b/get_certificates_link11.py @@ -0,0 +1,45 @@ +#!/bin/python +from env import * +import requests +import json +import pprint + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen +SECURITY_POLICY = "16fbf6d51b17" # z. B. Shop022 +# SECURITY_POLICY = "3f7a521c6570" # Shop023 +# SECURITY_POLICY = "9cc8dd695d5c" # Shop024 +# SECURITY_POLICY = "1f707fb18483" # Shop028 + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def get_server_groups(): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/certificates" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von server groups erfolgreich.") + else: + print(f"[✗] Fehler bei Abfrage von server groups): {response.status_code} → {response.text}") + #print(response.text) + res=json.loads(response.text) + pprint.pp(res) + +def main(): + get_server_groups() + +# === CSV-Datei einlesen === +if __name__ == "__main__": + main() diff --git a/get_load_balancers_link11.py b/get_load_balancers_link11.py new file mode 100755 index 0000000..f7f8fcc --- /dev/null +++ b/get_load_balancers_link11.py @@ -0,0 +1,55 @@ +#!/bin/python +from env import * +import requests +import json +import pprint + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen +SECURITY_POLICY = "16fbf6d51b17" # z. B. Shop022 +# SECURITY_POLICY = "3f7a521c6570" # Shop023 +# SECURITY_POLICY = "9cc8dd695d5c" # Shop024 +# SECURITY_POLICY = "1f707fb18483" # Shop028 + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def get_server_groups(): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/load-balancers" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von load balancers erfolgreich.") + else: + print(f"[✗] Fehler bei Abfrage von load balancers): {response.status_code} → {response.text}") + #print(response.text) + res=json.loads(response.text) + ''' + for key,value in res.items(): + if ( key != "items" ): + print (key, value, "\n") + else: + for items in value: # Value enthält einen einzelnen Load Balancer + if ( key != "certificates" ): + print (value, "\n") + else: + print(key2, value2) + ''' + pprint.pp(res) +def main(): + get_server_groups() + +# === CSV-Datei einlesen === +if __name__ == "__main__": + main() diff --git a/get_security_policy_link11.py b/get_security_policy_link11.py new file mode 100755 index 0000000..56305e6 --- /dev/null +++ b/get_security_policy_link11.py @@ -0,0 +1,58 @@ +#!/bin/python +from env import * +import requests +import json +import pprint + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen, dieses dient als Vorlage +SECURITY_POLICY = "secpol-shop022-jtl-hosting-de" # z. B. Shop022 +# SECURITY_POLICY = "3f7a521c6570" # Shop023 +# SECURITY_POLICY = "9cc8dd695d5c" # Shop024 +# SECURITY_POLICY = "1f707fb18483" # Shop028 + +# Backend Services, nur einen aktiv lassen +BACKEND_SERVICE = "backend-shop022-jtl-hosting-de" + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def get_security_policy(policy): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/security-policies/{policy}" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von Security policy '{policy}' erfolgreich.") + else: + print(f"[✗] Fehler bei ({policy}): {response.status_code} → {response.text}") + #print(response.text) + res=json.loads(response.text) + pprint.pp(res) + ''' + for key,value in res.items(): + if ( key != "map" ): + print (key, value, "\n") + else: + print(key) + for items in value: + for key2, value2 in items.items(): + print(key2, value2) + ''' + +def main(): + get_security_policy(SECURITY_POLICY) + +# === CSV-Datei einlesen === +if __name__ == "__main__": + main() diff --git a/get_server_groups_link11.py b/get_server_groups_link11.py new file mode 100755 index 0000000..2403367 --- /dev/null +++ b/get_server_groups_link11.py @@ -0,0 +1,57 @@ +#!/bin/python +from env import * +import requests +import json +import pprint + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen +SECURITY_POLICY = "16fbf6d51b17" # z. B. Shop022 +# SECURITY_POLICY = "3f7a521c6570" # Shop023 +# SECURITY_POLICY = "9cc8dd695d5c" # Shop024 +# SECURITY_POLICY = "1f707fb18483" # Shop028 + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def get_server_groups(): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/server-groups" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von server groups erfolgreich.") + else: + print(f"[✗] Fehler bei Abfrage von server groups): {response.status_code} → {response.text}") + #print(response.text) + res=json.loads(response.text) + pprint.pp(res) + ''' + for key,value in res.items(): + if ( key != "items" ): + print (key, value, "\n") + else: + print(key) + for items in value: # Value enthält eine einzelne Server Group + for key2, value2 in items.items(): + if ( (key2 == "security_policy") and (value2 == "16fbf6d51b17") ): + value2 = "secpol-shop022-jtl-hosting-de" + print(key2, value2) + ''' + +def main(): + get_server_groups() + +# === CSV-Datei einlesen === +if __name__ == "__main__": + main() diff --git a/serverliste_link11.csv b/serverliste_link11.csv new file mode 100644 index 0000000..5243987 --- /dev/null +++ b/serverliste_link11.csv @@ -0,0 +1 @@ +bida-industry.com diff --git a/shop001.csv b/shop001.csv new file mode 100644 index 0000000..f541f89 --- /dev/null +++ b/shop001.csv @@ -0,0 +1,23 @@ +az-sportline.de +bait-tools.de +bellbie.de +bellstedt-shop.de +bluespoon.de +efe-multimedia.de +getek-gmbh.de +goodtrade-b2b.de +gruene-reparatur.de +heatpaxx.de +jawerk.de +kombitex-shop.com +motorteile-online.de +musicfactory.tv +nordkauf.de +savageprofi.de +schmidtohg.de +smartshop-global.com +stoffparadies-zauberfee.de +storesys.de +toci.de +trendykids.de +vacano-gmbh.de diff --git a/shop002.csv b/shop002.csv new file mode 100644 index 0000000..0673190 --- /dev/null +++ b/shop002.csv @@ -0,0 +1,21 @@ +101golf.de +a-handels.de +antirutsch-shop.de +badazzcustoms-germany.shop +baustein-shop.net +cordoba-buch.de +diskuszucht-piwowarski-shop.de +duftmoment.de +fliesenhorizont.de +geoweinhaus.de +gp-metallum.de +hochdruck-shop.de +karl-jenter-shop.eu +landcruiser-parts.de +metalizer-records.de +mtw-tools.de +perfecto-futternapf.de +shop-behrend-sgt.de +teich-center.de +tueren-plus-fenster.de +zenris-group.de diff --git a/shop006.csv b/shop006.csv new file mode 100644 index 0000000..91ff3dc --- /dev/null +++ b/shop006.csv @@ -0,0 +1,23 @@ +armyshop-hoenig.de +barracuda-online.de +bikeside.de +brennstoff-koblenz.de +display-order-shop.de +gebetsfaehnchen.de +goods-for-people.de +hosenmode.de +hund-natuerlich.de +lier24.com +marios-fliegendose.de +meinkiosk24.de +namenspatron.de +prisos.de +rearseatdeletes-420.com +scorpio-shop.de +selbermachen-versand.de +slimraven-shop.de +spiel-und-modellbau.com +sportfreund24.de +stefanies-stoffzauber.de +weserbootshop.de +widmann-automation.net diff --git a/shop009.csv b/shop009.csv new file mode 100644 index 0000000..58a6368 --- /dev/null +++ b/shop009.csv @@ -0,0 +1,2 @@ +schuettec.de +bida-industry.de diff --git a/shop012.csv b/shop012.csv new file mode 100644 index 0000000..f0b99a7 --- /dev/null +++ b/shop012.csv @@ -0,0 +1,26 @@ +co-comp.de +coffeeshop-oberpfalz.de +dogs-and-more.at +donau-wald-kakteen.de +extrem-bad.de +galaxymed.de +handykaputt.de +hellas-foods.de +hs-sound.de +kfz-atd.de +lead-adventure.de +mattenwerk.eu +maulberger-shop.de +piercing-express.com +pinion-bikes.de +poseidon-angelsport.de +pure-corde-shop.com +pvcfittings.at +shop-fuelfriend.de +simplywine.at +spielgeist.de +sport-imperia.com +sys2sell.de +tcgwarehouse.de +the-crochet.at +tunemybike.de diff --git a/shop013.csv b/shop013.csv new file mode 100644 index 0000000..2ac0cfc --- /dev/null +++ b/shop013.csv @@ -0,0 +1,21 @@ +cice.de +corseartcarparts.de +dogfilous.com +dwstore.de +eurorein.de +feuerwerkshop-frankfurt.de +golfversand.de +hansepack24.com +jakobsweg-bewahrer.de +karthaeuser-muehle.shop +kennzeichenhalterung.de +kettenschmie.de +lohofol.com +mitbringsel.shop +napoliconnection-shop.de +onlineshop-kueche.de +qb-insects.de +sportkoch.at +wirkwarenhaus.de +xn--zhler-plattform-0kb.de +shop.catsonappletrees.de diff --git a/shop016.csv b/shop016.csv new file mode 100644 index 0000000..49bc3d3 --- /dev/null +++ b/shop016.csv @@ -0,0 +1,28 @@ +7-lights.de +ab-versand.de +abc-brandschutz.de +almhonig.at +bike-3.de +bike-quad-shop.de +biketools24.de +bionis-shop.de +bos-tec.com +cinestar-order.de +dancetowels.com +deinmalershop.de +dragasias-foods.com +haushalts-profis.de +kolibri-24.ch +peaa-shop.de +placeofvape.shop +ro-electronic.de +rosenauer-kg.de +saporino.de +spielzeugshop-berlin.de +steinkorb-gabione.de +tabletop-art.de +thermometerwelt.de +trades-best.de +wasgutestrinken.de +waterworld24.com +zauberfeder-shop.de diff --git a/shop018.csv b/shop018.csv new file mode 100644 index 0000000..019320d --- /dev/null +++ b/shop018.csv @@ -0,0 +1,27 @@ +107-store.de +123autopflegeshop.de +akkijewelry.com +anmetec-shop.de +apiformes.de +baitshop.at +basix1.de +bayern-hof.shop +bonaval.shop +chiropraktik-shop.eu +color-your-nails.de +garnelfe.de +guertel-vmp.de +herzog-kita-tee.de +jahrmarktbonbon.de +labiteagnitevi.eu +lafiore24.de +levowear.de +limondo.shop +massage-gaertringen.de +mkk-pyrohandel.de +modellbahn-nord.at +mtarchery.com +pixiemania.net +regoh.de +tapeshop.eu +zuendstoff-feuerwerkstechnik.de diff --git a/shop020.csv b/shop020.csv new file mode 100644 index 0000000..c90671e --- /dev/null +++ b/shop020.csv @@ -0,0 +1,26 @@ +artlaender-angelzentrum.de +b2b-pv.de +cannabis-samen-steckling.de +coriko.de +dasa-tec.de +daystarone.de +diekleinewerft.de +fideo-online.de +foerg-flyfishing.de +hannes-hawaii-shop.de +hypoka-haustechnik24.de +kiddies-geschenkewelt.de +larpzeit-shop.de +leistenhammer.de +loveafair-weimar.de +ms-beschlaege.de +olivenholz-design.de +premium-kollektion.de +schnaeppchenkiste.live +schnupper-stuebchen.de +sevendustysisters.de +tierverliebt.shop +topsell24.com +traderbiene.de +ulfbo.com +weidewaechter.com diff --git a/shop025.csv b/shop025.csv new file mode 100644 index 0000000..cbc558a --- /dev/null +++ b/shop025.csv @@ -0,0 +1,26 @@ +123jagd.de +alecso.de +b2b-sasagroup.de +babyvilla.de +bergstraesser-fitness-wellness.de +boillshop.com +buy21.de +cargoworkbench.com +cubiculum-shop.de +custom-junkies.com +das-falkenkind.de +deutsche-kunstblume-shop.de +dkunert.de +druckluft-welt.de +e-schnaeppchenkauf.de +fischzucht-koicenter.de +grownert.de +makoen.com +mas-sales.shop +megaprofi-business.com +musicfactorystore.de +shadesign.de +tackle-company.de +thundelec.at +ww-boule.de +yura-raeder.com diff --git a/shop026.csv b/shop026.csv new file mode 100644 index 0000000..36ac5c4 --- /dev/null +++ b/shop026.csv @@ -0,0 +1,18 @@ +ascaris-kauartikel.de +b1-kuechenshop.de +corexxtrading.de +eliah-sahil.com +funundsport.de +gandeshop.de +go-modellbau.de +kingtechturbine.lu +martin-elektronik.de +mbw-electronic-online.de +olivenholzprodukte.de +orkansports.de +pulox.de +shop-asi.de +spiele-teufel.com +stillvaping24.de +strike.eu +teichhandel-24.de diff --git a/shop027.csv b/shop027.csv new file mode 100644 index 0000000..100bfcc --- /dev/null +++ b/shop027.csv @@ -0,0 +1,20 @@ +bike-prof.de +blazing-cards.de +bubblestore.de +cretanoil.de +de-tronik.de +doghouse24.de +flexible-computers.de +gartenbahnshop.de +haesa.de +hms-shop24.de +hucklebuck-finja.de +magierspiele.de +monisbastelkiste.de +schloss-beschlag.com +shisha-tankstelle.de +soel-shop.de +soul-distribution.com +spielwaren-laumann.de +wiesenknopf-kaninchenfutter.de +wolldealer24.de diff --git a/shop028.csv b/shop028.csv new file mode 100644 index 0000000..577e384 --- /dev/null +++ b/shop028.csv @@ -0,0 +1,27 @@ +alpa-industrielack.de +angelcenter-voegler.de +badiwo.net +bio-balsam.de +bleigussformen-shop.de +brenox.de +business-ausstatter.de +dampfshopsteinfurt.de +ehawa-shop.de +ersatzteilzone.at +gartenundtierbedarf.de +hubini-shop.com +hundebettenmanufaktur.de +meine-kleine-eisenbahn.de +mt-automotive-parts.de +mtautoteile.de +reifenzubehoer-online.de +risto-shop.de +santo-tierfutter-zubehoer.de +schoenes-wohnen-24.de +sinneswerkfreiburg.de +solar-lange.shop +spar-paradies.eu +sport-shop-fischbach.de +theos-werkzeuge.eu +wolle-socken.de +uhlig-kakteen.de diff --git a/shop029.csv b/shop029.csv new file mode 100644 index 0000000..a02c781 --- /dev/null +++ b/shop029.csv @@ -0,0 +1,22 @@ +anke-s-dampferhafen.de +bauking-intercompany.de +bestreiniger.de +bodywin.de +cleansv-shop.de +delight.de +diesel-tanks.de +farben-fischer.shop +hilltronik.de +hutx.de +hypoka-haustechnik24.de +josef.shop +kameraclub.de +ktc-tec.de +kunsthandwerkstube.de +landmaschinenteile-thull.de +looney-toys.at +m-sale.de +schaedlingsstop.com +technic24.eu +teekontor-schott.de +theob2b.de diff --git a/shop031.csv b/shop031.csv new file mode 100644 index 0000000..9f3219f --- /dev/null +++ b/shop031.csv @@ -0,0 +1,22 @@ +badosan.de +broshrimp.de +carocase.com +fgb-rescuetechnik.shop +hannoversballonladen.de +jackets-to-go.de +kaffee-wahler.com +korsettshop.at +kynoshop.de +lagercontainerxxl.at +my-smoker24.de +mykima.de +printeramerch.de +sdampferle-spiele.de +sieg-machines.de +society-beauty.de +sweet-sin.de +walzos.de +werkstattausruestung-service.de +westerwald-shop.de +wischersmotoshop.de +zeitgeist-shop.com diff --git a/shop034.csv b/shop034.csv new file mode 100644 index 0000000..71743b4 --- /dev/null +++ b/shop034.csv @@ -0,0 +1,24 @@ +alpinsport-basis.de +bankrottstore.com +bedfordparts.de +boeco-gmbh.de +brennschneiden.de +deinsporthaus.de +fashion-unikat.de +gartenfiguren.de +gingerbeard3d.de +jjgmbh.de +klima-express-shop.de +lusitero.com +mein-schlafkomfort.de +mixdrink24.de +pferdeliebe.de +praemoo.com +rms-skituning.de +skani-shop.de +smthandel.de +superjuju.biz +terschluesen-shop.de +veloboutique.eu +xn--kanapee-mbel-djb.de +zwergig.de diff --git a/shop037.csv b/shop037.csv new file mode 100644 index 0000000..d91b710 --- /dev/null +++ b/shop037.csv @@ -0,0 +1,21 @@ +antikissimo.de +baubeschlag.shop +bikediscount.at +blublife.de +dcsportshop.de +fantic26.de +gotec-shop.com +interluxe.de +kartonkoenig-shop.de +kaufdochwasduwillst.de +ludwig-pfaff.de +mahafaly.de +myschmuckwelt.de +photolux-shopping.de +reitsport-hugenberg.de +strickkontor.de +tellurian-games.de +uhrig-autoteile.de +uwesbienenkorb.de +valhalla-nutritionstore.de +vffowbuchverkauf.de diff --git a/shop042.csv b/shop042.csv new file mode 100644 index 0000000..4a79b4b --- /dev/null +++ b/shop042.csv @@ -0,0 +1,17 @@ +3dtec-ek.de +alsterduene.de +augsburger-angelcenter-shop.com +best-nutrition.de +fendt-ersatzteile24.de +futterpan.de +hussenkoenig.de +liquor-store.org +neumann-gewuerze.de +orangedecor.de +puremoda.de +tackle-master.de +tbf-shop.de +udopea.de +veganversand-lebensweise.eu +xxlgrosshandel.de +yodasdata.biz diff --git a/shop044.csv b/shop044.csv new file mode 100644 index 0000000..09db39b --- /dev/null +++ b/shop044.csv @@ -0,0 +1,20 @@ +acrylcase.com +anhaengerteilespezi.de +anigaru.de +bauking-marketingportal.de +bavarian-nuts.de +bos-mounts.de +egesat.de +forellengrund-shop.de +garten-direkt24.de +kastaun-dach.shop +king-spa.de +kroeger-tiernahrung.com +manufaktur-lichtbogen.de +naturladen-feuchtwangen.de +siegelringe-hersteller.de +sturmbude.de +tirolmusikverlag.at +tomundpatty.de +zooherz.de +gastroline24.net diff --git a/shop045.csv b/shop045.csv new file mode 100644 index 0000000..66a9184 --- /dev/null +++ b/shop045.csv @@ -0,0 +1,22 @@ +alittlebitmorecolor.de +all4water.de +bestpricegeek.de +bg-sicherheitstechnik.de +cse-technik.de +dein-schrotti.de +der-kartshop.de +espressoxxl.de +firefly-crew-shop.de +grad-betonzaeune.de +ihb-shop.de +junghaehnel.de +marken-waescheshop.de +medizinmannshop.de +modellbau-nds.de +ortho24.at +plastidip-sale.com +sg-schmuck.de +steresa-fishing.de +toni-clark-shop.com +vorteil-led.de +zok-regattahandel.de diff --git a/shop046.csv b/shop046.csv new file mode 100644 index 0000000..3b7d993 --- /dev/null +++ b/shop046.csv @@ -0,0 +1,22 @@ +air-suspension-parts.de +allgaeu-triathlon-shop.de +cod-baits.de +egetel.de +elektrokon.de +gastro-shop-24.com +handysparkauf.de +hdt-wickelaufsatz.de +itemstar-shop.de +nordostseeteekontor.de +onemanseries.shop +peters-barf-service.com +phmusicshop.at +qbparts.com +raubfischreaktor.de +rostdoc.de +sanide24.de +sportvibrations.com +svsboerse.com +top-messtechnik.com +tselikas-greekdelights.de +whisky-corner-ruesselsheim.de diff --git a/shop051.csv b/shop051.csv new file mode 100644 index 0000000..1634761 --- /dev/null +++ b/shop051.csv @@ -0,0 +1,20 @@ +aqua-fu-tec.de +berndt-gloeckner.eu +dasstaubsaugercenter.de +eiscold.de +ersatzteilcenter.net +fahrersitze.de +gorilla-parts.de +guwi.de +jtl-beispiel.de +laudi-versand.de +lovelyness-shop.de +naehplatzl.at +onlinesurfshop.de +refurbshop24.de +repaircenter24.ch +rollladenrolltor.de +sac-online-world.de +schneider-consulting-elektronik.de +vapehaus24.de +zigarre-whisky.de diff --git a/shop056.csv b/shop056.csv new file mode 100644 index 0000000..1f7ad55 --- /dev/null +++ b/shop056.csv @@ -0,0 +1,23 @@ +cardsparadise.com +drugcos.de +etonerkartusche.ch +filzwolle.de +florascent-apothecary.com +forellen-fischen.de +handwerksmontagen.at +harzplant-seeds.de +hd-online-shop.com +henningsallerlei.de +kleene-racker.de +lanz-kundendienst.de +marderfallen.de +panterapack.com +piercing-express.com +remotaparts.de +scootergarage.shop +toeller.shop +tragetaschen-onlineshop.de +tuerbeschlaege24.de +waschfreaks.de +worldofgourmet.de +wurstschmitz-shop.de diff --git a/shop999.csv b/shop999.csv new file mode 100644 index 0000000..3bd45b1 --- /dev/null +++ b/shop999.csv @@ -0,0 +1,84 @@ +3shop-jg.shop999.jtl-hosting.de +5shop-fp.shop999.jtl-hosting.de +5shop-mh.shop999.jtl-hosting.de +abran.shop999.jtl-hosting.de +akshop.shop999.jtl-hosting.de +az-test.shop999.jtl-hosting.de +basicbey.shop999.jtl-hosting.de +bjoern.shop999.jtl-hosting.de +bonnkenobi.shop999.jtl-hosting.de +brancho.shop999.jtl-hosting.de +buildtest-rs.shop999.jtl-hosting.de +connect-fp.shop999.jtl-hosting.de +daktuell-test.shop999.jtl-hosting.de +danny.shop5.shop999.jtl-hosting.de +dauzis.shop999.jtl-hosting.de +dexshop.shop999.jtl-hosting.de +dh-master.shop999.jtl-hosting.de +dheil.shop999.jtl-hosting.de +dilaz-master.shop999.jtl-hosting.de +dilaz-test.shop999.jtl-hosting.de +dilaz2-test.shop999.jtl-hosting.de +dlattek.shop999.jtl-hosting.de +dw.shop999.jtl-hosting.de +eazysales.shop999.jtl-hosting.de +fhenn.shop999.jtl-hosting.de +gbuettner.shop999.jtl-hosting.de +hilkes-shop.shop999.jtl-hosting.de +ilona-2.shop999.jtl-hosting.de +ilona.shop999.jtl-hosting.de +jf43shop.shop999.jtl-hosting.de +jk-test.shop999.jtl-hosting.de +joeshop.shop999.jtl-hosting.de +jtl-hosting-emailtest.de +jtlshop-cschneider01.shop999.jtl-hosting.de +kh-test.shop999.jtl-hosting.de +lh-5.shop999.jtl-hosting.de +link11-testshop.shop999.jtl-hosting.de +master-lh.shop999.jtl-hosting.de +mimo02.shop999.de +mimo505.shop999.jtl-hosting.de +mko001.shop999.jtl-hosting.de +mvoelker2.shop999.jtl-hosting.de +mytestshop.shop999.jtl-hosting.de +ollishop.shop999.jtl-hosting.de +pc-test.shop999.jtl-hosting.de +pegasus-jtl.shop999.jtl-hosting.de +pf.shop999.jtl-hosting.de +pg-4.shop999.jtl-hosting.de +pg-5.shop999.jtl-hosting.de +pg-m.shop999.jtl-hosting.de +pierre.shop999.jtl-hosting.de +pk90e62065.shop999.jtl-hosting.de +ponsen-testshop.shop999.jtl-hosting.de +prime.shop999.jtl-hosting.de +probearbeiten.shop999.jtl-hosting.de +qalokalmaxsh1.shop999.jtl-hosting.de +qalokalmaxsh2.shop999.jtl-hosting.de +reuticon999.jtl-hosting.de +rk-1.shop999.jtl-hosting.de +rk-2.shop999.jtl-hosting.de +rk-3.shop999.jtl-hosting.de +robojul.shop999.jtl-hosting.de +shipping.shop999.jtl-hosting.de +shop4-jg.de.shop999.jtl-hosting.de +shop5-fm.shop999.jtl-hosting.de +shop5-mstickel.shop999.jtl-hosting.de +shop5-test-cr.shop999.jtl-hosting.de +shopowner.shop999.jtl-hosting.de +stapelshop.shop999.jtl-hosting.de +test-406-rs.shop999.jtl-hosting.de +test-500-rs.shop999.jtl-hosting.de +test-branch-rs.shop999.jtl-hosting.de +themaster.shop999.jtl-hosting.de +thoffmann.shop999.jtl-hosting.de +timniko.shop999.jtl-hosting.de +underground.shop999.jtl-hosting.de +update-delete-repeat.shop999.jtl-hosting.de +video.shop999.jtl-hosting.de +wchajan-1.shop999.jtl-hosting.de +webstollen.shop999.jtl-hosting.de +wps4.shop999.jtl-hosting.de +wps5.shop999.jtl-hosting.de +wpsm.shop999.jtl-hosting.de +zafira.shop999.jtl-hosting.de diff --git a/sync_security_policies_link11.py b/sync_security_policies_link11.py new file mode 100755 index 0000000..ea8649c --- /dev/null +++ b/sync_security_policies_link11.py @@ -0,0 +1,122 @@ +#!/bin/python +from env import * +import requests +import json +import pprint + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen, dieses dient als Vorlage +SECURITY_POLICY = "secpol-p414-jtl-hosting-de" # z. B. Shop022 +# SECURITY_POLICY = "3f7a521c6570" # Shop023 +# SECURITY_POLICY = "9cc8dd695d5c" # Shop024 +# SECURITY_POLICY = "1f707fb18483" # Shop028 + +# Backend Services, nur einen aktiv lassen + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + +def domain_to_id(domain): + return domain.replace(".", "-") + +def domain_to_secpol_id(domain): + return f"secpol-{domain_to_id(domain)}" + +def domain_to_backend_id(domain): + return f"backend-{domain_to_id(domain)}" + + +def get_all_security_policies(): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/security-policies" + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von Security policies erfolgreich.") + else: + print(f"[✗] Fehler bei ({policy}): {response.status_code} → {response.text}") + return + res=json.loads(response.text) + #pprint.pp(res) + + policies=[] + for item in res['items']: + policies+={item['id']} + #pprint.pp(policies) + return(policies) + +def sync_security_policies(policy, destination): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/security-policies/{policy}" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von Security policy '{policy}' erfolgreich.") + else: + print(f"[✗] Fehler bei ({policy}): {response.status_code} → {response.text}") + return + #print(response.text) + # Hier ist die Source Security Policy + template=json.loads(response.text) + + # Nun wird die Ziel-Security-Policy eingelesen + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/security-policies/{destination}" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von Security policy '{destination}' erfolgreich.") + else: + print(f"[✗] Fehler bei ({destination}): {response.status_code} → {response.text}") + return + + target=json.loads(response.text) + + # die Pfad-Mappings werden auf die vom Template gesetzt, alles andere bleibt wie es war + target['map'] = template['map'] + + backendservice = domain_to_backend_id(target['name']) + + # Neuen Backend-Service in allen Pfaden der Security Policy setzen + for mapitem in target['map']: + if (mapitem['id'] != "__site_level__"): + mapitem['backend_service'] = backendservice + + + #print(target) + # Speichern der Target Security Policy + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/security-policies/{destination}" + + response = requests.put(url, headers=HEADERS,data=json.dumps(target)) + + if response.status_code == 200: + print(f"[✓] Security Policy '{destination}' erfolgreich gespeichert.") + else: + print(f"[✗] Fehler bei {destination}: {response.status_code} → {response.text} {response.json()}") + + +def main(): + #sync_security_policies(SECURITY_POLICY, 'secpol-shop051-jtl-hosting-de') + + policies=get_all_security_policies() + print(f"The following security policies are synced to {SECURITY_POLICY}. Is this what you want?") + for policy in policies: + if ( policy != '__default__' ) and ( policy != SECURITY_POLICY ): + print(policy) + yesno = input("Enter yes or no:") + if ( yesno == "yes" ): + for policy in policies: + if ( policy != '__default__' ) and ( policy != SECURITY_POLICY ): + sync_security_policies(SECURITY_POLICY, policy) + +# === CSV-Datei einlesen === +if __name__ == "__main__": + main() diff --git a/todelete.csv b/todelete.csv new file mode 100644 index 0000000..5a79775 --- /dev/null +++ b/todelete.csv @@ -0,0 +1,5 @@ +scorpio-shop.de +brauerei-meusel.de +meinhundshop.ch +scharfzahn-holzwerkzeuge.de +nicegameshop.com diff --git a/update_server_groups_link11.py b/update_server_groups_link11.py new file mode 100755 index 0000000..8e73a28 --- /dev/null +++ b/update_server_groups_link11.py @@ -0,0 +1,60 @@ +#!/bin/python +from env import * +import requests +import json + +# === Konfiguration === +CONFIG_ID = "prod" + +# Proxy Templates – nur einen aktiv lassen +PROXY_TEMPLATE = "f4bf25a205a5" +# PROXY_TEMPLATE = "andere_template_id" + +# Security Policies – nur einen aktiv lassen +SECURITY_POLICY = "16fbf6d51b17" # z. B. Shop022 +# SECURITY_POLICY = "3f7a521c6570" # Shop023 +# SECURITY_POLICY = "9cc8dd695d5c" # Shop024 +# SECURITY_POLICY = "1f707fb18483" # Shop028 + +# === Header für alle Requests === +HEADERS = { + "Authorization": f"Bearer {API_TOKEN}", + "Content-Type": "application/json" +} + + +def get_server_groups(): + url = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/server-groups" + + response = requests.get(url, headers=HEADERS,) + + if response.status_code == 200: + print(f"[✓] Abfrage von server groups erfolgreich.") + else: + print(f"[✗] Fehler bei Abfrage von server groups): {response.status_code} → {response.text}") + #print(response.text) + res=json.loads(response.text) + for key,value in res.items(): + if ( key != "items" ): + print (key, value, "\n") + else: + print(key) + for items in value: # Items enthält eine einzelne Server Group + for key2, value2 in items.items(): + if ( (key2 == "security_policy") and (value2 == "16fbf6d51b17") ): + items['security_policy'] = "secpol-shop022-jtl-hosting-de" + url2 = f"https://jtlwaap.app.reblaze.io/api/v4.0/conf/{CONFIG_ID}/server-groups/{items['id']}" + #print(url2) + response = requests.put(url2, headers=HEADERS,data=json.dumps(items)) + if response.status_code == 200: + print(f"[✓] Server group {items['id']} erfolgreich aktualisiert.") + else: + print(f"[✗] Fehler bei Aktualisierung von server group {items['id']}): {response.status_code} → {response.text}") + + print(key2, value2) +def main(): + get_server_groups() + +# === CSV-Datei einlesen === +if __name__ == "__main__": + main()