This commit is contained in:
parent
80c456f19a
commit
89cff04248
1 changed files with 15 additions and 13 deletions
28
initproton
28
initproton
|
|
@ -8,31 +8,33 @@ 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" \
|
||||
if ! [ -d .gnupg ]; then
|
||||
echo -e "%no-protection\nKey-Type: RSA\nKey-Length: 4096\nName-Real: $EMAIL\nExpire-Date: 0\n%commit" \
|
||||
| gpg --generate-key --batch
|
||||
pass init pass-key
|
||||
fi
|
||||
if ! [ -d .password-store ]; then
|
||||
pass init "$EMAIL"
|
||||
fi
|
||||
if ! [ -d ~/.cache/protonmail/bridge ]; then
|
||||
COMMAND="login\n$EMAIL\n$PASSWORD"
|
||||
RUN_2FA_LOGIN=${RUN_2FA_LOGIN:-}
|
||||
if [ -n "$RUN_2FA_LOGIN" ]; then
|
||||
echo "Using MFA code."
|
||||
MFA_CODE=${MFA_CODE:-}
|
||||
if [ -n "$MFA_CODE" ]; then
|
||||
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
|
||||
ARGUMENTS="--noninteractive"
|
||||
LOG_LEVEL=${LOG_LEVEL:-}
|
||||
if [ -n "$LOG_LEVEL" ]; then
|
||||
ARGUMENTS="${ARGUMENTS} --log-level ${LOG_LEVEL}"
|
||||
fi
|
||||
cat $FIFO | $BRIDGE --cli
|
||||
|
||||
$BRIDGE $ARGUMENTS
|
||||
Loading…
Add table
Add a link
Reference in a new issue