Initial commit.

This commit is contained in:
michael 2020-05-21 13:52:09 -05:00
commit f5f2d79d3b
5 changed files with 98 additions and 0 deletions

43
initproton Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash
set -eufo pipefail
BRIDGE=/bin/protonmail-bridge
PRINT_INFO=${PRINT_INFO:-""}
SMTP_PORT=${SMTP_PORT:-"1025"}
IMAP_PORT=${IMAP_PORT:-"1143"}
#### INIT
PASS_FILE=${PASS_FILE:-}
if [ -n "$PASS_FILE" ]; then
echo "Using PASS file."
PASS=$(cat $PASS_FILE)
fi
if ! [ -f ./initialized ]; then
gpg --generate-key --batch /tmp/gpgparams
pass init pass-key
COMMAND="login\n$EMAIL\n$PASSWORD"
RUN_2FA_LOGIN=${RUN_2FA_LOGIN:-}
if [ -n "$RUN_2FA_LOGIN" ]; then
echo "Using MFA code."
COMMAND="$COMMAND\n$MFA_CODE"
fi
echo "Executing COMMAND: $COMMAND"
echo -e "$COMMAND" | $BRIDGE --cli
touch ./initialized
fi
if [ -n "$PRINT_INFO" ]; then
echo info | $BRIDGE --cli | egrep '(Username|Password)' | sort -ru
fi
# socat will make the conn appear to come from 127.0.0.1
# ProtonMail Bridge currently expects that.
# It also allows us to bind to the real ports :)
socat TCP-LISTEN:$SMTP_PORT,fork TCP:127.0.0.1:1025 &
socat TCP-LISTEN:$IMAP_PORT,fork TCP:127.0.0.1:1143 &
# Fake a terminal, so it does not quit because of EOF...
rm -f faketty
mkfifo faketty
cat faketty | $BRIDGE --cli