forked from shenxn/protonmail-bridge-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
42 lines (33 loc) · 766 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# thanks to https://github.com/spameier/proton-bridge-docker
set -ex
BRIDGE="/protonmail/proton-bridge --cli"
BRIDGE_EXTRA_ARGS="--log-level info"
FIFO="/fifo"
# Initialize
if [[ $1 == init ]]; then
# initialize gpg if necessary
if ! [ -d /root/.gnupg ]; then
gpg --generate-key --batch << 'EOF'
%no-protection
%echo Generating GPG key
Key-Type:RSA
Key-Length:2048
Name-Real:pass-key
Expire-Date:0
%commit
EOF
fi
# initialize pass if necessary
if ! [ -d /root/.password-store ]; then
pass init pass-key
fi
# login to ProtonMail if neccessary
if ! [ -d /root/.cache/protonmail/bridge ]; then
${BRIDGE} $@
fi
else
# keep stdin open
[ -e ${FIFO} ] || mkfifo ${FIFO}
cat ${FIFO} | ${BRIDGE} ${BRIDGE_EXTRA_ARGS}
fi