From 4164524906bb98973d8ecd804d609a3e91d9eff7 Mon Sep 17 00:00:00 2001 From: Lanubya Date: Mon, 16 Sep 2024 19:21:31 +0200 Subject: [PATCH] . --- .dockerignore | 8 ++++++++ Dockerfile | 14 +++++++++++++ ENV | 1 + VERSION | 1 + docker-compose.yml | 17 ++++++++++++++++ entrypoint.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++ gpgparams | 8 ++++++++ install.sh | 36 ++++++++++++++++++++++++++++++++++ 8 files changed, 134 insertions(+) diff --git a/.dockerignore b/.dockerignore index e69de29..9b14186 100644 --- a/.dockerignore +++ b/.dockerignore @@ -0,0 +1,8 @@ +* + +!.dockerignore +!VERSION +!entrypoint.sh +!install.sh +!gpgparams +!Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e69de29..bf92576 100644 --- a/Dockerfile +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:jammy + +EXPOSE 25/tcp +EXPOSE 143/tcp + +WORKDIR /protonmail + +# Copy bash scripts +COPY gpgparams install.sh entrypoint.sh VERSION /protonmail/ + +# Install dependencies and protonmail bridge +RUN bash install.sh + +ENTRYPOINT ["bash", "/protonmail/entrypoint.sh"] \ No newline at end of file diff --git a/ENV b/ENV index e69de29..bce8e58 100644 --- a/ENV +++ b/ENV @@ -0,0 +1 @@ +APP_DIR=/mnt/user/appdata/protonmail-bridge-v2 \ No newline at end of file diff --git a/VERSION b/VERSION index e69de29..d612ab6 100644 --- a/VERSION +++ b/VERSION @@ -0,0 +1 @@ +3.12.0-1 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..896f6d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +services: + protonmail-bridge: + container_name: protonmail-bridge-v2 + build: . + ports: + - 1025:25/tcp + - 1143:143/tcp + restart: unless-stopped + volumes: + - ${APP_DIR:?err}/app:/root + networks: + - main + +networks: + main: + driver: bridge + external: true \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index e69de29..6bbb77e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -ex + +# Initialize +if [[ $1 == init ]]; then + + # # Parse parameters + # TFP="" # Default empty two factor passcode + # shift # skip `init` + # while [[ $# -gt 0 ]]; do + # key="$1" + # case $key in + # -u|--username) + # USERNAME="$2" + # ;; + # -p|--password) + # PASSWORD="$2" + # ;; + # -t|--twofactor) + # TWOFACTOR="$2" + # ;; + # esac + # shift + # shift + # done + + # Initialize pass + gpg --generate-key --batch /protonmail/gpgparams + pass init pass-key + + # Login + protonmail-bridge --cli + +else + + # 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:25,fork TCP:127.0.0.1:1025 & + socat TCP-LISTEN:143,fork TCP:127.0.0.1:1143 & + + # Start protonmail + # Fake a terminal, so it does not quit because of EOF... + rm -f faketty + mkfifo faketty + cat faketty | protonmail-bridge --cli + +fi \ No newline at end of file diff --git a/gpgparams b/gpgparams index e69de29..720ad37 100644 --- a/gpgparams +++ b/gpgparams @@ -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 \ No newline at end of file diff --git a/install.sh b/install.sh index e69de29..e0ba6df 100644 --- a/install.sh +++ b/install.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -ex + +VERSION=`cat VERSION` +DEB_FILE=protonmail-bridge_${VERSION}_amd64.deb + +# Install dependents +apt-get update +apt-get install -y --no-install-recommends socat pass ca-certificates + +# Build time dependencies +apt-get install -y wget binutils xz-utils + +# Repack deb (remove unnecessary dependencies) +mkdir deb +cd deb +wget -q https://git.lanubya.de/Lanubya/protonmail-bridge-v2/raw/branch/main/${DEB_FILE} +ar x -v ${DEB_FILE} +mkdir control +tar zxvf control.tar.gz -C control +sed -i "s/^Depends: .*$/Depends: libgl1, libc6, libsecret-1-0, libstdc++6, libgcc1/" control/control +cd control +tar zcvf ../control.tar.gz . +cd ../ +ar rcs -v ${DEB_FILE} debian-binary control.tar.gz data.tar.gz +cd ../ + +# Install protonmail bridge +apt-get install -y --no-install-recommends ./deb/${DEB_FILE} + +# Cleanup +apt-get purge -y wget binutils xz-utils +apt-get autoremove -y +rm -rf /var/lib/apt/lists/* +rm -rf deb