63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import os
|
||
from inwx_config import login, logout # Importiere Login/Logout aus der Konfigurationsdatei
|
||
from inwx_dns_functions import get_dns_info, add_record, update_record, delete_record # Importiere DNS-Funktionen
|
||
|
||
def main_menu():
|
||
"""Hauptmenü der CLI-Anwendung."""
|
||
|
||
# 1. Login-Daten abfragen (kann auch über Umgebungsvariablen INWX_USER/INWX_PASS gesetzt werden)
|
||
INWX_USER = os.getenv('INWX_USER')
|
||
INWX_PASS = os.getenv('INWX_PASS')
|
||
|
||
if not INWX_USER:
|
||
INWX_USER = input("Gib deinen INWX-Benutzernamen ein: ")
|
||
if not INWX_PASS:
|
||
INWX_PASS = input("Gib dein INWX-Passwort ein: ")
|
||
|
||
if not login(INWX_USER, INWX_PASS):
|
||
return
|
||
|
||
# 2. Hauptschleife
|
||
try:
|
||
while True:
|
||
# Das Menü im MC-Stil
|
||
print("\n" + "=" * 40)
|
||
print(" INWX DNS-CLI (MC-Style) - DOMAIN-VERWALTUNG")
|
||
print("=" * 40)
|
||
print("1: 🌐 **Anzeigen** (nameserver.info)")
|
||
print("---")
|
||
print("2: ➕ **Hinzufügen** (nameserver.addRecord)")
|
||
print("3: ✏️ **Ändern** (nameserver.updateRecord)")
|
||
print("4: 🗑️ **Löschen** (nameserver.deleteRecord)")
|
||
print("---")
|
||
print("9: 🚪 Logout & Beenden")
|
||
print("-" * 40)
|
||
|
||
choice = input("Wähle eine Aktion (1-4 oder 9): ").strip()
|
||
|
||
if choice == '1':
|
||
domain = input("Gib die Domain ein, deren Einträge du sehen möchtest: ").strip()
|
||
if domain:
|
||
get_dns_info(domain)
|
||
elif choice == '2':
|
||
add_record()
|
||
elif choice == '3':
|
||
update_record()
|
||
elif choice == '4':
|
||
delete_record()
|
||
elif choice == '9':
|
||
break
|
||
else:
|
||
print("Ungültige Auswahl. Bitte versuche es erneut.")
|
||
|
||
finally:
|
||
# Stelle sicher, dass immer ausgeloggt wird
|
||
logout()
|
||
|
||
if __name__ == "__main__":
|
||
main_menu()
|
||
|