hydroxide-docker
hydroxide-docker copied to clipboard
No longer working with latest Hydroxide build
It seemed the container will run properly but the info.json is no longer filled with the desired hash.
I fixed the script by resort to expect:
cat expect.sh
#!/usr/bin/expect -f
set timeout 10
spawn hydroxide auth "$env(PROTONMAIL_USER)"
expect_before {
timeout {
puts "Timeout waiting for operation"
exit 1
}
}
expect {
"Password:" {
send "$env(PROTONMAIL_PASS)\n"
}
}
expect {
"Bridge password:" {
exit 0
}
}
# Intentionally crash if hydroxide behave unexpectedly
puts "Unexpect output from hydroxide"
exit 1
cat start.sh
#!/bin/bash
printf "%s\n" "Starting Hydroxide..."
expect_result=$(./expect.sh)
if [ $? != 0 ]; then
printf "%s\n" "Hydroxide auth error"
printf "%s\n" "$expect_result"
exit 1
fi
hydroxide_hash_output=$(printf "%s" "$expect_result" | tail -n1)
printf "%s\n" "$hydroxide_hash_output"
IFS=":" read -ra hydroxide_hash_output_split <<< "$hydroxide_hash_output"
HYDROXIDE_HASH="${hydroxide_hash_output_split[1]:1}"
# get ride of "^M" at the end
HYDROXIDE_HASH=$(printf "$HYDROXIDE_HASH" | tr -d '\r')
printf "%s\n" "Logged in, user: $PROTONMAIL_USER, hash: $HYDROXIDE_HASH"
printf "{\x22user\x22: \x22$PROTONMAIL_USER\x22, \x22hash\x22: \x22$HYDROXIDE_HASH\x22}" > /info.json
# MUST host on '0.0.0.0' for the ports to pass through to other containers
# From: https://github.com/docker/compose/issues/4799#issuecomment-623504144
hydroxide -imap-host '0.0.0.0' imap &
hydroxide -smtp-host '0.0.0.0' smtp &
tail -f /dev/null
You need to install expect for obivous reasons, as it does not comes with alpine:3.9 base image.
Thanks for this. I updated my Dockerfile with COPY ./expect.sh expect.sh RUN chmod +x ./expect.sh RUN apk add expect and then changed the compose file to use PROTONMAIL_USER and PROTONMAIL_PASS as the env names.