tuya-ipc-terminal/tuya_auth_login.exp aktualisiert
This commit is contained in:
parent
1c69804531
commit
06b14e7dd9
@ -1,66 +1,57 @@
|
|||||||
#!/usr/bin/expect -f
|
#!/usr/bin/expect -f
|
||||||
|
|
||||||
# --- START SUPER-DEBUG ---
|
# Aktiviere internes Debugging, um den Ablauf zu verfolgen
|
||||||
# Aktiviere das interne Debugging von Expect. Dies erzeugt SEHR viel Output.
|
|
||||||
exp_internal 1
|
exp_internal 1
|
||||||
puts "DEBUG: Expect-Skript gestartet. Internes Debugging ist aktiviert."
|
puts "DEBUG: Expect-Skript gestartet."
|
||||||
# --- ENDE SUPER-DEBUG ---
|
|
||||||
|
|
||||||
# Entferne den alten Konfigurationsordner, um eine Neu-Authentifizierung zu erzwingen.
|
# Entferne alte Konfiguration, um eine neue Sitzung zu erzwingen
|
||||||
set config_dir "/config/.tuya-data"
|
set config_dir "/config/.tuya-data"
|
||||||
puts "DEBUG: Prüfe auf Verzeichnis: $config_dir"
|
|
||||||
if { [file isdirectory $config_dir] } {
|
if { [file isdirectory $config_dir] } {
|
||||||
puts "DEBUG: Altes Konfigurationsverzeichnis gefunden. Wird entfernt."
|
puts "DEBUG: Altes Konfigurationsverzeichnis gefunden, wird entfernt."
|
||||||
if {[catch {file delete -force -- $config_dir} err]} {
|
if {[catch {file delete -force -- $config_dir} err]} {
|
||||||
puts stderr "FATAL: Konnte existierendes Verzeichnis '$config_dir' nicht löschen: $err"
|
puts stderr "FATAL: Konnte Verzeichnis '$config_dir' nicht löschen: $err"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
puts "DEBUG: Verzeichnis erfolgreich entfernt."
|
|
||||||
} else {
|
|
||||||
puts "DEBUG: Kein altes Konfigurationsverzeichnis gefunden. Fortfahren."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
puts "DEBUG: Starte den Authentifizierungsprozess..."
|
puts "DEBUG: Starte Authentifizierungsprozess."
|
||||||
set timeout 60
|
set timeout 60
|
||||||
|
|
||||||
# Lese die Eingaben
|
# Lese Eingaben
|
||||||
puts "DEBUG: Lese Region von stdin..."
|
|
||||||
gets stdin region
|
gets stdin region
|
||||||
puts "DEBUG: Region gelesen: $region"
|
|
||||||
|
|
||||||
puts "DEBUG: Lese Email von stdin..."
|
|
||||||
gets stdin email
|
gets stdin email
|
||||||
puts "DEBUG: Email gelesen: $email"
|
|
||||||
|
|
||||||
puts "DEBUG: Lese Passwort von stdin..."
|
|
||||||
gets stdin password
|
gets stdin password
|
||||||
# Das Passwort selbst nicht loggen
|
|
||||||
puts "DEBUG: Passwort wurde gelesen."
|
|
||||||
|
|
||||||
if { $region eq "" || $email eq "" || $password eq "" } {
|
if { $region eq "" || $email eq "" || $password eq "" } {
|
||||||
puts stderr "FATAL: Eine der Eingaben (Region, Email, Passwort) ist leer."
|
puts stderr "FATAL: Eine der Eingaben ist leer."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
puts "DEBUG: Starte 'spawn tuya-ipc-terminal auth add ...'"
|
|
||||||
spawn tuya-ipc-terminal auth add $region $email --password
|
spawn tuya-ipc-terminal auth add $region $email --password
|
||||||
|
|
||||||
# Interaktion
|
# --- START DER ENTSCHEIDENDEN KORREKTUR ---
|
||||||
|
# Verwende einen regulären Ausdruck (-re), der auf verschiedene Passwortabfragen reagiert.
|
||||||
|
# "Enter ?[Pp]assword:" fängt "Enter password:" und "Enter Password:" ab.
|
||||||
expect {
|
expect {
|
||||||
"Password:" {
|
-re {Password:|Enter ?[Pp]assword:?|Please enter your password:} {
|
||||||
puts "DEBUG: 'Password:' Prompt erkannt. Sende Passwort..."
|
puts "DEBUG: Passwortabfrage erkannt. Sende Passwort..."
|
||||||
send "$password\r"
|
send "$password\r"
|
||||||
puts "DEBUG: Passwort gesendet."
|
puts "DEBUG: Passwort gesendet."
|
||||||
|
# exp_continue sorgt dafür, dass das Skript auf weitere Ausgaben wartet
|
||||||
exp_continue
|
exp_continue
|
||||||
}
|
}
|
||||||
|
# --- ENDE DER KORREKTUR ---
|
||||||
|
|
||||||
"Authentication successful" {
|
"Authentication successful" {
|
||||||
puts "DEBUG: Erfolg-Nachricht 'Authentication successful' erkannt."
|
puts "DEBUG: Erfolgsmeldung 'Authentication successful' erkannt."
|
||||||
|
# Warte, bis der Prozess sich beendet hat
|
||||||
catch {expect eof}
|
catch {expect eof}
|
||||||
catch {wait}
|
catch {wait}
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
eof {
|
eof {
|
||||||
puts "DEBUG: 'eof' (End of File) vom Prozess erreicht."
|
puts "DEBUG: Prozess hat sich beendet (EOF)."
|
||||||
|
# Prüfe den Exit-Code des beendeten Prozesses
|
||||||
set exit_code [lindex [wait] 2]
|
set exit_code [lindex [wait] 2]
|
||||||
puts "DEBUG: Prozess beendet mit Exit-Code $exit_code."
|
puts "DEBUG: Prozess beendet mit Exit-Code $exit_code."
|
||||||
exit $exit_code
|
exit $exit_code
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user