You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
625 B
32 lines
625 B
6 years ago
|
#!/usr/bin/env expect
|
||
|
|
||
|
# Read the password string
|
||
|
set pass [lindex $argv 0]
|
||
|
|
||
|
# Check if password was provided
|
||
|
if { $pass == "" } {
|
||
|
puts "Usage: $argv0 <password>"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
# Disable output
|
||
|
log_user 0
|
||
|
|
||
|
# Execute password hashing script
|
||
|
spawn docker exec -it matrix-synapse /usr/local/bin/hash_password -c /data/homeserver.yaml
|
||
|
expect "Password: "
|
||
|
send "$pass\r"
|
||
|
expect "Confirm password: "
|
||
|
send "$pass\r"
|
||
|
expect "%"
|
||
|
|
||
|
# Save the hash output to a variable
|
||
|
set output $expect_out(buffer)
|
||
|
|
||
|
# Trim the whitespace
|
||
|
regexp {\S+} $output passwordHash
|
||
|
|
||
|
# Output the password hash
|
||
|
puts -nonewline stdout $passwordHash
|
||
|
close stdout
|