tuya-ipc-terminal/tuya_auth_login.exp aktualisiert
This commit is contained in:
parent
47a46209ae
commit
0d0e466ff3
@ -1,39 +1,41 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
# Check if config directory exists
|
||||
# Check if the config directory already exists.
|
||||
set config_dir "/config/.tuya-data"
|
||||
if { [file isdirectory $config_dir] } {
|
||||
puts "Skipping authentication: Configuration directory already exists."
|
||||
puts "Skipping authentication: Configuration directory '$config_dir' already exists."
|
||||
exit 0
|
||||
}
|
||||
|
||||
puts "Configuration directory not found. Proceeding with email/password authentication..."
|
||||
puts "Configuration directory not found. Proceeding with authentication..."
|
||||
|
||||
set timeout 30
|
||||
|
||||
# Read inputs
|
||||
# Read the region from the first line of standard input.
|
||||
gets stdin region
|
||||
if { [eof stdin] || $region eq "" } {
|
||||
puts stderr "Error: Could not read region from stdin."
|
||||
puts stderr "Error: Could not read region from stdin or region is empty."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Read the email from the second line of standard input.
|
||||
gets stdin email
|
||||
if { [eof stdin] || $email eq "" } {
|
||||
puts stderr "Error: Could not read email from stdin."
|
||||
puts stderr "Error: Could not read email from stdin or email is empty."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Read the password from the third line of standard input.
|
||||
gets stdin password
|
||||
if { [eof stdin] || $password eq "" } {
|
||||
puts stderr "Error: Could not read password from stdin."
|
||||
puts stderr "Error: Could not read password from stdin or password is empty."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Start authentication without --qr flag
|
||||
spawn tuya-ipc-terminal auth add $region $email
|
||||
# Spawn the tuya-ipc-terminal command WITH --password flag
|
||||
spawn tuya-ipc-terminal auth add $region $email --password $password
|
||||
|
||||
# Handle different prompts
|
||||
# Handle password prompt
|
||||
expect {
|
||||
"Password:" {
|
||||
send "$password\r"
|
||||
@ -43,11 +45,22 @@ expect {
|
||||
send "$password\r"
|
||||
exp_continue
|
||||
}
|
||||
"Please enter your password:" {
|
||||
send "$password\r"
|
||||
exp_continue
|
||||
}
|
||||
"Authentication successful" {
|
||||
puts "Login successful!"
|
||||
puts "Authentication completed successfully!"
|
||||
}
|
||||
"Login successful" {
|
||||
puts "Login completed successfully!"
|
||||
}
|
||||
"Invalid credentials" {
|
||||
puts stderr "Authentication failed: Invalid credentials"
|
||||
exit 1
|
||||
}
|
||||
"Login failed" {
|
||||
puts stderr "Authentication failed - check credentials"
|
||||
puts stderr "Authentication failed: Login failed"
|
||||
exit 1
|
||||
}
|
||||
timeout {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user