protonmail-bridge/initproton
Ubuntu e523a8b15d
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Added setcap command.
2020-07-08 15:27:45 -05:00

38 lines
No EOL
993 B
Bash
Executable file

#!/bin/bash
set -eufo pipefail
BRIDGE=/bin/protonmail-bridge
FIFO=/tmp/fifo
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...
if [ ! -e "$FIFO" ]; then
mkfifo $FIFO
fi
cat $FIFO | $BRIDGE --cli