Initial commit.
This commit is contained in:
commit
f5f2d79d3b
5 changed files with 98 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
.env
|
||||||
31
Dockerfile
Normal file
31
Dockerfile
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
FROM golang:1.14-alpine as build
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
libsecret-dev \
|
||||||
|
make \
|
||||||
|
musl-dev
|
||||||
|
WORKDIR /usr/src
|
||||||
|
RUN git clone https://github.com/ProtonMail/proton-bridge.git proton-bridge
|
||||||
|
WORKDIR /usr/src/proton-bridge
|
||||||
|
RUN make build-nogui
|
||||||
|
|
||||||
|
FROM alpine:edge
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
ENV SMTP_PORT 1025
|
||||||
|
ENV IMAP_PORT 1143
|
||||||
|
COPY --from=build /usr/src/proton-bridge/Desktop-Bridge /bin/protonmail-bridge
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
libsecret \
|
||||||
|
pass \
|
||||||
|
socat \
|
||||||
|
su-exec
|
||||||
|
COPY entrypoint /bin/
|
||||||
|
RUN chmod +x /bin/entrypoint
|
||||||
|
COPY initproton /bin/
|
||||||
|
RUN chmod +x /bin/initproton
|
||||||
|
COPY gpgparams /tmp/
|
||||||
|
WORKDIR /var/lib/proton
|
||||||
|
ENTRYPOINT ["/bin/entrypoint"]
|
||||||
|
CMD ["/bin/initproton"]
|
||||||
15
entrypoint
Executable file
15
entrypoint
Executable file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Add local user
|
||||||
|
# Either use the PUID/PGID if passed in at runtime or
|
||||||
|
# fallback
|
||||||
|
|
||||||
|
USER_ID=${PUID:-9001}
|
||||||
|
GROUP_ID=${PGID:-$USER_ID}
|
||||||
|
echo "Starting with UID : $USER_ID:$GROUP_ID"
|
||||||
|
addgroup -g $GROUP_ID proton
|
||||||
|
adduser -D -u $USER_ID -G proton -h /var/lib/proton -s /bin/bash proton
|
||||||
|
chown -R ${USER_ID}:${GROUP_ID} /var/lib/proton
|
||||||
|
|
||||||
|
export HOME=/var/lib/proton
|
||||||
|
|
||||||
|
exec /sbin/su-exec proton "$@"
|
||||||
8
gpgparams
Executable file
8
gpgparams
Executable file
|
|
@ -0,0 +1,8 @@
|
||||||
|
%no-protection
|
||||||
|
%echo Generating a basic OpenPGP key
|
||||||
|
Key-Type: RSA
|
||||||
|
Key-Length: 2048
|
||||||
|
Name-Real: pass-key
|
||||||
|
Expire-Date: 0
|
||||||
|
%commit
|
||||||
|
%echo done
|
||||||
43
initproton
Executable file
43
initproton
Executable 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue