1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 22:21:13 +03:00
awx/tools/scripts/sign.exp

50 lines
871 B
Plaintext
Raw Normal View History

2015-09-08 03:33:08 +03:00
#!/usr/bin/expect -f
#
# Helper script to respond to passphrase prompts from the gpg command.
#
# Disable timeout
set timeout -1
# Optionally print usage message
if {[llength $argv] <= 0} {
puts "Usage: sign.exp <command>"
exit 1
}
# Process arguments
2015-09-08 03:33:08 +03:00
set command [join $argv]
if { [info exists env(PASSPHRASE) ] } {
set passphrase $env(PASSPHRASE)
} else {
set passphrase ""
}
# Run the desired command
spawn {*}$command
2015-09-08 03:33:08 +03:00
expect {
2015-09-09 20:07:09 +03:00
-nocase "enter passphrase:" {
2015-09-08 03:33:08 +03:00
send -- "$passphrase\r"
exp_continue
}
2015-09-10 01:51:23 +03:00
-nocase "enter pass phrase:" {
send -- "$passphrase\r"
exp_continue
}
timeout {
puts "expect timeout"
exit 1
}
2015-09-08 03:33:08 +03:00
eof { }
}
2015-09-08 22:43:04 +03:00
lassign [wait] pid spawnid os_error_flag retval
if {$os_error_flag == 0} {
puts "exit status: $retval"
} else {
puts "errno: $retval"
}
exit $retval