32 lines
625 B
Plaintext
32 lines
625 B
Plaintext
|
#!/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
|