All checks were successful
continuous-integration/drone/push Build is passing
36 lines
No EOL
965 B
Bash
Executable file
36 lines
No EOL
965 B
Bash
Executable file
#!/bin/bash
|
|
set -eufo pipefail
|
|
|
|
BRIDGE=/bin/protonmail-bridge
|
|
PRINT_INFO=${PRINT_INFO:-""}
|
|
|
|
#### INIT
|
|
PASS_FILE=${PASS_FILE:-}
|
|
if [ -n "$PASS_FILE" ]; then
|
|
echo "Using PASS file."
|
|
PASS=$(cat $PASS_FILE)
|
|
fi
|
|
|
|
if ! [ -f ./initialized ]; then
|
|
echo -e "%no-protection\nKey-Type: RSA\nKey-Length: 2048\nName-Real: $EMAIL\nExpire-Date: 0\n%commit" \
|
|
| gpg --generate-key --batch
|
|
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
|
|
|
|
# Fake a terminal, so it does not quit because of EOF...
|
|
rm -f faketty
|
|
mkfifo faketty
|
|
cat faketty | $BRIDGE --cli |